ffmpeg-scaler
Scale video resolution
SYNOPSIS
ffmpeg-scaler -i input_file [options] output_file
Example: ffmpeg-scaler -i input.mp4 -vf scale=1280:-1 output_720p.mp4
PARAMETERS
-i input_file
Specifies the path to the input video file.
output_file
Specifies the path for the output video file. This is typically the last argument.
-vf "scale=WIDTH:HEIGHT"
Applies the video filtergraph for scaling. Use '-1' for WIDTH or HEIGHT to automatically calculate the other dimension while maintaining aspect ratio (e.g., 'scale=1280:-1' for 720p width). Multiple filters can be chained with commas.
-s WIDTHxHEIGHT
A shorthand for setting output resolution. Less flexible than -vf scale, as it only sets resolution and doesn't explicitly handle aspect ratio or padding.
-aspect ratio
Sets the output display aspect ratio (e.g., '16:9', '4:3', '1.777').
-c:v codec
Specifies the video codec for the output (e.g., 'libx264' for H.264, 'libvpx-vp9' for VP9). Re-encoding is often required for scaling.
-preset speed
Sets an encoding preset for codecs like libx264, affecting compression speed and quality (e.g., 'veryfast', 'medium', 'slow'). Faster presets result in larger files or lower quality.
-crf quality_factor
Constant Rate Factor for H.264/HEVC encoding. Lower values mean higher quality and larger files (e.g., '23' is a good balance, '18' is near lossless).
-an
Disables audio processing, removing the audio stream from the output.
-map 0:a
Copies the audio stream from the first input without re-encoding, preserving audio quality.
-ss position
Starts processing the input at a specified timestamp (e.g., '00:01:30' or '90' seconds).
-to position
Stops processing the input at a specified timestamp (e.g., '00:05:00').
DESCRIPTION
The ffmpeg-scaler command conceptually represents the process of resizing and scaling video streams using the powerful FFmpeg multimedia framework. While not a standalone binary, it abstracts the common use case of modifying video dimensions, aspect ratios, and pixel formats. This operation is crucial for adapting video content to different display devices, reducing file sizes, or preparing media for specific platforms (e.g., social media, web streaming).
FFmpeg offers a highly flexible video filter system, primarily the scale filter, which allows users to specify target resolutions, maintain aspect ratios, or even crop and pad simultaneously. It supports various scaling algorithms, influencing output quality and processing speed. This conceptual command emphasizes ease of use for a complex task, enabling users to achieve precise control over their video output's visual properties.
CAVEATS
Scaling operations can be CPU-intensive, especially for high resolutions or complex filter chains, impacting processing time. The quality of scaling depends on the chosen algorithm and the output codec settings. Incorrect aspect ratio handling can lead to distorted video. Always test outputs on different devices or players to ensure compatibility and visual fidelity.
Chaining multiple filters within -vf requires careful ordering, as the sequence of operations matters significantly.
SCALING ALGORITHMS
The scale filter supports various algorithms, such as bicubic (default, good balance), bilinear (faster, lower quality), lanczos (higher quality, slower), and nearest (fastest, pixelated). Choosing the right algorithm impacts processing time and visual quality. You can specify it as part of the filter, for example: -vf "scale=1280:-1:flags=lanczos".
ASPECT RATIO AND PADDING
When scaling, maintaining the original aspect ratio is crucial. Using -1 for one dimension in the scale filter automatically calculates the other. If you need to fit video into a specific resolution while maintaining its aspect ratio, you can use the pad filter in conjunction with scale to add black bars (letterboxing/pillarboxing). For instance, to scale to 1280x720 while maintaining aspect ratio and padding if necessary: -vf "scale='min(1280,iw)':min(720,ih), pad=1280:720:(ow-iw)/2:(oh-ih)/2".
HISTORY
FFmpeg, the underlying engine for scaling operations, has a rich history dating back to 2000. It began as a command-line tool for converting video and audio formats and has grown into a comprehensive, open-source multimedia framework. The scale video filter, a core component, has been continuously refined over releases, adding more algorithms and features. Its widespread adoption across various industries, from broadcast to web streaming, highlights its robust and flexible capabilities in video manipulation, including scaling.