FFmpeg - change video resolution with aspect ratio

everything.

How to change video resolution with aspect ratio with FFmpeg?

There are options http://manpages.ubuntu.com/manpages/oneiric/man1/ffmpeg.1.html

-s size Set frame size. The format is wxh (ffserver default = 160x128, ffmpeg default = same as source). The following abbreviations are recognized: 

and

  -aspect aspect Set the video display aspect ratio specified by aspect. aspect can be a floating point number string, or a string of the form num:den, where num and den are the numerator and denominator of the aspect ratio. For example "4:3", "16:9", "1.3333", and "1.7777" are valid argument values. 

For example, I have two input videos:

  • with a resolution of 200 * 400
  • with a resolution of 400 * 700

I need to make an output video with a resolution of 100 * 200.

If I run ffmpeg with -s 100x200, then the second video will have a bad proportion.

How to limit the output video in width, with an automatic aspect ratio in height?

For example, I want to specify only 100 pixels wide for the output video, and ffmpeg should automatically calculate the height with the correct aspect ratio.

For the first video, it will be:

200/100 = 2

400/2 = 200

Those. 100x200

For the second video, it will be:

400/100 = 4

700/4 = 75

Those. 100x75

Is it possible?

+11
ffmpeg video resolution aspect-ratio
source share
5 answers

ffmpeg -i <input> -vf scale=720x406,setdar=16:9 <output>

Find out more about this,

Changing-resolution-video-using-ffmpeg

+15
source share

Not working with video. This page applies only to still images.

For reasons not fully understood, the FFMPEG monkeys around with the Sample / Pixel Aspect Ratio return the video to its original aspect ratio. For example, if you stretch the video image twice as wide, it will make the aspect ratio 1: 2 or something similar (2: 1?)

Thus, if you really want to stretch the video from the "Stretch Armstrong" style, you need to force the SAR (Sample Aspect Ratio):

 ffmpeg -i <something> -vf scale=iw*55:ih,setsar=1:1 ... 

This is not well described in the FFMPEG manual, here is the response of video.stackexchange, which puts it all in one place.

+8
source share

Both options are listed below: with scale:

 ffmpeg -i source.mp4 -r 15 -s 320x240 -strict -2 destination.mp4 

With aspect ratio:

 ffmpeg -i source.mp4 -r 15 -aspect 1:1 -strict -2 destination.mp4 
+1
source share

Use the magic number -1 to proportionally resize the video, and setdar needs to use a slash / as a delimiter rather than a colon :

 ffmpeg -i <input> -vf "scale=100:-1,setdar=16/9" <output> 

The team will resize the video from 100x200 to 100x200 and from 400x700 to 100x175 with an aspect ratio of 16:9

0
source share

I use iDealshare VideoGo to change the aspect ratio of the video: click "Settings ..." → "Advanced Settings" → "Aspect Ratio", click the "Auto" button to select 4: 3 or 16: 9, or just overwrite what you want. such as 2.35: 1, 1.85: 1, 1: 1, etc.

0
source share

All Articles