diff --git a/src/tracklist.cpp b/src/tracklist.cpp index 9dfbfab..454186b 100644 --- a/src/tracklist.cpp +++ b/src/tracklist.cpp @@ -64,6 +64,9 @@ void BestTrackList::OpenFile(const std::filesystem::path &SourceFile, const std: TrackList.push_back(TI); } + + File.ContainerStartTime = FormatContext->start_time; + File.ContainerStartTimeBase = AV_TIME_BASE; } BestTrackList::BestTrackList(const std::filesystem::path &SourceFile, const std::map *LAVFOpts) { @@ -120,3 +123,7 @@ std::map BestTrackList::GetTrackMetadata(int Track) co return Result; } + +const BestTrackList::FileInfo &BestTrackList::GetFileInfo() const { + return File; +} diff --git a/src/tracklist.h b/src/tracklist.h index 795e50b..9ba4a30 100644 --- a/src/tracklist.h +++ b/src/tracklist.h @@ -38,10 +38,16 @@ struct BestTrackList { int Disposition; std::string DispositionString; }; + struct FileInfo { + // Warning, ContainerStartTime may be equal to AV_NOPTS_VALUE. + int64_t ContainerStartTime; + int ContainerStartTimeBase; + }; private: AVFormatContext *FormatContext = nullptr; std::vector TrackList; + FileInfo File; void OpenFile(const std::filesystem::path &SourceFile, const std::map &LAVFOpts); void Free(); @@ -52,6 +58,7 @@ struct BestTrackList { [[nodiscard]] const TrackInfo &GetTrackInfo(int Track) const; [[nodiscard]] std::map GetFileMetadata() const; [[nodiscard]] std::map GetTrackMetadata(int Track) const; + [[nodiscard]] const FileInfo &GetFileInfo() const; }; #endif