[FFmpeg-devel] [RFC][PATCH] ticks_per_frame / timebase
Ivan Schreter
schreter
Fri Feb 27 18:47:42 CET 2009
Ivan Schreter wrote:
> Michael Niedermayer wrote:
>
>> On Fri, Feb 27, 2009 at 09:54:36AM +0100, Ivan Schreter wrote:
>>
>>
>>> Michael Niedermayer wrote:
>>>
>>>
>>>> good, ive applied it, if you find more regressions please tell me
>>>>
>>>>
>>>>
>>>>
>>> TS works without problem.
>>>
>>> However, there is a regression with MOV. I tried to decode trailer for
>>> movie "9", which is H.264 progressive 23.98 fps, but it detects it as
>>> 11.99 fps:
>>>
>>>
>> that happens because of local changes in your tree, i suspect the hunk
>> to the r_frame_rate code i rejected
>>
>>
>>
> I looked at the changes before reporting it. But you are right, there
> was one hunk where I removed H264 from tb_unreliable. This was the reason.
>
> OTOH, when reverting this hunk, interlaced field-picture H.264 stream is
> detected at 2*fps... I'll check it later, but I don't think it's because
> of my local changes (only seeking changes are there).
>
>
So, now I looked at it. The problem is, the information repeat_pict and
ticks_per_frame is not enough to determine frame duration for
tb_unreliable H.264 stream.
So we have following values for these MPEG-TS H.264 streams:
Progressive: ticks_per_frame == 2, repeat_pict == 1, dts deltas == frame
duration.
Interlaced, field-pictures: ticks_per_frame == 2, repeat_pict == 0, dts
deltas == 1/2 frame duration.
Interlaced, top-bottom pictures: ticks_per_frame == 2, repeat_pict == 1,
dts deltas == frame duration.
All of these use timebase 2*fps.
However, for H.264 MOV stream (progressive) we have timebase == fps!
So I think the only way to determine frame rate correctly is to take
frame durations as dts deltas of initial frames (as done for
tb_unreliable) and if we know the frames represent field pictures,
multiply these durations by factor 2 to get full-picture durations.
Then, compute frame rate and eventually ticks_per_frame from this (not
really sure whether ticks_per_frame is needed, except for suppressing
the warning in ffmpeg.c).
I.e., something along the lines of my original patches with field
picture flag. I updated them with Michael's suggestion regarding using
AVPacket.flags instead of extra flag. Updated patches attached.
With these patches, decoding of all four types of H.264 videos works
with correct frame rate.
I suppose, something along the lines of h264_fieldframe_flag will be
also needed for MPEG-2 field pictures.
Regards,
Ivan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avcodec_fieldframe_flag.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090227/8e3f2e31/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avformat_fieldframe_flag.patch
Type: text/x-patch
Size: 2023 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090227/8e3f2e31/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: h264_fieldframe_flag.patch
Type: text/x-patch
Size: 752 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090227/8e3f2e31/attachment-0002.bin>
More information about the ffmpeg-devel
mailing list