* [FFmpeg-devel] [PATCH] avformat/demux: use producer timestamp as wallclock when available
@ 2023-10-25 11:42 Clément Péron
0 siblings, 0 replies; only message in thread
From: Clément Péron @ 2023-10-25 11:42 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Clément Péron
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-25 11:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25 11:42 [FFmpeg-devel] [PATCH] avformat/demux: use producer timestamp as wallclock when available Clément Péron
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