ffmpegdecoder: disable stills in otherwise audio only files by default

This commit is contained in:
itsmattkc
2023-03-20 16:50:11 -07:00
parent c96e560347
commit 0a54585ece
2 changed files with 27 additions and 13 deletions
+20
View File
@@ -319,6 +319,8 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
}
// Dump it into the Footage object
int video_streams = 0, audio_streams = 0, still_streams = 0;
for (unsigned int i=0;i<fmt_ctx->nb_streams;i++) {
// FFmpeg AVStream
@@ -428,6 +430,12 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
desc.AddVideoStream(stream);
if (image_is_still) {
still_streams++;
} else {
video_streams++;
}
} else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
// Create an audio stream object
@@ -473,6 +481,8 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
stream.set_duration(avstream->duration);
desc.AddAudioStream(stream);
audio_streams++;
} else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
// Limit to SRT for now...
@@ -508,6 +518,16 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
desc.SetStreamCount(fmt_ctx->nb_streams);
if (video_streams == 0 && audio_streams > 0 && still_streams > 0) {
// This footage has no video streams, but has audio and image streams. We've probably
// imported a song with embedded album art that most people don't care about. We'll keep the
// stills referenced in case users do, but we'll default them to disabled so they're
// easier to work with.
for (VideoParams &vp : desc.GetVideoStreams()) {
vp.set_enabled(false);
}
}
}
// Free all memory
+7 -13
View File
@@ -125,23 +125,17 @@ public:
bool Save(const QString& filename) const;
const QVector<VideoParams>& GetVideoStreams() const
{
return video_streams_;
}
const QVector<VideoParams>& GetVideoStreams() const { return video_streams_; }
QVector<VideoParams>& GetVideoStreams() { return video_streams_; }
const QVector<AudioParams>& GetAudioStreams() const
{
return audio_streams_;
}
const QVector<AudioParams>& GetAudioStreams() const { return audio_streams_; }
QVector<AudioParams>& GetAudioStreams() { return audio_streams_; }
const QVector<SubtitleParams>& GetSubtitleStreams() const
{
return subtitle_streams_;
}
const QVector<SubtitleParams>& GetSubtitleStreams() const { return subtitle_streams_; }
QVector<SubtitleParams>& GetSubtitleStreams() { return subtitle_streams_; }
private:
static constexpr unsigned kFootageMetaVersion = 5;
static constexpr unsigned kFootageMetaVersion = 6;
QString decoder_;