FFmpeg - Scale and Letterbox: Difference between revisions

From PiRho Knowledgebase
Jump to navigationJump to search
Created page with "<pre> ffmpeg -i <input.file> -c:v libx264 -filter:v "scale=(iw*sar)*min(640/(iw*sar)\,480/ih):ih*min(640/(iw*sar)\,480/ih), pad=640:480:(640-iw*min(640/iw\,480/ih))/2:(480-ih*min(640/iw\,480/ih))/2" -f mp4 <output.file> </pre> Reference: FFMPEG - Encoding Optimal Videos for Streaming#Change_Resolution_and_add_Letterbox"
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:FFmpeg]]
[[Category:Video Scaling]]
<pre>
<pre>
ffmpeg -i <input.file> -c:v libx264 -filter:v "scale=(iw*sar)*min(640/(iw*sar)\,480/ih):ih*min(640/(iw*sar)\,480/ih), pad=640:480:(640-iw*min(640/iw\,480/ih))/2:(480-ih*min(640/iw\,480/ih))/2" -f mp4 <output.file>
ffmpeg -i <input.file> -c:v libx264 -filter:v "scale=(iw*sar)*min(640/(iw*sar)\,480/ih):ih*min(640/(iw*sar)\,480/ih), pad=640:480:(640-iw*min(640/iw\,480/ih))/2:(480-ih*min(640/iw\,480/ih))/2" -f mp4 <output.file>
</pre>
</pre>
Reference: [[FFMPEG - Encoding Optimal Videos for Streaming#Change_Resolution_and_add_Letterbox]]
Reference: [[FFMPEG - Encoding Optimal Videos for Streaming#Change_Resolution_and_add_Letterbox]]<br/>
Reference: [[https://stackoverflow.com/questions/61703587/proper-way-to-letterbox-with-ffmpeg stackoverflow: Proper way to letterbox with ffmpeg]]

Latest revision as of 12:41, 6 March 2025

ffmpeg -i <input.file> -c:v libx264 -filter:v "scale=(iw*sar)*min(640/(iw*sar)\,480/ih):ih*min(640/(iw*sar)\,480/ih), pad=640:480:(640-iw*min(640/iw\,480/ih))/2:(480-ih*min(640/iw\,480/ih))/2" -f mp4 <output.file>

Reference: FFMPEG - Encoding Optimal Videos for Streaming#Change_Resolution_and_add_Letterbox
Reference: [stackoverflow: Proper way to letterbox with ffmpeg]