39

I have a video that shows the following

enter image description here

and I would like to crop it to this:

enter image description here

How can I do it?

  • What have you tried yet and where did you get stuck? I'm sure there are dozens of tools that allow cropping video, so it might help to ask a more specific question, else we get a list of software that crops video – which is considered not constructive – slhck Nov 26 '12 at 21:11
  • I tried to find an application that supports this. I only found ffmpeg, but ffmpeg -croptop 90 -i original.ogv "output.ogv" gave me Vertical crop dimensions are outside the range of the original image. I did not find any graphical program for this task. – Martin Thoma Nov 26 '12 at 21:14
  • I would be happy if you could name me one program, that does allow me to crop by place, not by time. – Martin Thoma Nov 26 '12 at 21:15
  • Adobe Premiere, ffmpeg crop filter, Handbrake, QuickTime Pro, iMovie, VirtualDub, VidCrop – slhck Nov 26 '12 at 21:44
  • 1
    The ffmpeg syntax with croptop is quite old and won't be supported in any somewhat recent versions. You'll need to use the -filter:v command, see FFmpeg documentation. – slhck Nov 26 '12 at 21:48
62

Cropping with FFmpeg

With FFmpeg, cropping works as follows, using the crop filter:

ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4

Where the options are as follows:

  • out_w is the width of the output rectangle
  • out_h is the height of the output rectangle
  • x and y specify the top left corner of the output rectangle

So, for example, to crop a 640×480 window, starting from position (100, 100), you'd do:

ffmpeg -i in.mp4 -filter:v "crop=640:480:100:100" out.mp4

Be aware that FFmpeg will re-encode the video using x264, when the MP4 container is selected. With no additional options, this defaults to a constant rate factor (CRF) set to 23. To increase the quality—which could be necessary for screen recordings with sharp edges and text—use a lower value, maybe go down to 18:

ffmpeg -i in.mp4 -filter:v "crop=640:480:100:100" -crf 18 out.mp4

Cropping with Handbrake

Handbrake is a free and open source cross-platform tool with a GUI. Load the input file, then use the Picture Settings to specify the crop:

You can use the Preview Window to visually adjust the crop.

Here, you can also adjust the output quality with the Constant Quality slider:

| improve this answer | |
  • In handbrake 1.2.2 the crop setting is in Dimensions tab of the main window. – jarno Mar 4 at 11:18
3

Did you use Ubuntu's default recordMyDesktop tool? If so, click "Select Window" and then draw a rectangle on the thumbnail it shows of your current desktop. This area will be recorded. This is not "cropping a video" but "cropping a scene" but I think it should solve your problem at hand...

| improve this answer | |
  • As I have started the program inside of VirtualBox and I want to record it from the outside, I can't select the window. So this answer doesn't help (btw.: yes, I used recordmydesktop, but without a GUI which makes choosing a window quite difficult) – Martin Thoma Nov 27 '12 at 7:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.