11

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

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

slhck
  • 228,104
Gururaj
  • 225
  • 4
    Yes it is possible to zoom. Does that help? Your questions are too vague. They cannot be answered unless you are more specific. – Rajib Dec 06 '13 at 13:01

1 Answers1

21

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

slhck
  • 228,104
  • scale=2*iw:-1,crop=iw/2:ih/2 could be used for 2x zoom. – llogan Dec 10 '13 at 00:36
  • Slhck thanks for ypur reply. That command is working perfectly, but where can I change the amount of zooming, and how can I use this command for zoo out?. – Gururaj Dec 10 '13 at 11:25
  • @Gururaj I mentioned that in my example the factor would be 2, so you simply have to choose another factor. I'm not sure if zooming out is that easily accomplished with a factor between 0 and 1. I can't try it now. – slhck Dec 10 '13 at 11:38
  • slhck I am getting some bars on video after zooming. – Gururaj Dec 12 '13 at 05:38
  • @Gururaj If there's an issue with the command, you should probably post a new question, mention exactly what command you're using, and show the full, uncut command line output. Note that if you want to zoom out you have to scale down first and then pad the output. – slhck Dec 12 '13 at 08:40