Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FFmpeg commands become manageable once you understand what each option applies to and where it appears. This guide explains ten practical options, with runnable examples and the placement rules that prevent common mistakes.

FFmpeg is described in its official manual as “a universal media converter.” A command normally contains the ffmpeg program, global options, one or more input sections introduced by -i, output options, and one or more output filenames or URLs. The general pattern is:

ffmpeg [global_options] {[input_options] -i input_url} ... {[output_options] output_url} ...

For a first conversion, this is enough:

ffmpeg -i input.avi output.mp4

FFmpeg infers many formats from the input and output names, but that command does not promise a particular codec, quality, size, or compatibility result. Those depend on the files, defaults, codecs and containers involved. The official manual is regenerated nightly for the newest FFmpeg revision, and FFmpeg remains under continuous development, so check the current documentation when behavior matters: FFmpeg command-line documentation.

How option placement works

As a general rule, an option applies to the next specified input or output file. Options reset between files. In practical terms, put input options before the input they control, and output options after the relevant -i and before that output filename.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ffmpeg [options for input] -i input.mp4 [options for output] output.webm

Global options such as -y and -n affect the command as a whole. With multiple inputs or outputs, repeat the appropriate options for each file rather than assuming one setting applies everywhere.

The 10 options at a glance

Option What it controls Typical placement
-i Names an input file or URL Before the input name
-c, -c:v, -c:a Selects a codec or requests stream copy Usually before an output name
-map Chooses which streams enter an output Before the output name
-f Forces an input or output format Before the input or output it describes
-t Limits read or write duration Position determines behavior
-b:v Sets a target video bitrate Before the video output
-r Sets an output frame rate Before the output name
-y Overwrites existing outputs without asking Global
-n Refuses to overwrite existing outputs Global
-vn and related flags Excludes video, audio, subtitles or data Before the output name

1. -i: specify the input

-i introduces an input file or URL. The input can be a local path, network URL, device or another source supported by your FFmpeg build.

ffmpeg -i input.avi output.mp4

Here, FFmpeg reads input.avi and writes output.mp4. The output extension helps FFmpeg select a container, but it does not by itself define every codec or quality setting. Quote paths containing spaces:

ffmpeg -i "My vacation video.avi" "My vacation video.mp4"

When a command has several inputs, each one gets its own -i. Later options can refer to a particular input stream through mapping or stream specifiers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. -c, -c:v and -c:a: encode or copy streams

The -c option selects an encoder for an output or a decoder for an input. Stream specifiers narrow the setting: -c:v applies to video and -c:a to audio. The special value copy requests stream copy, meaning that stream is not re-encoded.

ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT

This example encodes all selected video with libx264 while copying audio. Encoding takes processing time and changes the stream; copying avoids re-encoding but only works when the destination container supports the copied stream.

To encode both streams explicitly:

ffmpeg -i input.mkv -c:v libx264 -c:a aac output.mp4

Codec names available on your system depend on the FFmpeg build. If FFmpeg reports an unknown encoder or an incompatible stream, choose a codec supported by that build and container.

3. -map: choose streams manually

Without -map, FFmpeg automatically selects streams for an output. That is convenient for simple files, but a movie may contain several audio languages, subtitle tracks, commentary channels or attached data. -map gives you predictable control.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT

0:v means video streams from the first input, and 0:a? means audio streams from that input if audio exists. The question mark makes the audio mapping optional, so a video-only input does not fail merely because no audio stream is present.

To select a particular stream, use an index such as -map 0:a:1 for the second audio stream. Once you use manual mapping, streams not mapped are normally excluded from that output. Confirm the available streams first when necessary:

ffmpeg -i input.mkv

Read the stream listing in FFmpeg’s diagnostic output, then map the tracks you actually need.

4. -f: force a format

FFmpeg usually detects an input format and guesses an output format from the filename extension. For ordinary named media files, you often do not need -f. It becomes useful with raw formats, unusual names, pipes or situations where inference is insufficient.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ffmpeg -f lavfi -i testsrc=size=1280x720:rate=30 -f mp4 output.mp4

The option applies to the next input or output context. Forcing the wrong format can produce an unreadable file, so use a format name appropriate to the actual data and destination.

5. -t: limit duration

As an output option, -t stops writing after the requested duration:

ffmpeg -i input.mp4 -t 00:00:10 output.mp4

This creates an output lasting up to ten minutes? No: 00:00:10 means ten seconds. FFmpeg accepts time values such as HH:MM:SS and fractional seconds.

Placed before -i, it limits how much of the input FFmpeg reads:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ffmpeg -t 00:00:10 -i input.mp4 output.mp4

Placement therefore changes the operation. The manual also documents -to as an alternative stopping point; -t and -to are mutually exclusive, and -t takes priority if both are supplied.

6. -b:v: set a target video bitrate

-b:v sets a target bitrate for video. The official manual illustrates the syntax with:

ffmpeg -i input.avi -b:v 64k -bufsize 64k output.mp4

A bitrate is not a direct quality guarantee. The visible result and final size also depend on the codec, rate-control mode, source content, frame rate and other encoder settings. Treat the manual’s 64 kb/s example as a demonstration of option placement, not a universal recommendation for modern video.

Use a unit such as k for kilobits per second and keep the option scoped to video; audio has its own setting, commonly written with -b:a.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

7. -r: set the frame rate

As an output option, -r requests a particular output frame rate:

ffmpeg -i input.avi -r 24 output.mp4

This asks FFmpeg to produce 24 frames per second. Changing frame rate can duplicate or drop frames and may affect motion or synchronization, so do it for a specific delivery requirement rather than assuming a higher or lower value is automatically better.

The manual also describes an input frame-rate option. It is intended for raw formats, where the source does not carry timing information; do not use an input frame-rate setting casually on ordinary files that already contain timestamps.

8. -y: overwrite without prompting

-y tells FFmpeg to overwrite an existing output file without asking:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ffmpeg -y -i input.mp4 output.mp4

This is useful in automated jobs, but it can destroy a previous result. Use it only when replacing the destination is intentional.

9. -n: refuse to overwrite

-n does the opposite: if the output already exists, FFmpeg exits instead of replacing it.

ffmpeg -n -i input.mp4 output.mp4

It is the safer choice for scripts that must preserve earlier outputs. Do not combine it with an expectation that FFmpeg will silently pick a new filename; your script must handle the refusal and choose what to do next.

10. -vn and the stream-exclusion family

-vn disables video in an output. The related flags are -an for audio, -sn for subtitles and -dn for data. They can exclude stream types even when those streams would otherwise be selected automatically or mapped manually, subject to filtergraph outputs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For an audio-only extraction:

ffmpeg -i input.mp4 -vn output.m4a

The destination container and audio codec must support the resulting stream. If the source audio is compatible and you want to avoid re-encoding, request a copy explicitly:

ffmpeg -i input.mp4 -vn -c:a copy output.m4a

If the container cannot hold that copied codec, choose a compatible output format and encoder instead.

Putting the options together

Here is a more controlled conversion that selects video and optional audio, limits duration, sets an encoder and frame rate, and protects an existing file:

ffmpeg -n -i input.mkv -map 0:v -map 0:a? -t 00:02:00 -c:v libx264 -c:a aac -r 30 output.mp4

Read it from left to right: do not overwrite; read input.mkv; map video and optional audio; stop after two minutes; encode video and audio; request 30 fps; write output.mp4. Whether the command succeeds still depends on the source streams, installed encoders and MP4 compatibility.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common choices and failure modes

Encoding versus copying

Encoding changes a stream and requires processing. copy avoids re-encoding that stream, but the target container must support it. A copy can therefore fail even when the source file plays correctly.

Automatic versus manual mapping

Automatic selection is shortest for simple files. Use -map when a file has multiple tracks or you need a repeatable choice. Remember that manual mapping can omit streams you forgot to include.

Extension versus forced format

Let the extension guide routine file conversions. Use -f when working with raw data, pipes or ambiguous names, and verify that the forced format matches the data.

Overwrite behavior

If a script unexpectedly replaces files, remove -y and use -n. If an automated pipeline stops because a file exists, handle that expected exit condition rather than adding -y blindly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Missing streams or unknown codecs

Run ffmpeg -i input to inspect streams and read the diagnostic message. Add an optional map such as 0:a? for files that may lack audio, select an available stream explicitly, or choose an encoder present in your build.

Output plays poorly or will not open

Check the container, codec combination, forced format and stream-copy compatibility. Remove unnecessary -f, encode to codecs supported by the destination, or stop copying a stream that the container cannot carry.

Performance, repeatability and safety

  • Use -c copy where compatible when avoiding re-encoding is more important than changing the media.
  • Use -map in scripts that must produce the same tracks every time.
  • Use -n for preservation and reserve -y for deliberate replacement.
  • Place duration, codec, bitrate and frame-rate options on the output they are intended to control.
  • Keep the exact FFmpeg command and version information with automated jobs because the documentation and software are continuously updated.

Or skip the browser setup

If your workflow is actually collecting website screenshots rather than converting media, ScreenshotNeo provides a single HTTP request instead of a browser automation setup. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and responses identify the page verdict and billing status in headers.

For a screenshot, see the ScreenshotNeo documentation and run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.

FAQ

Do I need to use all ten options in one command?

No. Start with -i and an output name, then add only the options needed for your streams, duration, codec, safety or delivery requirements.

Why does the same option behave differently in another position?

FFmpeg applies options to the next input or output they precede. Moving an option across -i can change whether it controls reading the source or writing the destination.

Is -b:v a quality setting?

It is a target video bitrate. Quality and file size also depend on codec, content, rate control, frame rate and other encoder settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How can I see what streams a file contains?

Run ffmpeg -i filename without an output. FFmpeg prints stream information and diagnostics, which you can use to construct precise -map expressions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.