User Tools

Site Tools


ffmpeg:video:resize

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ffmpeg:video:resize [2025/01/12 23:07] peterffmpeg:video:resize [2025/01/29 22:37] (current) peter
Line 1: Line 1:
 ====== ffmpeg - Video - Resize ====== ====== ffmpeg - Video - Resize ======
  
-<code bash> +[[ffmpeg:Video:Resize:Basic resize of a video|Basic resize of a video]]
--vf scale=width:height  +
-</code>+
  
-----+[[ffmpeg:Video:Resize:Convert to 1080p (1920x1080)|Convert to 1080p (1920x1080)]]
  
-<code bash> +[[ffmpeg:Video:Resize:Convert to 4K (3840x2160)|Convert to 4K (3840x2160)]]
--vf scale=1280:-2 +
-</code>+
  
-<WRAP info> +[[ffmpeg:Video:Resize:Maintain aspect ratio|Maintain aspect ratio]]
-**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> +
- +
----- +
- +
-===== Upscaling Video to 1080p ===== +
- +
-<code bash> +
-ffmpeg -i input.mp4 -vf scale=1920x1080:flags=lanczos -c:v libx264 -preset slow -crf 21 output_compress_1080p.mp4 +
- +
-# Using GPU. +
-ffmpeg -vaapi_device /dev/dri/renderD128 -i "input.mkv" -vf 'hwupload,scale_vaapi=w=1920:h=1080:format=nv12' -map 0:v -metadata:s:v:0 language=eng -c:v hevc_vaapi -map 0:a -metadata:s:a:0 language=eng -map 0:s? -metadata:s:s:0 language=eng -rc_mode CQP -global_quality 25 -c:a copy -c:s copy -profile:v main -v verbose output_1080p.mkv +
- +
-</code> +
- +
-<WRAP info> +
-**NOTE:**  Lanczos resampling involves a sinc filter as well. +
- +
-  * It is more computationally expensive but usually described as very high quality and can be used for up- and downsampling. +
- +
-</WRAP> +
- +
----- +
- +
-===== Upscaling Video to 4K ===== +
- +
-<code bash> +
-ffmpeg -i input.mp4 -vf scale=3840x2560:flags=lanczos -c:v libx264 -preset slow -crf 21 output_compress_4k.mp4 +
-</code> +
- +
-==== Faster ==== +
- +
-<code bash> +
-ffmpeg -i input.mp4 -vf scale=3840x2560:flags=lanczos -c:v libx264 -preset veryfast -crf 25 output.mp4 +
-</code> +
- +
-<WRAP info> +
-**NOTE:**  To achieve a faster upscale use a fast preset like **veryfast** or **superfast** however these will give a poorer compression but will complete the upscaling faster. +
- +
-  * Using a CRF of 25 will also lower the output quality slightly (less bitrate = less size). +
-  * Slower encoding means more quality is kept and the compression is superior. +
- +
-</WRAP> +
- +
----- +
- +
-===== Downscaling Video ===== +
- +
-<code bash> +
-ffmpeg -i input.mp4 -vf scale=640x480:flags=lanczos -c:v libx264 -preset slow -crf 21 output_compress_480p.mp4 +
-</code> +
- +
----- +
- +
-===== Downscale or Downsize ===== +
- +
-<code bash> +
-ffmpeg -i input.mp4 -vf scale=1920:1080 -c:v libx264 smaller.mp4 +
-</code>+
  
 ---- ----
ffmpeg/video/resize.1736723228.txt.gz · Last modified: 2025/01/12 23:07 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki