Differences between current version and predecessor to the previous major change of FFmpeg.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 18 Last edited on Monday, January 3, 2011 11:58:25 am by LawrenceDoliveiro
Older page: version 17 Last edited on Monday, June 15, 2009 8:28:17 pm by LawrenceDoliveiro Revert
@@ -101,10 +101,27 @@
  -ss 00:01:04.00 -i ''srcmovie'' \ 
  -i ''srcmovie'' \ 
  -vcodec copy -acodec copy ''dstmovie'' \ 
  -map 1.0 -map 0.1 
+!Resize video for DVD  
+Supposing I have a film where the video frames are 608x224 pixels, that I want to put on a DVD. Allowable aspect ratios for DVD-Video are 4:3 or 16:9. Clearly I should use 16:9 as the closest fit to the original ratio, and add black bars at the top and bottom to pad out the video frame.  
+But there is also the complication that pixels in DVD-Video are non-square: even though I want the video displayed at a 16:9 ratio, the number of pixels I have to play with on a PAL DVD is 720x576, which doesn’t match a 16:9 ratio.  
+The trick is to do the calculation in two stages: first calculate the necessary resizing to fill as much as possible of a destination frame size of 720x405 pixels (which has a 16:9 ratio), then apply an additional vertical rescaling to stretch the height from 405 to 576 pixels.  
+So if the width of 608 pixels is rescaled to 720, then the height of 224 pixels must be correspondingly rescaled to (720 / 608) * 224 = 265 (to the nearest pixel), in order to avoid distorting the images. Then I apply another vertical scale factor of 576 / 405 for the non-uniform DVD-Video pixels, to come up with a height of 377 pixels—make it 378, because video encoding algorithms tend to prefer even dimensions.  
+This I then need to pad out to a final height of 576 pixels by adding black bars at the top and bottom. FFmpeg can do this with its “pad” filter, specified as <tt>-vf pad ''width'':''height'':''xoffset'':''yoffset''</tt>. To keep the video nicely centred on the screen, the bars should have equal heights of (576 - 378) / 2 = 99 pixels.  
+So the complete FFmpeg command looks something like this:  
+ffmpeg -i in.mpg -target pal-dvd -s 720x378 -vf pad=720:576:0:99 -aspect 16:9 out.mpg  
 * [FFmpeg home|] 
 * [libamr home page|] -- needed for audio encoding if you're making 3GPP movies to play on cell phones. Recent versions of FFmpeg no longer expect the AMR source code to be inserted into the FFmpeg source tree.