If you've ever downloaded a video off the Internet using, say, Youtube Downloader, and it had both really annoying boxing around it so the poster could put their own logo or advertising, and the video was big enough that your machine chugged and lagged and it became hard to watch, here's the ffmpeg command to reduce it to size.
The switch you want is
-filter:v "crop=width:height:x-offset:y-offset,scale=max-width,-2"
Here's the full command:
ffmpeg -y -i 'WARHAMMER 40K Full Cinematic.webm' \
-filter:v "crop=3840:1604:0:280,scale=1440,-2" \
Space_Marine_2_Cutscene_Movie.mp4
Explanation:
I wanted to watch the (very spoilery) cut scenes from the new Warhammer 40K game, Space Marine II, since I really enjoyed the original. But the video was both almost two hours long (that's a lot of cutscene!) and caused my poor little 2013 Lenovo Yoga to just give up and die. After downloading the video, I still had to convert it.
Ffmpeg has a simple command that will both crop the video (which was something like 3840x2160!) and then resize it automatically. There are probably faster ways to do this, but here's mine.
First, I played the video using mplayer --vf screenshot
, and when the annoying black outline
appeared hit s
and then quit. In GIMP, I edited the produced file (cleverly named
shot0001.png
), found that the black outline was just for the widescreen (and the "GameClips"
logo, which seems a little sketchy to me, but hey, we're not exactly in "honoring IP" territory here
anyway), started at 0x280 (width x height) and stopped at 3840x1884. Doing some quick math of 1884 -
280, I found I wanted a height of 1604.
So... I wanted to crop it to 3840x1604, offset 0x280.
The Yoga's screen is 1440pixels wide. Ffmpeg will preserve the aspect ratio if you put a -2
in
the "max-height" position.
So the crop command, as seen above, is: crop=3840:1604:0:280
, and the scale command would just be
scale=1440,-2
.
The -y
means "Overwrite existing output without asking." It's t there because I got tired of
fiddling with it and having to say "Sigh, yes, go ahead and overwrite the last attempt."
And that's it.