Skip to content

Commit

Permalink
BEHOLD! Feature test macros!
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed May 27, 2024
1 parent 264513e commit ff911fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,9 +1659,14 @@ void BestVideoSource::WriteTimecodes(const std::filesystem::path &TimecodeFile)

fprintf(F.get(), "# timecode format v2\n");
for (const auto &Iter : TrackIndex.Frames) {
double timestamp = (Iter.PTS * VP.TimeBase.Num) / (double)VP.TimeBase.Den;
#ifdef __cpp_lib_to_chars
char buffer[100];
auto res = std::to_chars(buffer, buffer + sizeof(buffer), (Iter.PTS * VP.TimeBase.Num) / (double)VP.TimeBase.Den, std::chars_format::fixed, 2);
auto res = std::to_chars(buffer, buffer + sizeof(buffer), timestamp, std::chars_format::fixed, 2);
fprintf(F.get(), "%s\n", std::string(buffer, res.ptr - buffer).c_str());
#else
fprintf(F.get(), "%.02f\n", timestamp);
#endif
}
}

Expand Down

0 comments on commit ff911fa

Please sign in to comment.