11

Suppose you have a 16:9 aspect ratio wide-format movie file and you want to make a version ideal for playing on a 4:3 device. Since you don't want to clip any of the image or distort the picture, so you want to make a letterbox version.

That is, you want a 4:3 movie with black bars at the top and bottom surrounding the moving image rectangle, which has true 16:9 dimensions.

Can you tell us how to do this in Windows or Linux, using free command-line or GUI tools.

6 Answers 6

11

Newer versions of ffmpeg deprecate the "padtop" and "padbottom" options. To do it with the new version, use the same basic logic above. In my case, my original video was 720x404, but I wanted to encode 720x480 - padding the top and bottom. So per-above:

(480-404) / 2 = 38

i.e. Pad 38 pixels to both the top and bottom. The "pad" command wants the size of the video you are encoding, and how far left and down you want to move the original. So:

-vf pad=720:480:0:38

note that the output resolution needs to be written as 720:480 not 720x480

1
7

This can be done in ffmpeg. Before you begin, read this great resource on understanding the math: http://www.doom9.org/index.html?/aspectratios.htm

First, calculate the top and bottom padding values.

long=width of original,
skinny=height of orginal
totalPadding = .75*long - skinny
top padding = bottom padding = totalPadding / 2

NOTE: if the top and bottom paddings are not EVEN numbers, force them even so that they sum to totalPadding (e.g. not 47 and 53, but 48 and 52 to get 100)

Second, add letterbox bars and ensure outfile will be recognized as 4x3. Suppose your paddings came out to be 58 pixels for both top and bottom

ffmpeg -i Infile.avi -padtop 58 -padbottom 58 -padcolor 000000 -aspect 4:3 Outfile_letterbox.mpg
2

By "ideal" I'm guessing your playback device is stretching videos?

The ideal situation is no to add black bars to the video, but to display the video with black bars - re-encoding a video to add bars not only breaks the rule of "encode once" but ALSO lowers the over-all quality per bit by adding extra, useless information.

Can you explain further what problem you're trying to solve?

2
  • I have a 4:3 TV. I have 16:9 movies. I burn them to playable DVDs and one of two things happens 1) they get resized to 4:3 (i.e. stretched) 2) they don't get stretched but don't show as letterboxed. Since it's impossible to have an unstretched 16:9 image fill up a 4:3 screen, this means the edges are getting cropped. I'm using some cheesy commercial software to make playable DVDs (Cyberlink PowerProducer). Maybe that is the problem. I'm open to other ways of making the DVDs from .avi and .mpg files in the first place.
    – dggoldst
    Aug 20, 2009 at 13:12
  • Ahhh, ok, there's the problem - I don't use disks anymore, but I suggest shopping around for other software - off the top of my head I think you need to be able to export with anamorphic pixels - this will stretch the video to 4:3 but tell the player to change the ratio. Aug 20, 2009 at 13:21
2

Download and install Avisynth. Open notepad, put in the following:

AviSource("c:\movies\somemovie.avi")
BicubicResize(720,266,0,0.5)
AddBorders(0, 106, 0, 108)

Save it as mymovie.avs, and put that into your encoder.

You might have to tweak the resize and borders, but generally you can see what's going on here. Also, if your video doesn't load with AviSource, replace it with DirectShowSource.

0

Windows Movie Maker has this function: http://windowshelp.microsoft.com/Windows/en-US/Help/d7783074-18d6-4f9a-8dfb-e0b1ab6c45e11033.mspx

1
  • Reading that, it's not clear to me that it doesn't simply change the aspect ratio? Many packages do this, but they either crop or distort the image. I'm looking for a way that will make a letterbox edition, with black bars on top and bottom.
    – dggoldst
    Aug 20, 2009 at 13:41
0

A Free, open-source program called DeVeDe for Linux (and Windows port, too) takes care of this automatically and well http://www.rastersoft.com/programas/devede.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .