Thursday, April 16, 2009

How to Crop a Video using ffmpeg

As usual, this post is just a self reminder, this time about how to crop a video top and bottom 'black bars' and leave it in a 16:9 format, ready for mythtv ;)

ffmpeg -i In_Movie.avi -croptop 74 -cropbottom 74 -sameq -aspect 16:9 -y Out_Movie.avi

-i In_Movie.avi
Sets the input file

-croptop
Sets the top cropping size in pixels, this value must be a multiple of 2

-cropbottom
Sets the bottom cropping size in pixels, this value must be a multiple of 2

-sameq
Keeps the video's quality as original

-aspect 16:9
Sets the output format to 16:9, widescreen, use 4:3 if your video is letterbox.

-y
Makes ffmpeg stop complaining about overwriting the output file (be careful)

Out_Movie.avi
The output file, which will be a cropped version of the In_Movie.avi

Hope this is useful for someone out there.

Greetings,

Gabriel.