Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFmpeg - Change resolution of the video with aspect ratio

Tags:

all.

How to change resolution of the video 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 200*400 resolution
  • with 400*700 resolution

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

If I will run ffmpeg with -s 100x200, then second video will have bad aspect ratio.

How can I limit output video by width, with auto aspect ratio by height?

For example, I want specify for the output video only width 100px and ffmpeg must automatically calculate height with right aspect ratio.

For first video it will be:

200/100=2

400/2=200

Ie 100x200

For second video it will be:

400/100=4

700/4=75

Ie 100x75

Is it possible?

like image 908
Arthur Avatar asked Jun 06 '14 17:06

Arthur


People also ask

How do I resize in FFmpeg?

More Video Resizing Commands for FFmpeg: If you want to resize a video to half of its original size, then use: scale=w=iw/2:h=ih/2. To resize a video to double of its original dimensions, use this syntax: scale=w=2*iw:h=2*ih.

How do I reduce the size of a video in FFmpeg?

Download and set up FFmpeg on your computer, use command line to compress video with FFmpeg by changing video codec format, lowering down bitrate, cutting video length, etc. For example, set CRF in FFmpeg to reduce video file size (ffmpeg -i input. mp4 -vcodec libx264 -crf 24 output.

How do I change frame rate in FFmpeg?

How to change the frame rate. There are two ways to change the output frame rate: With the -r option used as an output option. With the ​fps filter.


1 Answers

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

like image 133
Devesh Chauhan Avatar answered Dec 08 '22 18:12

Devesh Chauhan