diff --git a/app/codec/ffmpeg/ffmpegdecoder.cpp b/app/codec/ffmpeg/ffmpegdecoder.cpp index 2ab14eadb..c2dbe2488 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.cpp +++ b/app/codec/ffmpeg/ffmpegdecoder.cpp @@ -513,6 +513,8 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can } + desc.SetStreamCount(fmt_ctx->nb_streams); + } // Free all memory diff --git a/app/node/output/viewer/viewer.h b/app/node/output/viewer/viewer.h index 09b0ac3d5..8d26f4bd3 100644 --- a/app/node/output/viewer/viewer.h +++ b/app/node/output/viewer/viewer.h @@ -126,7 +126,7 @@ public: return InputArraySize(kSubtitleParamsInput); } - int GetTotalStreamCount() const + virtual int GetTotalStreamCount() const { return GetVideoStreamCount() + GetAudioStreamCount() + GetSubtitleStreamCount(); } diff --git a/app/node/project/footage/footage.cpp b/app/node/project/footage/footage.cpp index 7b8870ee2..7c89f3496 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -44,7 +44,8 @@ Footage::Footage(const QString &filename) : ViewerOutput(false, false), timestamp_(0), valid_(false), - cancelled_(nullptr) + cancelled_(nullptr), + total_stream_count_(0) { SetCacheTextures(true); @@ -125,6 +126,9 @@ void Footage::Clear() // Clear decoder link decoder_.clear(); + // Clear total stream count + total_stream_count_ = 0; + // Reset ready state valid_ = false; } @@ -497,6 +501,8 @@ void Footage::Reprobe() SetStream(Track::kSubtitle, QVariant::fromValue(footage_info.GetSubtitleStreams().at(i)), i); } + total_stream_count_ = footage_info.GetStreamCount(); + SetValid(); } diff --git a/app/node/project/footage/footage.h b/app/node/project/footage/footage.h index 8397726a2..7eb38f3c5 100644 --- a/app/node/project/footage/footage.h +++ b/app/node/project/footage/footage.h @@ -180,6 +180,8 @@ public: virtual qint64 creation_time() const override; virtual qint64 mod_time() const override; + virtual int GetTotalStreamCount() const override { return total_stream_count_; } + static const QString kFilenameInput; protected: @@ -224,6 +226,8 @@ private: CancelAtom *cancelled_; + int total_stream_count_; + private slots: void CheckFootage(); diff --git a/app/node/project/footage/footagedescription.cpp b/app/node/project/footage/footagedescription.cpp index 610db5c39..742372586 100644 --- a/app/node/project/footage/footagedescription.cpp +++ b/app/node/project/footage/footagedescription.cpp @@ -43,9 +43,11 @@ bool FootageDescription::Load(const QString &filename) // Default to first version of metadata (which wasn't versioned at all) unsigned version = 1; - XMLAttributeLoop((&reader), attr) { - if (attr.name() == QStringLiteral("version")) { - version = attr.value().toUInt(); + { + XMLAttributeLoop((&reader), attr) { + if (attr.name() == QStringLiteral("version")) { + version = attr.value().toUInt(); + } } } @@ -58,6 +60,14 @@ bool FootageDescription::Load(const QString &filename) if (reader.name() == QStringLiteral("decoder")) { decoder_ = reader.readElementText(); } else if (reader.name() == QStringLiteral("streams")) { + { + XMLAttributeLoop((&reader), attr) { + if (attr.name() == QStringLiteral("count")) { + total_stream_count_ = attr.value().toInt(); + } + } + } + while (XMLReadNextStartElement(&reader)) { if (reader.name() == QStringLiteral("video")) { VideoParams vp; @@ -116,6 +126,8 @@ bool FootageDescription::Save(const QString &filename) const writer.writeStartElement(QStringLiteral("streams")); + writer.writeAttribute(QStringLiteral("count"), QString::number(total_stream_count_)); + foreach (const VideoParams& vp, video_streams_) { writer.writeStartElement(QStringLiteral("video")); vp.Save(&writer); diff --git a/app/node/project/footage/footagedescription.h b/app/node/project/footage/footagedescription.h index 930a6e8be..0c55cb044 100644 --- a/app/node/project/footage/footagedescription.h +++ b/app/node/project/footage/footagedescription.h @@ -32,7 +32,8 @@ class FootageDescription { public: FootageDescription(const QString& decoder = QString()) : - decoder_(decoder) + decoder_(decoder), + total_stream_count_(0) { } @@ -118,6 +119,9 @@ public: return StreamIsVideo(index) || StreamIsAudio(index) || StreamIsSubtitle(index); } + int GetStreamCount() const { return total_stream_count_; } + void SetStreamCount(int s) { total_stream_count_ = s; } + bool Load(const QString& filename); bool Save(const QString& filename) const; @@ -138,7 +142,7 @@ public: } private: - static constexpr unsigned kFootageMetaVersion = 2; + static constexpr unsigned kFootageMetaVersion = 3; QString decoder_; @@ -148,6 +152,8 @@ private: QVector subtitle_streams_; + int total_stream_count_; + }; }