diff --git a/app/codec/ffmpeg/ffmpegdecoder.cpp b/app/codec/ffmpeg/ffmpegdecoder.cpp index 30db4ec5d..938ff3f22 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.cpp +++ b/app/codec/ffmpeg/ffmpegdecoder.cpp @@ -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;inb_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 diff --git a/app/node/project/footage/footagedescription.h b/app/node/project/footage/footagedescription.h index 588c06c2b..bd5ec0545 100644 --- a/app/node/project/footage/footagedescription.h +++ b/app/node/project/footage/footagedescription.h @@ -125,23 +125,17 @@ public: bool Save(const QString& filename) const; - const QVector& GetVideoStreams() const - { - return video_streams_; - } + const QVector& GetVideoStreams() const { return video_streams_; } + QVector& GetVideoStreams() { return video_streams_; } - const QVector& GetAudioStreams() const - { - return audio_streams_; - } + const QVector& GetAudioStreams() const { return audio_streams_; } + QVector& GetAudioStreams() { return audio_streams_; } - const QVector& GetSubtitleStreams() const - { - return subtitle_streams_; - } + const QVector& GetSubtitleStreams() const { return subtitle_streams_; } + QVector& GetSubtitleStreams() { return subtitle_streams_; } private: - static constexpr unsigned kFootageMetaVersion = 5; + static constexpr unsigned kFootageMetaVersion = 6; QString decoder_;