Hi,
I'm trying to make VLC to play H.264/AAC service from live MPEG-2 TS
broadcast.
And one problem I have is that timestamps are not updated correctly for
video pictures.
I'm working with ffmpeg-0.5.1.
After digging into the code, I found that it is caused by ticks_per_frame.
ticks_per_frame is set to 1 by default but for codec_id ==
CODEC_ID_H264, it is forced to be 2 and time_base.den gets doubled
(refer to decode_init of h264.c).
I don't know why this is required but there is no problem with this code
itself.
The problem happens when time_base is not initialized at codec
initialization time but determined later on after processing some units
from the actual stream.
Current code doesn't double the detected time_base.den and this results
in wrong timestamp calculation in VLC.
The following illustrates what happens for 29.9fps H.264 video stream
with 1001/30000 time factors.
ticks_per_frame time_base.num time_base.den
Before init 1 0 1
After init 2 0 2
Parsed slice hdr 2 1001 30000 (wrong?)
Parsed slice hdr 2 1001 30000*2 (my fix)
So from my understanding, the following should be applied to fix the
problem.
I want to hear opinions from experts in this group and find the right
solution which doesn't break compatibilities.
Thanks,
Tae-il Lim
================================================================
--- h264.c 2010-02-10 04:02:39.000000000 +0900
+++ h264.fix.c 2010-07-23 01:55:36.697361986 +0900
@@ -3776,7 +3776,7 @@
s->avctx->sample_aspect_ratio.den = 1;
if(h->sps.timing_info_present_flag){
- s->avctx->time_base= (AVRational){h->sps.num_units_in_tick,
h->sps.time_scale};
+ s->avctx->time_base= (AVRational){h->sps.num_units_in_tick,
h->sps.time_scale * s->avctx->ticks_per_frame};
if(h->x264_build > 0 && h->x264_build < 44)
s->avctx->time_base.den *= 2;
av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den,
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user