Zoom video using ffmpeg commands

All we need is an easy explanation of the problem, so here it is.

Is it possible to zoom a video and save it using ffmpeg commands?

I searched a lot but I did not find any solution.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Zooming is a two step process. You want to:

  1. Scale the video by a factor of your choice.
  2. Crop the video back to its original size.

That’d look something like this, e.g. to zoom in with a factor of 2, assuming an input video of 1280×720 pixels:

ffmpeg -i input.mp4 -vf "scale=2*iw:-1, crop=iw/2:ih/2" output.mp4

Of course, you can change the factor here. The -1 means that the height will be set automatically.

You can use two additional parameters for the crop filter to set the position of the cropping window.

Have a look at the x264 encoding guide if you need to change the output quality (it will be reduced compared to the original, of course).

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply