13 Jul 2007 rillian   » (Master)

Careful with that --aspect

I've talked to several people on IRC recently about getting the proper aspect ratio when encoding theora video, and wanted to summarize here.

The short answer is, when you're encoding from DV (or most other formats) with ffmpeg2theora don't use the --aspect switch. The program will calculate the correct aspect ratio based on the source and whatever target resolution you give it, either through a -p profile or explicit -x -y switches.

The --aspect switch is for overriding the default calcuation, usually because the input source video is incorrectly marked. But video aspect ratios are confusing, and it's easy to mess up. For example, if you take a DV source video and encode with -x 320 -y 240 --aspect 4:3, you will get a video that says its pixels are square, but in fact they are not, so playback will be distorted. Without the --aspect switch, ffmpeg2theora will mark the file with the correct (non-4:3) aspect ratio.

Huh? 320x240 is 4:3! Yes. DV, whose native resolution is 720x480 (NTSCish) or 720x576 (PALish) contains some overscan area, and so the full frame is not a 4:3 image. It roughly contains one, and the theory is the extra bits get masked off by the edges of your CRT. Computers have nice, square pixels, so everything is much easier, but digital video imports a lot of the complexity of the analog technology it developed from, and had to interoperate with.

Since the full DV frame isn't actually 4:3--or 16:9 if you're shooting in wide screen--you have to crop if you want to make an actual, standard ratio, square pixel file.

For example:

ffmpeg2theora -x 320 -y 240 --cropleft 8 --cropright 8 -o output.ogg input.dv
will give you square pixels with a 4:3 frame aspect ratio.

For 16:9, use something like:

ffmpeg2theora -x 640 -y 360 --cropleft 8 --cropright 8 -o widescreen.ogg widescreen.dv

The same thing goes for the --deinterlace flag. It forces using the deinterlace filter regardless of whether the input is marked as interlaced or not, and so can degrade quality on progressive material. DV is a very sane format and all of these things are reliably marked. In general, trust the defaults.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!