LinuxCommandLibrary

ffmpeg

TLDR

Convert video format

$ ffmpeg -i [input.mp4] [output.avi]
copy
Extract audio from video
$ ffmpeg -i [video.mp4] -vn [audio.mp3]
copy
Resize video
$ ffmpeg -i [input.mp4] -vf scale=[1280]:[720] [output.mp4]
copy
Compress video
$ ffmpeg -i [input.mp4] -crf [23] [output.mp4]
copy
Create GIF from video
$ ffmpeg -i [input.mp4] -vf "fps=10,scale=320:-1" [output.gif]
copy

SYNOPSIS

ffmpeg [global-options] [input-options] -i input [output-options] output

DESCRIPTION

ffmpeg is the swiss army knife of multimedia processing. It converts, records, streams, and processes audio and video in virtually any format through an extensive codec library.
The tool uses a powerful filter system for transformations like scaling, cropping, color correction, and effects. It handles everything from simple format conversion to complex streaming setups.
ffmpeg forms the foundation of many video applications and is the de facto standard for command-line multimedia processing.

PARAMETERS

-i FILE

Input file.
-c:v CODEC
Video codec (libx264, libx265, copy).
-c:a CODEC
Audio codec (aac, mp3, copy).
-crf N
Quality (0-51, lower is better).
-vf FILTER
Video filter (scale, crop, fps).
-af FILTER
Audio filter.
-ss TIME
Start time.
-t DURATION
Duration.
-y
Overwrite output without asking.
--help
Display help information.

CAVEATS

Complex syntax requires learning. Quality vs size tradeoffs vary by content. Some codecs have licensing considerations. Processing is CPU-intensive.

HISTORY

ffmpeg was started by Fabrice Bellard in 2000 and has become the most widely-used multimedia framework. It powers countless applications from VLC to YouTube's video processing pipeline.

SEE ALSO

ffprobe(1), ffplay(1), avconv(1)

Copied to clipboard