[FFmpeg-devel] [PATCH 6/6] lavf: count skipped samples for initial timestamps.

Nicolas George nicolas.george at normalesup.org
Sun Jul 15 17:53:06 CEST 2012


If skip_samples is set and timestamps are synthesized using durations,
make them start at -skip_samples (rescaled) instead of 0,
so that the timestamp of the first undiscarded sample is 0.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavformat/utils.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index ae3a39a..98273ef 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -942,6 +942,10 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
     AVPacketList *pktl= s->parse_queue ? s->parse_queue : s->packet_buffer;
     int64_t cur_dts= RELATIVE_TS_BASE;
 
+    if (st->skip_samples && st->codec->sample_rate && st->time_base.num)
+        cur_dts -= av_rescale_q(st->skip_samples,
+                                (AVRational){ 1, st->codec->sample_rate },
+                                st->time_base);
     if(st->first_dts != AV_NOPTS_VALUE){
         cur_dts= st->first_dts;
         for(; pktl; pktl= get_next_pkt(s, st, pktl)){
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list