MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / ConvertFrameToVideoPTS

Method ConvertFrameToVideoPTS

src/FFmpegReader.cpp:2588–2603  ·  view source on GitHub ↗

Convert Frame Number into Video PTS

Source from the content-addressed store, hash-verified

2586
2587// Convert Frame Number into Video PTS
2588int64_t FFmpegReader::ConvertFrameToVideoPTS(int64_t frame_number) {
2589 const double fps_value = (info.fps.num > 0 && info.fps.den > 0) ? info.fps.ToDouble() : 30.0;
2590 const double video_timebase_value =
2591 (info.video_timebase.num > 0 && info.video_timebase.den > 0)
2592 ? info.video_timebase.ToDouble()
2593 : (1.0 / 30.0);
2594
2595 // Get timestamp of this frame (in seconds)
2596 double seconds = (double(frame_number - 1) / fps_value) + pts_offset_seconds;
2597
2598 // Calculate the # of video packets in this timestamp
2599 int64_t video_pts = round(seconds / video_timebase_value);
2600
2601 // Apply PTS offset (opposite)
2602 return video_pts;
2603}
2604
2605// Convert Frame Number into Video PTS
2606int64_t FFmpegReader::ConvertFrameToAudioPTS(int64_t frame_number) {

Callers

nothing calls this directly

Calls 1

ToDoubleMethod · 0.80

Tested by

no test coverage detected