diff --git a/src/videosource.cpp b/src/videosource.cpp index 5c79361..2fc4d9b 100644 --- a/src/videosource.cpp +++ b/src/videosource.cpp @@ -1545,16 +1545,18 @@ bool BestVideoSource::GetFrameIsTFF(int64_t N, bool RFF) { } } -bool BestVideoSource::WriteTimecodes(const std::filesystem::path &TimecodeFile) const { +void BestVideoSource::WriteTimecodes(const std::filesystem::path &TimecodeFile) const { + for (const auto &Iter : TrackIndex.Frames) + if (Iter.PTS == AV_NOPTS_VALUE) + throw BestSourceException("Cannot write valid timecode file, track contains frames with unknown timestamp"); + file_ptr_t F(OpenNormalFile(TimecodeFile, true)); if (!F) - return false; + throw BestSourceException("Couldn't open timecode file for writing"); fprintf(F.get(), "# timecode format v2\n"); for (const auto &Iter : TrackIndex.Frames) fprintf(F.get(), "%.02f\n", (Iter.PTS * VP.TimeBase.Num) / (double)VP.TimeBase.Den); - - return true; } const BestVideoSource::FrameInfo &BestVideoSource::GetFrameInfo(int64_t N) const { diff --git a/src/videosource.h b/src/videosource.h index acf7b64..eb1e09b 100644 --- a/src/videosource.h +++ b/src/videosource.h @@ -274,7 +274,7 @@ class BestVideoSource { [[nodiscard]] BestVideoFrame *GetFrameWithRFF(int64_t N, bool Linear = false); [[nodiscard]] BestVideoFrame *GetFrameByTime(double Time, bool Linear = false); [[nodiscard]] bool GetFrameIsTFF(int64_t N, bool RFF = false); - bool WriteTimecodes(const std::filesystem::path &TimecodeFile) const; + void WriteTimecodes(const std::filesystem::path &TimecodeFile) const; [[nodiscard]] const FrameInfo &GetFrameInfo(int64_t N) const; [[nodiscard]] bool GetLinearDecodingState() const; };