[FFmpeg-user] Detect if an MTS file is interlaced or not?
Thomas Worth
dev at rarevision.com
Wed Jun 15 16:52:10 CEST 2011
On Wed, Jun 15, 2011 at 7:06 AM, Mike Scheutzow
<mike.scheutzow at alcatel-lucent.com> wrote:
> Thomas Worth wrote:
>>>>
>>>> On Wed, Jun 8, 2011 at 2:13 AM, Thomas Worth <dev at rarevision.com> wrote:
>>>> It doesn't seem to be getting it from r_frame_rate, since that is
>>>> always double the playback rate with MTS it seems.
>
>>> The double rate is not an artifact of the container. The container knows
>>> nothing about the frame rate.
>>
>> The container, or at least the streams should be flagged as
>> field-based and have some type of field order flag (top first / bottom
>> first).
>
> For a transport stream container, this is not the case. There is no
> field/frame info at the container level. There is no field/frame info at the
> global stream level. For H.264, this information is placed at the Frame
> level.
>
> For H.264, you have to examine the Slice NAL to determine field/frame and
> top/bottom status. This is because H.264 is very flexible, and allows mixing
> field pictures and frame pictures in the same elementary stream.
>
>> Otherwise, a playback device wouldn't know how to play it
>> back. It is this information I need to interpret, but I just can't
>> seem to get it. I know the information is there, I just need to know
>> how to retrieve it from avcodec.
>
> There are two fields, but they don't tell you what you seem to want.
>
> See AVFrame.interlaced_frame and AVFrame.top_field_first in avcodec.h. These
> fields are part of the AVFrame information returned by
> avcodec_decode_video2().
>
> Be careful though: these fields do NOT tell you whether the input to the
> decoder was 2 field pictures or 1 frame picture, because a frame picture can
> also can also contain interlaced top/bottom content (this is very common.)
>
> As far as I know, FFmpeg does not provide an easy way to determine if a
> particular AVPacket holds 1 field or 1 frame.
Thanks, Mike. That's very helpful. I've tried decoding a single frame
and inspecting the AVFrame.interlaced_frame, but as you suspected it
doesn't tell me what I need to know (even though avcodec.h suggests
that this should be set by the decoder). What is perplexing is that
VLC will play back these videos at the correct frame rate, and I
suspect FFplay will as well. VLC also deinterlaces the video properly
and with the correct field order. Since this is the case, how are
these apps figuring this out?
More information about the ffmpeg-user
mailing list