User Tools

Site Tools


ffmpeg:video:resize:maintain_aspect_ratio

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ffmpeg:video:resize:maintain_aspect_ratio [2025/01/29 22:10] – created peterffmpeg:video:resize:maintain_aspect_ratio [2025/01/29 22:18] (current) peter
Line 1: Line 1:
 ====== ffmpeg - Video - Resize - Maintain aspect ratio ====== ====== ffmpeg - Video - Resize - Maintain aspect ratio ======
 +
 +<code bash>
 +-vf scale=1920:-1
 +-vf scale=-1:1080
 +-vf scale=1920:-2
 +-vf scale=-2:1080
 +</code>
 +
 +<WRAP info>
 +**NOTE:**
 +
 +  * **-1** for the width or height will keep it in ratio to the other specified dimension.
 +  * **-2** will keep it in ratio to the other specified dimension, but, to ensure it is divisible by 2 (a requirement for certain encodings such as yuv420p) the width or height will be adjusted if necessary.
 +
 +</WRAP>
 +
 +----
 +
 +===== Example =====
 +
 +<code bash>
 +ffmpeg -i input.mp4 -vf "scale=1920:-1" -c:a copy output.mp4
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The **-1** tells ffmpeg to automatically calculate the height while maintaining the aspect ratio after sizing to the new width.
 +
 +  * **-i input.mp4**: Specifies the input video file.
 +  * **-vf "scale=1920:-1"**: Applies the scale filter to resize the video width to 1920 pixels, and the video height is calculated to ensure the aspect ratio is maintained.
 +  * **-c:a copy**: Copies the media streams without re-encoding.
 +  * **output.mp4**: Name of the output file.
 +
 +</WRAP>
  
  
  
ffmpeg/video/resize/maintain_aspect_ratio.1738188623.txt.gz · Last modified: 2025/01/29 22:10 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki