Zoom video using ffmpeg commands
Is it possible to zoom a video and save it using ffmpeg commands?
I searched a lot but I did not find any solution.
Zooming is a two step process. You want to:
- Scale the video by a factor of your choice.
- 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).