[MPlayer-DOCS] RFC: mencoder with interlacing/telecine howto (draft 1)

D Richard Felker III dalias at aerifal.cx
Sun Jan 4 18:20:58 CET 2004


On Sat, Jan 03, 2004 at 07:02:25PM -0800, Corey Hickey wrote:
> It is not possible to retrieve a complete progressive video from interlaced
> content without losing half of the vertical resolution. Unless you are
> downscaling to smaller than 1/2 of the original size, you have two choices:

It is possible (deinterlace to 60fps). However, such files will not
compress well at all, and they'll take insane cpu power to decode. To
make one you need to use -vf tfields, which is buggy with G1... :)

> 1. Encode the video in interlaced form. Normally, interlacing wreaks havoc with
> the encoder's ability to compress well, but lavc has an ildct parameter for
> dealing with storing interlaced video a bit better. Note that -ofps is NOT
> needed here.
> $ mencoder dvd://1 -nosound -ovc lavc -lavcopts ildct

It also has interlaced motion vector support now too, which you should
enable. And mbd=2 should be used so that macroblocks get encoded
non-interlaced when there's no motion.

> 2. Use a deinterlacing filter before encoding. There are several of these
> filters available to choose from, each with its own advantages and
> disadvantages. Consult mplayer -pphelp to see what's available (grep for
> "deint"), and search the mplayer mailing lists to find many discussions about
> the various filters. Again, the framerate is not changing, so no -ofps. Also,
> postprocessing should be done after cropping and before scaling.
> $ mencoder dvd://1 -nosound -vf pp=lb -ovc lavc

While you're mentioning cropping, crop height and offset must _always_
be a multiple of 4 for 4:2:0 video. If not you'll mess it up bad.

> If, however, you plan on downscaling dramatically, you can use the il filter to
> separate the two fields, and only encode one. Of course, you'll lose half the
> vertical resolution, but if you plan on downscaling to at most 1/2 of the
> original, the loss won't matter much. The result will be a progressive 29.97
> frames per second file. Here's the procedure. You can apply each filter with
> mplayer first to test, before encoding.
> 
> 1. Use il=d:d to separate the two fields.
> 2. Use -vf crop to extract either field (without any surrounding black bars, of
>    course).
> 3. Scale appropriately. First divide the cropped horizontal resolution by two,
>    and then adjust the scaling parameters to maintain the original aspect ratio
>    and to make the resolutions divisible by 16. How to do the latter part is
>    described in other documents.
> $ mencoder dvd://1 -nosound -vf il=d:d,crop=718,180:0:30,scale=308:180 -ovc lavc

This procedure is unnecessarily slow. Just use -vf field=0 (or 1 if
you want the bottom field).

> ---Mixed progressive and telecine---
> 
> In order to turn mixed progressive and telecine video into entirely progressive
> video, the telecined parts have to be inverse-telecined. There are two filters
> that accomplish this natively: pullup and filmdint.
> 
> Pullup doesn't really work well with the current mencoder, and is intended for
> use with mencoder G2 (whenever it's ready).

It works fine if you don't need -ofps. Unfortunately that will make
the output choppy.

> Filmdint
> TODO: DESCRIBE FILMDINT (I haven't used filmdint yet, but it ought to be good)

It's ok, but IMO it tries to deinterlace rather than doing inverse
telecine too often (much like settop DVD players & progressive TVs)
which gives ugly flickering and other artefacts. If you're going to
use it, you at least need to spend some time tuning the options and
watching the output first to make sure it's not messing up.

> Another, currently very reliable, method is to, rather than inverse-telecine
> the telecined parts, telecine the non-telecined parts and the inverse-telecine
> the whole video. Sound confusing? softpulldown is a filter that goes through a
> video and makes the entire file telecined. If we follow softpulldown with either
> detc or ivtc, the final result will be entirely progressive. Cropping and
> scaling should be done after the inverse-telecine operations, and -ofps 23.976
> is needed.
> $ mencoder dvd://1 -nosound -vf softpulldown,ivtc=1 -ovc lavc -ofps 23.976

This is probably the most reliable method at this time.

> --Mixed progressive and interlaced--
> 
> There are two options for dealing with this category, each of which is a
> compromise. You should decide based on the duration/location of each type.
> 
> 1. Treat it as progressive. The interlaced parts will look interlaced, and some
>    of the interlaced frames will have to be dropped, resulting in a bit of
>    uneven jumpiness. You can use a postprocessing filter if you want to, but it
>    may adversely affect the progressive parts.
> 
> 2. Treat it as interlaced. Some frames of the progressive parts will need to be
>    duplicated, resulting in uneven jumpiness. Again, deinterlacing filters may
>    degrade the progressive parts.

Yes, alas mencoder (G1) doesn't support variable-fps output. I would
strongly recommend against option 1. The best approach (aside from
using a different program to encode) would be to leave output at 29.97
fps. If the interlaced scenes are mostly low-motion, you could try -vf
pp=lb or l5 and see if you think the output is acceptable. This will
blend away the combing without throwing away half the picture, so it
will temporally blur interlaced content, but on the other hand it
won't do serious damage to progressive frames.

Thanks for writing this doc, btw!

Rich




More information about the MPlayer-DOCS mailing list