
Ffmpeg Command Syntax
- 53 installs
- 50 repo stars
- Updated June 18, 2026
- josiahsiegel/claude-plugin-marketplace
Helps with ai & agent building tasks.
About
ffmpeg-command-syntax is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- ffmpeg-command-syntax
- AI & Agent Building
- AI-coding skill
Ffmpeg Command Syntax by the numbers
- 53 all-time installs (skills.sh)
- +4 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #6,979 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill ffmpeg-command-syntaxAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 53 |
|---|---|
| repo stars | ★ 50 |
| Last updated | June 18, 2026 |
| Repository | josiahsiegel/claude-plugin-marketplace ↗ |
What it does
Helps with ai & agent building tasks.
Files
CRITICAL: FFmpeg Option Ordering Rules
The most common FFmpeg mistake is putting options in the wrong place. Options in FFmpeg are position-sensitive and apply to the NEXT file specified after them.
The Golden Rule
ffmpeg [global_options] {[input_options] -i input}... {[output_options] output}...Key principle: Options are applied to the next file. They are reset between files.
---
Option Categories at a Glance
| Category | Where it goes | Notable members |
|---|---|---|
| Global | First, before any -i | -y, -n, -v, -hide_banner, -filter_complex, -init_hw_device |
| Input | Between previous output (or start) and the next -i | -ss, -t, -to, -re, -stream_loop, -hwaccel, -itsoffset |
| Output | After all -i, before the matching output file | -c:v, -c:a, -crf, -preset, -vf, -af, -map, -movflags |
The full per-category catalog (every option, with descriptions) lives in `references/complete-option-reference.md`.
Global Options (Quick Subset)
ffmpeg -y -hide_banner -v warning -i input.mp4 output.mp4Common global flags: -y, -n, -v/-loglevel, -stats, -progress, -report, -hide_banner, -filter_complex, -filter_complex_threads, -init_hw_device, -filter_hw_device.
Input Options (Quick Subset)
Placed immediately before the -i they apply to. They affect how the file is read/decoded.
Most-used: -ss, -t, -to, -itsoffset, -itsscale, -re, -readrate, -stream_loop, -hwaccel, -hwaccel_device, -hwaccel_output_format, -c:v/-c:a (as decoder), -r/-s/-pix_fmt (raw inputs), -accurate_seek, -thread_queue_size.
# Correct: Input options before their -i
ffmpeg -ss 00:01:00 -t 30 -i input.mp4 output.mp4
# Wrong: -ss after -i becomes an OUTPUT (slow) seek
ffmpeg -i input.mp4 -ss 00:01:00 output.mp4Hardware acceleration must always go before -i:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
-c:v h264_nvenc output.mp4Output Options (Quick Subset)
Placed after all inputs and before the output file they apply to. They affect how the file is encoded/written.
Most-used: -c:v/-c:a/-c:s (as encoder), -b:v/-b:a, -crf, -qp, -preset, -tune, -profile:v, -level, -r/-s/-aspect/-pix_fmt, -vf/-af, -map, -ss/-t/-to (output forms), -fs, -frames:v/-frames:a, -movflags, -metadata, -disposition, -shortest, -an/-vn/-sn.
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium output.mp4---
Options That Switch Behavior by Position
Some options have completely different meanings depending on whether they appear before or after -i.
-ss (Seek/Start Time) - Position Critical
# BEFORE -i (INPUT): Fast keyframe seek, then decode to exact position with -accurate_seek (default)
ffmpeg -ss 00:01:00 -i input.mp4 -t 30 -c copy output.mp4
# AFTER -i (OUTPUT): Frame-accurate but slow - decodes everything, discards until target
ffmpeg -i input.mp4 -ss 00:01:00 -t 30 -c:v libx264 output.mp4
# BOTH (recommended): coarse seek + fine seek
ffmpeg -ss 00:00:55 -i input.mp4 -ss 00:00:05 -t 30 -c:v libx264 output.mp4Note: -ss before -i resets timestamps to 0. Use -copyts to preserve originals.
-t and -to
# -t BEFORE -i: limits how much of input to READ
ffmpeg -t 60 -i input.mp4 -c copy output.mp4
# -t AFTER -i: limits output DURATION
ffmpeg -i input.mp4 -t 60 -c copy output.mp4
# -ss + -to: with timestamp reset, -to is relative to new zero
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:00:30 output.mp4 # 30s clip
ffmpeg -ss 00:01:00 -copyts -i input.mp4 -to 00:01:30 output.mp4 # also 30s clip-r (Frame Rate)
# BEFORE -i: input frame rate (raw/image sequences)
ffmpeg -r 30 -i frame_%04d.png output.mp4
# AFTER -i: output frame rate (adds/drops frames)
ffmpeg -i input.mp4 -r 24 output.mp4-s (Size)
# BEFORE -i: raw input size
ffmpeg -s 1920x1080 -pix_fmt yuv420p -i raw.yuv output.mp4
# AFTER -i: scales output (prefer -vf scale instead)
ffmpeg -i input.mp4 -s 1280x720 output.mp4-c / -codec
# BEFORE -i: DECODER selection
ffmpeg -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc output.mp4
# AFTER -i: ENCODER selection (common case)
ffmpeg -i input.mp4 -c:v libx264 -c:a aac output.mp4---
Stream Specifiers (Quick Form)
Target specific streams with -option[:specifier]:
ffmpeg -i input.mkv -c:v libx264 -c:a aac -c:s mov_text output.mp4
ffmpeg -i a.mp4 -i b.mp4 -map 1:0 -c copy output.mp4Common specifiers: :v, :V, :a, :s, :d, :t, :v:0, :a:1, :0, :m:key:value, :p:0. Full table and per-stream examples in `references/stream-specifiers.md`.
---
Multiple Inputs and Outputs
# Per-input options
ffmpeg \
-ss 10 -i first.mp4 \
-ss 5 -i second.mp4 \
-filter_complex "[0:v][1:v]overlay" output.mp4
# Per-output options (they RESET between outputs)
ffmpeg -i input.mp4 \
-c:v libx264 -crf 23 output_h264.mp4 \
-c:v libx265 -crf 28 output_h265.mp4# WRONG: second output silently gets no encoding options
ffmpeg -i input.mp4 -c:v libx264 -crf 23 out1.mp4 out2.mp4---
Common Mistakes and Fixes
1. Input option after -i
# WRONG: -hwaccel after -i has no effect
ffmpeg -i input.mp4 -hwaccel cuda -c:v h264_nvenc output.mp4
# CORRECT
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp42. Output option before -i
# WRONG: -c:v before -i tries to choose a decoder
ffmpeg -c:v libx264 -i input.mp4 output.mp4
# CORRECT
ffmpeg -i input.mp4 -c:v libx264 output.mp43. Expecting options to persist across outputs
# WRONG
ffmpeg -i input.mp4 -c:v libx264 -crf 23 out1.mp4 out2.mp4
# CORRECT
ffmpeg -i input.mp4 \
-c:v libx264 -crf 23 out1.mp4 \
-c:v libx264 -crf 23 out2.mp44. Wrong -ss position for accuracy
# Fast but may snap to keyframe
ffmpeg -ss 00:05:00 -i input.mp4 -t 30 -c copy output.mp4
# Accurate but slow
ffmpeg -i input.mp4 -ss 00:05:00 -t 30 -c:v libx264 output.mp4
# Fast AND accurate
ffmpeg -ss 00:04:55 -i input.mp4 -ss 5 -t 30 -c:v libx264 output.mp45. Mixing inputs and outputs
# WRONG
ffmpeg -i input1.mp4 -c:v libx264 output1.mp4 -i input2.mp4 output2.mp4
# CORRECT
ffmpeg -i input1.mp4 -i input2.mp4 \
-map 0 -c:v libx264 output1.mp4 \
-map 1 -c:v libx264 output2.mp46. -t vs -to with -ss timestamp reset
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:00:30 output.mp4 # 30s clip
ffmpeg -ss 00:01:00 -copyts -i input.mp4 -to 00:01:30 output.mp4 # 30s clip
ffmpeg -ss 00:01:00 -i input.mp4 -t 00:00:30 output.mp4 # 30s clip7. -vf vs -filter_complex
# Single-input filter (per-output)
ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4
# Multi-input filter (global)
ffmpeg -i video.mp4 -i overlay.png \
-filter_complex "[0:v][1:v]overlay=10:10" output.mp4
# WRONG: -vf cannot reference multiple inputs
ffmpeg -i video.mp4 -i overlay.png -vf "overlay=10:10" output.mp4---
Command Structure Examples
# Basic transcode
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4
# With input seeking
ffmpeg -ss 60 -i input.mp4 -t 30 -c:v libx264 output.mp4
# Hardware acceleration
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
-c:v h264_nvenc -preset p4 output.mp4
# Multiple inputs with filters
ffmpeg -i main.mp4 -i overlay.png \
-filter_complex "[0:v][1:v]overlay=10:10[v]" \
-map "[v]" -map 0:a -c:v libx264 -c:a copy output.mp4
# Real-time streaming
ffmpeg -re -i input.mp4 -c:v libx264 -f flv rtmp://server/live/stream
# Full structure
ffmpeg \
-y -hide_banner \
-hwaccel cuda -ss 10 -i input1.mp4 \
-stream_loop -1 -i input2.mp4 \
-filter_complex "[0:v][1:v]overlay[v]" \
-map "[v]" -map 0:a \
-c:v h264_nvenc -b:v 5M \
-c:a aac -b:a 192k \
-movflags +faststart \
output.mp4---
Quick Placement Cheatsheet
| Option | Before -i | After -i | Notes |
|---|---|---|---|
-ss | Fast seek | Accurate seek | Before = keyframe, After = decode |
-t | Input limit | Output limit | Read vs write |
-to | Input end | Output end | Affected by timestamp reset |
-r | Input FPS | Output FPS | Raw / output conversion |
-s | Input size | Output size | Raw / scaling |
-c:v/-c:a | Decoder | Encoder | Before = decode |
-hwaccel, -re, -itsoffset, -stream_loop | Required | N/A | Input only |
-vf, -af, -map, -crf, -preset, -movflags | N/A | Required | Output only |
-y, -v, -filter_complex | Global | Global | Place first |
---
Extended Reference Map
For exhaustive lookups, see the companion reference files:
- Complete option catalog (all global / input / output / color / threading / format flag tables): `references/complete-option-reference.md`
- Stream specifier syntax and examples: `references/stream-specifiers.md`
- Per-backend hardware device initialization (CUDA, VAAPI, QSV, Vulkan, D3D11VA, VideoToolbox): `references/hardware-device-init.md`
- Format/protocol/muxer options (HLS, DASH, segment, RTSP, RTMP, raw video, movflags, MPEG-TS, Matroska): `references/format-specific-options.md`
- Timestamps, bitstream filters, metadata, attachments, disposition: `references/timestamps-bitstream-metadata.md`
---
External References
Complete FFmpeg 8.0+ Option Reference
Exhaustive option catalogs grouped by category. Use this for lookup; for the placement rules and common mistakes see the parent SKILL.md.
Global Options (Complete List)
| Option | Description |
|---|---|
-y | Overwrite output files without asking |
-n | Never overwrite output files |
-v level / -loglevel level | Set logging verbosity (quiet, panic, fatal, error, warning, info, verbose, debug, trace) |
-stats | Print encoding progress statistics |
-stats_period time | Set statistics output period |
-progress url | Send progress info to URL/file |
-stdin | Enable stdin interaction |
-nostdin | Disable stdin interaction |
-report | Generate ffmpeg-*.log debug file |
-hide_banner | Suppress program banner |
-max_alloc bytes | Maximum allocation size limit |
-cpuflags flags | Set CPU flags mask |
-cpucount count | Override CPU count detection |
-max_error_rate ratio | Maximum decoding error ratio |
-xerror | Exit on error |
-abort_on flags | Conditions to abort (empty_output, empty_output_stream) |
-filter_complex graph | Global complex filtergraph |
-filter_complex_threads n | Filtergraph thread count |
-filter_threads n | Set filter processing threads |
-filter_buffered_frames n | Max buffered frames in filtergraph |
-lavfi graph | Alias for -filter_complex |
-filter_complex_script file | Read filtergraph from file |
-sdp_file file | Write SDP info to file |
-init_hw_device type=name | Initialize hardware device |
-filter_hw_device name | Hardware device for filters |
-hwaccels | List available hardware accelerations |
-benchmark | Show benchmarking info |
-benchmark_all | Show per-step benchmarking |
-timelimit duration | Exit after duration seconds |
-dump | Dump each input packet |
-hex | Dump packets in hex |
-debug_ts | Print timestamp/latency debugging info |
-recast_media | Force decoder of different media type |
-vsync mode | Video sync method (deprecated, use -fps_mode) |
-fps_mode mode | Frame rate mode (passthrough, cfr, vfr, auto) |
-frame_drop_threshold threshold | Frame drop threshold |
-async samples_per_second | Audio sync method |
-adrift_threshold threshold | Audio drift threshold |
-copyts | Copy timestamps from input |
-start_at_zero | Shift input timestamps to start at 0 |
-copytb mode | Copy input timebase (0=decoder, 1=demuxer, -1=auto) |
-dts_delta_threshold threshold | DTS discontinuity threshold |
-dts_error_threshold threshold | DTS error timestamp threshold |
-muxdelay seconds | Maximum mux delay |
-muxpreload seconds | Initial mux delay |
-streamid output_index:new_id | Set stream ID in output |
-override_ffserver | Override ffserver input specifications |
-bitexact | Use only bit-exact algorithms |
-default_mode mode | Default stream selection mode |
-vstats | Dump video coding stats to vstats_HHMMSS.log |
-vstats_file file | Dump video coding stats to specified file |
-vstats_version n | Set vstats format version |
-print_graphs | Print execution graph to stderr |
-print_graphs_file file | Write execution graph to file |
-print_graphs_format fmt | Set graph output format (default, compact, json, mermaid) |
Input-Only Options (Complete List)
| Option | Description |
|---|---|
-i url | Input file URL |
-f fmt | Force input format |
-c:v decoder / -vcodec decoder | Video decoder |
-c:a decoder / -acodec decoder | Audio decoder |
-c:s decoder / -scodec decoder | Subtitle decoder |
-ss position | Seek to position (fast, keyframe-based) |
-sseof position | Seek relative to end of file (negative value) |
-t duration | Limit input duration |
-to position | Limit input to position |
-itsoffset offset | Input timestamp offset |
-itsscale scale | Input timestamp scale (per-stream) |
-isync input_index | Assign input as sync source |
-re | Read at native frame rate |
-readrate speed | Read at specified rate |
-readrate_initial_burst duration | Initial burst before rate limiting |
-readrate_catchup speed | Catchup rate when behind |
-stream_loop count | Loop input (-1 = infinite) |
-hwaccel method | Hardware acceleration (none, auto, cuda, vaapi, qsv, d3d11va, dxva2, videotoolbox, vdpau, vulkan) |
-hwaccel_device device | Hardware device path/name |
-hwaccel_output_format format | Hardware output pixel format |
-autorotate | Automatically rotate video (enabled by default) |
-noautorotate | Disable automatic rotation |
-r fps | Input frame rate (raw formats) |
-s size | Input frame size (raw formats) |
-pix_fmt format | Input pixel format (raw formats) |
-sample_fmt format | Input sample format (raw audio) |
-ar rate | Input audio sample rate |
-ac channels | Input audio channel count |
-channel_layout layout | Input audio channel layout |
-accurate_seek | Enable accurate seeking (default) |
-noaccurate_seek | Disable accurate seeking |
-seek_timestamp | Enable seeking by timestamp |
-thread_queue_size count | Input thread queue size |
-guess_layout_max channels | Max channels for layout guessing |
-discard mode | Discard frames (none, default, noref, bidir, nokey, all) |
-reinit_filter | Reinitialize filters on input change (per-stream) |
-drop_changed | Drop frames with changed parameters (per-stream) |
-display_rotation degrees | Set display rotation metadata |
-display_hflip | Set horizontal flip metadata |
-display_vflip | Set vertical flip metadata |
-fix_sub_duration | Fix subtitle durations |
-canvas_size size | Subtitle canvas size |
-ignore_loop | Ignore loop metadata (GIF) |
-dump_attachment:stream filename | Extract attachment to file (per-stream) |
Output-Only Options (Complete List)
| Option | Description |
|---|---|
-f fmt | Force output format |
-c:v encoder / -vcodec encoder | Video encoder (or copy) |
-c:a encoder / -acodec encoder | Audio encoder (or copy) |
-c:s encoder / -scodec encoder | Subtitle encoder (or copy) |
-c:d codec / -dcodec codec | Data stream codec |
-ss position | Start time (accurate, slow) |
-t duration | Output duration limit |
-to position | Output end position |
-fs size | File size limit (bytes) |
-frames:v count / -vframes count | Video frame count limit |
-frames:a count / -aframes count | Audio frame count limit |
-frames:d count / -dframes count | Data frame count limit |
-r fps | Output frame rate |
-fpsmax fps | Maximum output frame rate |
-s size | Output frame size |
-aspect ratio | Display aspect ratio |
-pix_fmt format | Output pixel format |
-sample_fmt format | Output sample format |
-ar rate | Output audio sample rate |
-ac channels | Output audio channel count |
-channel_layout layout | Output audio channel layout |
-vf filtergraph / -filter:v | Video filter chain |
-af filtergraph / -filter:a | Audio filter chain |
-map input:stream | Stream mapping |
-map_metadata specifier | Metadata mapping |
-map_chapters input_index | Chapter mapping from input |
-b:v bitrate | Video bitrate |
-b:a bitrate | Audio bitrate |
-maxrate bitrate | Maximum bitrate |
-minrate bitrate | Minimum bitrate |
-bufsize size | Rate control buffer size |
-crf value | Constant Rate Factor (quality) |
-qp value | Constant QP value |
-q:v value / -qscale:v value | Video quality scale (VBR) |
-q:a value / -qscale:a value | Audio quality scale (VBR) |
-preset name | Encoder preset |
-tune name | Encoder tuning |
-profile:v name | Video profile |
-level value | Codec level |
-g frames | GOP size / keyframe interval |
-keyint_min frames | Minimum keyframe interval |
-sc_threshold value | Scene change threshold |
-bf frames | B-frame count |
-refs frames | Reference frames |
-pass n | Multi-pass encoding (1 or 2) |
-passlogfile prefix | Pass log file prefix |
-rc_lookahead frames | Rate control lookahead |
-an | Disable audio output |
-vn | Disable video output |
-sn | Disable subtitle output |
-dn | Disable data stream output |
-metadata key=value | Set global metadata |
-metadata:s:v key=value | Set video stream metadata |
-metadata:s:a key=value | Set audio stream metadata |
-metadata:c:0 key=value | Set chapter metadata |
-disposition:s:0 flags | Set stream disposition |
-program title=name:st=0:st=1 | Create program in output |
-stream_group type=value:... | Create stream group |
-target type | Target format (vcd, svcd, dvd, dv, dv50) |
-shortest | Stop at shortest stream |
-shortest_buf_duration duration | Buffer for shortest detection |
-apad | Pad audio to match video (use with -shortest) |
-copypriorss n | Copy frames before start time (0=no, 1=yes, -1=auto) |
-avoid_negative_ts mode | Handle negative timestamps (make_non_negative, make_zero, auto, disabled) |
-timestamp date | Set recording timestamp |
-movflags flags | MOV/MP4 flags (+faststart, +frag_keyframe, etc.) |
-fflags flags | Format flags (+genpts, +igndts, +discardcorrupt, etc.) |
-bsf:v filter | Video bitstream filter |
-bsf:a filter | Audio bitstream filter |
-tag:v fourcc / -vtag fourcc | Video tag/fourcc |
-tag:a fourcc / -atag fourcc | Audio tag/fourcc |
-timecode hh:mm:ss:ff | Set initial timecode |
-force_key_frames expr | Force keyframe positions |
-copyinkf | Copy initial non-keyframes (stream copy) |
-init_hw_device type=name | Initialize hw device for output |
-enc_time_base mode | Encoder timebase (demux, filter, auto) |
-attach filename | Add attachment (fonts, images) |
-pre preset_name | Use preset file (per-stream) |
-fpre preset_file | Use preset file (per-file) |
-max_muxing_queue_size packets | Muxing queue size |
-muxing_queue_data_threshold bytes | Queue data threshold |
-dcodec codec | Data stream codec (alias for -c:d) |
-intra | Use only intra frames (deprecated, use -g 1) |
-vol volume | Audio volume (256=normal, deprecated, use -af volume) |
-autoscale | Auto-scale video (enabled by default) |
-noautoscale | Disable auto-scaling |
-autorotate | Auto-rotate video on output (enabled by default) |
-noautorotate | Disable auto-rotation on output |
Video Color/HDR Options (Output)
| Option | Description |
|---|---|
-color_range range | Color range (tv/pc, limited/full, mpeg/jpeg) |
-color_primaries primaries | Color primaries (bt709, bt2020, smpte170m, etc.) |
-color_trc trc | Transfer characteristics (bt709, smpte2084/pq, arib-std-b67/hlg, etc.) |
-colorspace space | Colorspace (bt709, bt2020nc, smpte170m, etc.) |
-chroma_sample_location loc | Chroma sample location |
-top n | Top field first (1) or bottom field first (0) |
-bits_per_raw_sample n | Bits per raw sample |
-dc precision | Intra DC precision |
-qphist | Show QP histogram |
Subtitle Options
| Option | Description | Type |
|---|---|---|
-sn | Disable subtitles | Input/Output |
-scodec codec | Subtitle codec | Input/Output |
-stag fourcc | Subtitle tag/fourcc | Output |
-fix_sub_duration | Fix subtitle durations | Input |
-canvas_size size | Subtitle canvas size | Input |
FFmpeg 8.0+ Specific Options
| Option | Description | Type |
|---|---|---|
-vaapi_device path | VAAPI device path | Input/Global |
-qsv_device path | Intel QSV device | Input/Global |
-vulkan_device device | Vulkan device selection | Input/Global |
-fps_mode mode | Frame rate mode (replaces -vsync) | Output |
-enc_stats_pre file | Pre-encoding stats output | Output |
-enc_stats_post file | Post-encoding stats output | Output |
-enc_stats_pre_fmt fmt | Pre-encoding stats format | Output |
-enc_stats_post_fmt fmt | Post-encoding stats format | Output |
-autoscale | Auto-scale to encoder (default) | Output |
-noautoscale | Disable auto-scaling | Output |
-bits_per_raw_sample n | Set bits per raw sample | Output |
Threading Options
| Option | Description | Type |
|---|---|---|
-threads n | Encoding/decoding threads (0=auto) | Per-stream/Output |
-thread_type type | Thread type (frame, slice) | Per-stream |
-filter_threads n | Filter processing threads | Global |
-filter_complex_threads n | Complex filtergraph threads | Global |
# Auto-detect threads for encoding
ffmpeg -i input.mp4 -c:v libx264 -threads 0 output.mp4
# Specific thread count
ffmpeg -i input.mp4 -c:v libx264 -threads 8 output.mp4
# Per-stream threading
ffmpeg -i input.mp4 -threads:v 8 -threads:a 2 -c:v libx264 -c:a aac output.mp4
# Filter threads
ffmpeg -filter_threads 4 -i input.mp4 -vf "scale=1920:1080" output.mp4Format Flags (-fflags)
| Flag | Description |
|---|---|
+genpts | Generate PTS if missing |
+igndts | Ignore DTS (use PTS only) |
+ignidx | Ignore index |
+discardcorrupt | Discard corrupted frames |
+sortdts | Sort packets by DTS |
+fastseek | Enable fast seeking |
+nobuffer | Disable buffering |
+flush_packets | Flush packets immediately |
+bitexact | Bit-exact output |
+shortest | Stop at shortest stream |
+autobsf | Auto-insert bitstream filters |
Format/Protocol/Muxer Options
These options belong to specific muxers/demuxers/protocols, not the main FFmpeg options. They are passed using -option value syntax but only work with their specific format. Unlike main options, they are not position-sensitive in the same way and only apply when the matching format is selected.
HLS Muxer (Output)
ffmpeg -i input.mp4 -c copy \
-hls_time 10 \
-hls_list_size 6 \
-hls_segment_filename "seg_%03d.ts" \
-hls_flags delete_segments \
playlist.m3u8Segment Muxer (Output)
ffmpeg -i input.mp4 -c copy \
-f segment \
-segment_time 60 \
-segment_list playlist.txt \
-segment_format mp4 \
output_%03d.mp4DASH Muxer (Output)
ffmpeg -i input.mp4 -c copy \
-f dash \
-seg_duration 4 \
-init_seg_name "init_$RepresentationID$.m4s" \
manifest.mpdRTSP/RTMP Protocol (Input)
ffmpeg -rtsp_transport tcp -i "rtsp://server/stream" output.mp4
ffmpeg -rtmp_buffer 1000 -i "rtmp://server/live/stream" output.mp4Raw Video Input
ffmpeg -f rawvideo -video_size 1920x1080 -pix_fmt yuv420p -framerate 30 \
-i input.yuv output.mp4MP4/MOV Muxer Flags (-movflags)
# Fast start (move moov atom to beginning for web)
ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4
# Fragmented MP4 (for DASH/streaming)
ffmpeg -i input.mp4 -c copy -movflags +frag_keyframe+empty_moov output.mp4
# Separate moov atom
ffmpeg -i input.mp4 -c copy -movflags +frag_keyframe+separate_moof output.mp4
# All common streaming flags
ffmpeg -i input.mp4 -c copy \
-movflags +faststart+frag_keyframe+empty_moov+default_base_moof \
output.mp4| Flag | Description |
|---|---|
faststart | Move moov before mdat (web streaming) |
frag_keyframe | Fragment at each keyframe |
empty_moov | Empty initial moov (DASH) |
separate_moof | Separate moof for each track |
default_base_moof | Base offset at moof (DASH) |
negative_cts_offsets | Allow negative CTS offsets |
isml | IIS Smooth Streaming |
omit_tfhd_offset | Omit offset in tfhd |
disable_chpl | Disable chapter track |
write_colr | Write colr atom |
write_gama | Write gama atom |
MPEG-TS Muxer
# MPEG-TS with PCR
ffmpeg -i input.mp4 -c copy -mpegts_copyts 1 output.ts
# Set service info
ffmpeg -i input.mp4 -c copy \
-mpegts_service_id 1 \
-mpegts_service_type digital_tv \
output.tsMatroska/WebM Muxer
# Cue points at clusters
ffmpeg -i input.mp4 -c:v libvpx-vp9 -cues_to_front 1 output.webm
# Set cluster size
ffmpeg -i input.mp4 -c copy -cluster_size_limit 2M output.mkvHardware Acceleration Device Initialization
Per-backend syntax for -hwaccel, -init_hw_device, and -filter_hw_device. For an in-depth comparison of GPU pipelines, see the ffmpeg-hardware-acceleration skill.
CUDA (NVIDIA)
# Basic CUDA
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp4
# Specify device
ffmpeg -hwaccel cuda -hwaccel_device 0 -i input.mp4 -c:v h264_nvenc output.mp4
# Full GPU pipeline (decode + filter + encode on GPU)
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \
-vf "scale_cuda=1920:1080" -c:v h264_nvenc output.mp4
# Initialize named device for filters
ffmpeg -init_hw_device cuda=gpu0:0 -filter_hw_device gpu0 \
-i input.mp4 -vf "hwupload_cuda,scale_cuda=1920:1080,hwdownload" \
-c:v libx264 output.mp4VAAPI (AMD/Intel Linux)
# Basic VAAPI
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i input.mp4 \
-c:v h264_vaapi output.mp4
# VAAPI with output format
ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi \
-hwaccel_device /dev/dri/renderD128 -i input.mp4 \
-vf "scale_vaapi=1920:1080" -c:v h264_vaapi output.mp4
# Using -vaapi_device shortcut
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 \
-vf "hwupload,scale_vaapi=1920:1080" -c:v h264_vaapi output.mp4QSV (Intel)
# Basic QSV
ffmpeg -hwaccel qsv -i input.mp4 -c:v h264_qsv output.mp4
# QSV with device specification
ffmpeg -qsv_device /dev/dri/renderD128 -hwaccel qsv \
-i input.mp4 -c:v h264_qsv output.mp4
# Full QSV pipeline
ffmpeg -hwaccel qsv -hwaccel_output_format qsv -i input.mp4 \
-vf "scale_qsv=1920:1080" -c:v h264_qsv output.mp4Vulkan (Cross-platform FFmpeg 7.1+/8.0+)
# Vulkan hardware acceleration
ffmpeg -init_hw_device vulkan=vk:0 -filter_hw_device vk \
-i input.mp4 -vf "hwupload,scale_vulkan=1920:1080,hwdownload" \
-c:v libx264 output.mp4
# Vulkan encoder (FFmpeg 8.0+)
ffmpeg -hwaccel vulkan -hwaccel_output_format vulkan -i input.mp4 \
-c:v h264_vulkan output.mp4D3D11VA (Windows)
# D3D11 hardware acceleration
ffmpeg -hwaccel d3d11va -i input.mp4 -c:v h264_nvenc output.mp4
# With specific adapter
ffmpeg -hwaccel d3d11va -hwaccel_device 0 -i input.mp4 \
-c:v hevc_amf output.mp4VideoToolbox (macOS)
# VideoToolbox decode + encode
ffmpeg -hwaccel videotoolbox -i input.mp4 \
-c:v h264_videotoolbox output.mp4
# With ProRes
ffmpeg -i input.mov -c:v prores_videotoolbox output.movStream Specifiers
Stream specifiers target specific streams for per-stream options. Appended with a colon after the option name.
Syntax
-option[:stream_specifier] valueStream Specifier Types
| Specifier | Meaning | Example |
|---|---|---|
:v | All video streams | -c:v libx264 |
:V | Video streams (not thumbnails/covers) | -c:V libx264 |
:a | All audio streams | -c:a aac |
:s | All subtitle streams | -c:s mov_text |
:d | All data streams | -c:d copy |
:t | All attachment streams | ... |
:v:0 | First video stream | -b:v:0 5M |
:a:1 | Second audio stream | -c:a:1 ac3 |
:0 | First stream (any type) | -c:0 copy |
:1 | Second stream (any type) | -c:1 libx264 |
:#0x1234 | Stream with specific PID | -c:#0x1234 copy |
:i:0x100 | Stream with specific ID | -c:i:0x100 copy |
:m:key:value | Stream with matching metadata | -c:m:language:eng aac |
:p:0 | Streams in program 0 | -c:p:0 copy |
:u | Usable configuration streams | -c:u copy |
Input Index Prefix
For multi-input commands, prefix with input index:
# Stream 0 from input 1
ffmpeg -i a.mp4 -i b.mp4 -map 1:0 -c copy output.mp4
# Video from input 0, audio from input 1
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a output.mp4
# Second audio stream from third input
ffmpeg -i a.mp4 -i b.mp4 -i c.mp4 -map 2:a:1 output.mp4Per-Stream Option Examples
# Different codecs per stream type
ffmpeg -i input.mkv -c:v libx264 -c:a aac -c:s mov_text output.mp4
# Different bitrates per stream index
ffmpeg -i input.mkv -map 0 \
-c:v libx264 -b:v:0 5M \
-c:a:0 aac -b:a:0 192k \
-c:a:1 ac3 -b:a:1 384k \
output.mkv
# Different settings for each audio stream
ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 \
-c:a:0 ac3 -b:a:0 640k \
-ac:a:1 2 -c:a:1 aac -b:a:1 128k \
output.mp4Timestamps, Bitstream Filters, Metadata, Attachments, Disposition
Reference for advanced packet-level and container-level options.
Advanced Timestamp Handling
# Copy timestamps exactly from input
ffmpeg -copyts -i input.mp4 -c copy output.mp4
# Shift timestamps to start at zero
ffmpeg -start_at_zero -i input.mp4 -c copy output.mp4
# Both: copy but start at zero
ffmpeg -copyts -start_at_zero -i input.mp4 -c copy output.mp4
# Offset input timestamps
ffmpeg -itsoffset 5 -i input.mp4 -c copy output.mp4 # Delay by 5 seconds
# Scale input timestamps (2x speed)
ffmpeg -itsscale 0.5 -i input.mp4 -c copy output.mp4
# Handle negative timestamps
ffmpeg -i input.mp4 -avoid_negative_ts make_zero output.mp4Timestamp Modes
| Mode | Description |
|---|---|
make_non_negative | Shift timestamps to be non-negative |
make_zero | Shift to start at exactly zero |
auto | Auto-select based on format |
disabled | Don't adjust timestamps |
Bitstream Filters (-bsf)
# Extract AnnexB NAL units for H.264
ffmpeg -i input.mp4 -c:v copy -bsf:v h264_mp4toannexb output.h264
# Add SEI recovery point for broadcast
ffmpeg -i input.mp4 -c:v copy -bsf:v h264_redundant_pps output.mp4
# HEVC HVC1 to HEV1
ffmpeg -i input.mp4 -c:v copy -bsf:v hevc_mp4toannexb output.hevc
# Insert ADTS headers for AAC
ffmpeg -i input.mp4 -c:a copy -bsf:a aac_adtstoasc output.aac
# Remove filler data
ffmpeg -i input.mp4 -c:v copy -bsf:v filter_units=remove_types=6 output.mp4
# Metadata injection
ffmpeg -i input.mp4 -c:v copy -bsf:v h264_metadata=level=4.1 output.mp4Common Bitstream Filters
| Filter | Description |
|---|---|
h264_mp4toannexb | Convert H.264 to AnnexB format |
hevc_mp4toannexb | Convert HEVC to AnnexB format |
aac_adtstoasc | Convert AAC ADTS to ASC |
extract_extradata | Extract codec extradata |
h264_redundant_pps | Add redundant PPS |
h264_metadata | Modify H.264 metadata |
hevc_metadata | Modify HEVC metadata |
filter_units | Filter NAL units |
dump_extra | Dump extradata to packets |
prores_metadata | Modify ProRes metadata |
vp9_superframe | VP9 superframe handling |
av1_metadata | Modify AV1 metadata |
Metadata Mapping (-map_metadata)
Syntax
-map_metadata[:metadata_spec_out] infile[:metadata_spec_in]Metadata Specifiers
| Specifier | Target |
|---|---|
g | Global file metadata |
s:stream_index | Stream metadata |
s:v / s:a / s:s | All video/audio/subtitle streams |
c:chapter_index | Chapter metadata |
p:program_index | Program metadata |
Examples
# Copy all metadata from input to output
ffmpeg -i input.mp4 -map_metadata 0 -c copy output.mp4
# Copy global metadata only
ffmpeg -i input.mp4 -map_metadata:g 0:g -c copy output.mp4
# Strip all metadata
ffmpeg -i input.mp4 -map_metadata -1 -c copy output.mp4
# Copy metadata from second input file
ffmpeg -i video.mp4 -i metadata_source.mp4 -map 0 -map_metadata 1 -c copy output.mp4
# Copy stream metadata from input stream 0 to output stream 0
ffmpeg -i input.mp4 -map_metadata:s:0 0:s:0 -c copy output.mp4
# Copy chapter metadata
ffmpeg -i input.mp4 -map_metadata:c 0:c -map_chapters 0 -c copy output.mp4
# Copy all metadata, but set specific values
ffmpeg -i input.mp4 -map_metadata 0 -metadata title="New Title" -c copy output.mp4Metadata Manipulation
# Add/modify metadata
ffmpeg -i input.mp4 -metadata title="Video Title" -metadata artist="Creator" output.mp4
# Set stream-specific metadata
ffmpeg -i input.mp4 -metadata:s:v:0 title="Main Video" -metadata:s:a:0 language=eng output.mp4
# Set chapter metadata
ffmpeg -i input.mp4 -metadata:c:0 title="Chapter 1" output.mp4
# Remove specific metadata (set to empty)
ffmpeg -i input.mp4 -metadata comment= -c copy output.mp4Attachments
Adding (-attach)
# Attach font file (for subtitles)
ffmpeg -i input.mkv -attach DejaVuSans.ttf \
-metadata:s:t:0 mimetype=application/x-truetype-font \
-c copy output.mkv
# Attach cover art
ffmpeg -i input.mp4 -attach cover.jpg \
-metadata:s:t:0 mimetype=image/jpeg \
-c copy output.mkv
# Multiple attachments
ffmpeg -i input.mkv \
-attach font1.ttf -metadata:s:t:0 mimetype=application/x-truetype-font \
-attach font2.ttf -metadata:s:t:1 mimetype=application/x-truetype-font \
-c copy output.mkvExtracting (-dump_attachment)
# Extract first attachment to specific file
ffmpeg -dump_attachment:t:0 extracted_font.ttf -i input.mkv
# Extract all attachments (uses filename metadata)
ffmpeg -dump_attachment:t "" -i input.mkv
# Extract specific stream by index
ffmpeg -dump_attachment:3 attachment.bin -i input.mkvDisposition Flags
# Set stream as default
ffmpeg -i input.mkv -c copy -disposition:a:0 default output.mkv
# Set as default and forced subtitle
ffmpeg -i input.mkv -c copy -disposition:s:0 default+forced output.mkv
# Clear all dispositions
ffmpeg -i input.mkv -c copy -disposition:a:1 0 output.mkv
# Multiple dispositions
ffmpeg -i input.mkv -c copy \
-disposition:v:0 default \
-disposition:a:0 default \
-disposition:a:1 0 \
output.mkvDisposition Values
| Value | Description |
|---|---|
default | Default stream for playback |
dub | Dubbed audio track |
original | Original language |
comment | Commentary track |
lyrics | Lyrics track |
karaoke | Karaoke version |
forced | Forced subtitles |
hearing_impaired | Subtitles for hearing impaired |
visual_impaired | Audio for visually impaired |
clean_effects | Clean audio effects |
attached_pic | Attached picture (cover art) |
captions | Closed captions |
descriptions | Audio descriptions |
metadata | Metadata stream |
dependent | Dependent stream |
still_image | Still image stream |