سؤال

I have a list of video files with different resolutions. And I should to change them to 1920x1080. It's easy to make using ffmpeg and scale filter but result video is wrong aspect ratio. If I use aspect ratio then output resolution isn't fullhd. Is it possible to change resolution to best available like scale="'if(gt(a,16/9),1920,-1)':'if(gt(a,16/9),-1,1080)'" and all remaining space is filled in black color ?

هل كانت مفيدة؟

المحلول

Found the solution but don't know if it's nice:

ffmpeg -i a5732-480x320-clip01-sound.mp4 -filter_complex "[0:0]split[main][back];[back]scale=1920:1080[scale];[scale]drawbox=x=0:y=0:w=1920:h=1080:color=black:t=1000[draw];[main]scale='if(gt(a,16/9),1920,-1)':'if(gt(a,16/9),-1,1080)'[proc];[draw][proc]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[fhd];[fhd]setsar=1/1[sarfix]"  output.mp4

Details: split video stream to two streams. First one I scale to 1920x1080 and then fill all area to black color. Second stream I convert to 1920x1080 saving aspect ration so video is always less or equals FullHD resolution. Then Second stream overlays the total black stream so free areas becomes black. And last filter is fixed SAR.

Maybe someone know more elegant solution?

نصائح أخرى

Please try this.. just change scale (320x240) below.

ffmpeg -i source.mp4 -r 15 -s 320x240 -an destination.mp4
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top