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"
 
mNo edit summary
Line 2: Line 2:
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]]

Revision as of 10:51, 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]