ffmpeg - formula to calculate video dimensions for target aspect ratio -


i building application converts videos specific dimension under consideration of target aspect ration.

the target resolution must 1280x720, want fit uploaded video in size using black bars.

can point out formula calculate target video dimensions without changing it's aspect ratio? if target smaller 1280x720 i'll add missing pixels black bars.

i'm using ffmpeg "-vf scale=1280x720,pad=?:?:black" command

(sorry if english not great)

read this page, particularly section:

sometimes there need scale input image in such way fits specified rectangle, i.e. if have placeholder (empty rectangle) in want scale given image. little bit tricky, since need check original aspect ratio, in order decide component specify , set other component -1 (to keep aspect ratio). example, if scale our input image rectangle dimensions of 320x240, use this:

ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'" output_320x240_boxed.png 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -