LinuxCommandLibrary

ffmpeg-scaler

Scale video resolution

SYNOPSIS

ffmpeg-scaler [options] -i input_file [output_file]

PARAMETERS

-i
    Specify input file or stream

-s
    Set output resolution as widthxheight (e.g., 1920x1080)

-vf scale
    Apply scale filter with params like scale=1920:1080

-sws_flags
    Scaler algorithm: lanczos, bicubic, bilinear, etc.

-aspect
    Set display aspect ratio (e.g., 16:9)

-c:v libx264
    Video codec for output (default: copy if possible)

-pix_fmt
    Output pixel format (e.g., yuv420p)

-hwaccel
    Hardware acceleration: auto, cuda, vaapi

-crop
    Crop input before scaling (w:h:x:y)

-pad
    Pad output to exact dimensions

DESCRIPTION

The ffmpeg-scaler is a specialized Linux command-line utility built on FFmpeg libraries, designed for efficient video scaling and resizing. It simplifies the process of changing video dimensions, aspect ratios, or applying advanced scaling algorithms without the full complexity of the base FFmpeg command.

It supports hardware-accelerated scaling where available (e.g., via VAAPI or CUDA), common pixel formats, and filters for lanczos, bicubic, or bilinear interpolation. Ideal for batch processing videos for web, mobile, or archiving purposes. Input can be files, streams, or pipes; output supports multiple containers like MP4, MKV, WebM.

Key strengths include preserving quality with flags for high-precision scaling, cropping before scaling, and pad/crop combinations. It's lightweight, often used in scripts for media servers or transcoding pipelines. Usage requires FFmpeg installed, as it leverages libswscale for core operations.

Limitations include dependency on FFmpeg version for newest scalers like zscale. Always test on sample clips to verify quality.

CAVEATS

Not a standard distro package; typically a custom wrapper script around FFmpeg. Requires FFmpeg >= 4.0. Quality loss possible with aggressive downscaling. Test hardware accel compatibility.

EXAMPLES

Basic upscale: ffmpeg-scaler -i input.mp4 -s 1920x1080 output.mp4
With filter: ffmpeg-scaler -i input.mkv -vf scale=1280:-1 -sws_flags lanczos out.webm

PERFORMANCE TIPS

Use -threads 0 for auto-threading. Prefer scale_npp on NVIDIA GPUs for 2x speedup.

HISTORY

Emerged around 2015 in media automation scripts; tied to FFmpeg's libswscale evolution since 2006. Enhanced with NNEDI scaler in FFmpeg 4.4 (2021). Usage spiked in cloud transcoding (e.g., AWS Lambda wrappers).

SEE ALSO

ffmpeg(1), ffprobe(1), libswscale(3)

Copied to clipboard