ffmpegdecoder: disable stills in otherwise audio only files by default
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user