[FFmpeg-user] Detect if an MTS file is interlaced or not?

Mike Scheutzow mike.scheutzow at alcatel-lucent.com
Tue Jun 14 15:48:00 CEST 2011


Thomas Worth wrote:
> On Wed, Jun 8, 2011 at 2:13 AM, Thomas Worth <dev at rarevision.com> wrote:
>> I'd like to know if there's a way to tell if an MTS file is
>> interlaced, preferably without having to decode it first. The problem
>> I have is that libav always returns 59.94 for the frame rate of
>> interlaced NTSC streams, even though we know it's 29.97. And of
>> course, r_frame_rate always returns 0 with the "mpegts" format so I am
>> left to calculate the frame count manually. I need the correct frame
>> rate to do this, however and there's no way of telling ahead of time
>> whether the input video will be interlaced or not. Any ideas?
>>
> 
> Sorry to nag, but I didn't get a response to this. All I need is a way
> to determine whether an input MTS file (with an H.264 stream) is
> interlaced or not. I thought this could be accomplished by reading
> values from the MTS format context, but I've had no luck. I even tried
> decoding an AVFrame and reading the avframe->interlaced_frame value,
> but it did not report the frame as interlaced even though the video is
> indeed interlaced (comments in avcodec.h say this value is set by the
> decoder).
> 
> Obviously VLC is playing the file back at its intended frame rate even
> though the frame rate reported by avformat is 59.94 (the actual frame,
> not field rate should be 29.97). Where is it getting this information?
> It doesn't seem to be getting it from r_frame_rate, since that is
> always double the playback rate with MTS it seems.


It sounds as if you are trying to decode a file with video field 
pictures (as opposed to frame pictures.) The ffmpeg rate-estimation code 
always makes a mistake and doubles the frame rate in this situation.

I use '-r 30000/1001' on the command line to just tell ffmpeg the 
correct frame rate.

 > 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.


Mike Scheutzow


More information about the ffmpeg-user mailing list