How can I crop a video to a part of the view?

38

15

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?

Martin Thoma

Posted 2012-11-26T20:47:09.333

Reputation: 2 705

People who come to this question might look for software to cut a video (so only the first 10 seconds or something similar). See What to use to quickly cut Audio/Video for that.

– Martin Thoma – 2016-11-01T15:20:13.023

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 – 2012-11-26T21:11:57.683

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 – 2012-11-26T21:14:14.407

I would be happy if you could name me one program, that does allow me to crop by place, not by time. – Martin Thoma – 2012-11-26T21:15:22.773

Adobe Premiere, ffmpeg crop filter, Handbrake, QuickTime Pro, iMovie, VirtualDub, VidCrop

– slhck – 2012-11-26T21:44:26.513

1The 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 – 2012-11-26T21:48:01.913

Answers

61

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:

slhck

Posted 2012-11-26T20:47:09.333

Reputation: 182 472

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...

5gon12eder

Posted 2012-11-26T20:47:09.333

Reputation: 131

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 – 2012-11-27T07:16:21.107