From: "Clément Péron" <peron.clem@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: "Clément Péron" <peron.clem@gmail.com> Subject: [FFmpeg-devel] [PATCH] avformat/demux: use producer timestamp as wallclock when available Date: Wed, 25 Oct 2023 13:42:45 +0200 Message-ID: <20231025114245.170846-1-peron.clem@gmail.com> (raw) When use_wallclock_as_timestamps option is enabled the demux rely on the time of the system even when a producer wallclock is available. If a Producer Reference Timestamp is available use it instead of the system timestamp. Signed-off-by: Clément Péron <peron.clem@gmail.com> --- libavformat/demux.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 6decb08698..94a622e0cc 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -635,8 +635,17 @@ FF_ENABLE_DEPRECATION_WARNINGS force_codec_ids(s, st); /* TODO: audio: time filter; video: frame reordering (pts != dts) */ - if (s->use_wallclock_as_timestamps) - pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); + if (s->use_wallclock_as_timestamps) { + AVProducerReferenceTime *prft; + size_t side_data_size; + + // User Producer Reference time as wallclock when available + prft = (AVProducerReferenceTime *)av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size); + if (prft && side_data_size == sizeof(AVProducerReferenceTime) && prft->flags == 24) + pkt->dts = pkt->pts = av_rescale_q(prft->wallclock, AV_TIME_BASE_Q, st->time_base); + else + pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); + } if (!pktl && sti->request_probe <= 0) return 0; -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2023-10-25 11:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231025114245.170846-1-peron.clem@gmail.com \ --to=peron.clem@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git