Overview
ffmpeg is a powerful command-line tool for converting, processing, and streaming multimedia content. It serves as the main workhorse of the FFmpeg project, capable of transcoding between virtually any audio and video format.
ffmpeg is described as a “Universal media converter” and can handle complex filtering, format conversion, and stream manipulation tasks.
Basic Syntax
Common Global Options
Overwrite output files without asking
Never overwrite output files
Force container format (auto-detected otherwise)Example:
-f mp4Select encoder/decoder. Use
copy to copy stream without reencodingVariants:-c:v- Video codec-c:a- Audio codec-c:s- Subtitle codec-c:d- Data codec
Alias for
-c optionInput/Output Options
Time-Related Options
Stop transcoding after specified durationExample:
-t 30 (30 seconds), -t 00:05:00 (5 minutes)Stop transcoding at specified timeExample:
-to 00:10:00Start transcoding at specified time (seek)Example:
-ss 00:01:30Set start time offset relative to end of file
Stream Mapping
Set input stream mappingFormat:
[-]input_file_id[:stream_specifier][?]Examples:-map 0- Map all streams from first input-map 0:v:0- Map first video stream from first input-map 0:a- Map all audio streams from first input-map -0:a:1- Exclude second audio stream
Set metadata information of output file from input fileFormat:
outfile[,metadata]:infile[,metadata]Set chapters mapping from specific input file
Video Options
Override input framerate or convert to given output framerateExample:
-r 30 (30 fps), -r 24000/1001 (23.976 fps)Set frame size (WxH or abbreviation)Examples:
-s 1920x1080, -s hd720Set aspect ratioExamples:
-aspect 16:9, -aspect 1.7777Set pixel formatExample:
-pix_fmt yuv420pDisable video recording
Alias for
-c:v (select video codec)Examples: -vcodec libx264, -vcodec copyApply video filtersExample:
-vf "scale=1280:720,fps=30"Set video bitrateExample:
-b:v 2M (2 Mbps)Use fixed quality scale for video (VBR)Range: 0-31 (lower is better quality)
Audio Options
Disable audio recording
Alias for
-c:a (select audio codec)Examples: -acodec aac, -acodec libmp3lameApply audio filtersExample:
-af "volume=0.5,aresample=48000"Set audio sampling rateExample:
-ar 48000 (48 kHz)Set number of audio channelsExample:
-ac 2 (stereo)Set audio bitrateExample:
-b:a 192k (192 kbps)Use fixed quality scale for audio (VBR)
Advanced Options
Filter Graphs
Create a complex filtergraphExample:
Alias for
-filter_complexHardware Acceleration
Use hardware accelerationExamples:
cuda, qsv, vaapi, videotoolboxSelect hardware device for acceleration
Stream Specifiers
Stream specifiers allow you to precisely target specific streams:vorv:0- First video streamaora:0- First audio streamsors:0- First subtitle stream0:v:1- Second video stream from first input0:a:0- First audio stream from first input
Real-World Examples
Basic Format Conversion
Extract Audio from Video
Trim Video
Resize Video
Change Video Bitrate
Combine Audio and Video
Create Thumbnail
Convert to GIF
Add Watermark
Concatenate Videos
Stream Copy (Fast)
Performance Options
Set number of threads for encodingExample:
-threads 4Set encoding preset (speed vs compression trade-off)Values:
ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslowTune encoder for specific content typeExamples:
film, animation, grain, stillimageDebugging Options
Set logging levelValues:
quiet, panic, fatal, error, warning, info, verbose, debug, traceGenerate a report with detailed encoding information
Add timings for benchmarking
Write program-readable progress information to URL
Source Code Reference
The main option parsing logic is implemented in:/home/daytona/workspace/source/fftools/ffmpeg_opt.c:1622- Options array definition/home/daytona/workspace/source/fftools/ffmpeg_opt.c:1424- Usage information
For a complete list of options, run
ffmpeg -h full or visit the official FFmpeg documentation.See Also
- FFplay - Multimedia player
- FFprobe - Media analysis tool
- Additional Tools - Other utilities