
FFmpeg video conversion commands: Convert video formats, resize, trim, remux and choose streams with FFmpeg. Always check codec support and keep originals until output is verified. This guide explains what each command does, its syntax, practical examples, useful options, and common mistakes. Commands are shown for typical installations; flags can vary across operating-system and tool versions.
Before you start
Open a terminal appropriate for the operating system shown in the examples. Check that the required tool is installed and that you are running it with the permissions needed for your task. Replace sample names, paths, hostnames and IDs with values from your own environment.
Syntax at a glance
Square brackets usually indicate optional arguments, while uppercase words such as FILE, HOST and PACKAGE are placeholders that you replace. Keep quotes around paths or text that contains spaces. Commands should be tested on a safe sample before being used in production.
Quick command reference
| Command | What it does | Example | Useful options |
|---|---|---|---|
ffmpeg -i input.mp4 output.webm | Convert a source file to WebM | ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 output.webm | -c:v selects the video encoder; CRF controls quality/size for supported codecs |
-vf scale | Resize video frames | ffmpeg -i input.mp4 -vf scale=1280:-2 output.mp4 | -2 asks FFmpeg to choose a divisible dimension |
-c copy | Remux compatible streams without re-encoding | ffmpeg -i input.mp4 -c copy output.mkv | Fast and lossless at the stream level; destination format must support the streams |
-ss / -to | Trim a segment by start and end time | ffmpeg -ss 00:00:10 -to 00:00:20 -i input.mp4 clip.mp4 | Placing -ss before input can be faster; exact boundaries depend on encoding |
-map | Choose streams for the output | ffmpeg -i input.mp4 -map 0:v:0 -map 0:a:0 output.mp4 | -map 0 selects all streams; -an disables audio |
Command syntax and examples explained
1. ffmpeg -i input.mp4 output.webm
Purpose: Convert a source file to WebM.
Syntax
ffmpeg -i INPUT OUTPUT.webmExample
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 output.webmOptions and notes: -c:v selects the video encoder; CRF controls quality/size for supported codecs.
Encoder availability depends on the FFmpeg build.
2. -vf scale
Purpose: Resize video frames.
Syntax
-vf scale=WIDTH:HEIGHTExample
ffmpeg -i input.mp4 -vf scale=1280:-2 output.mp4Options and notes: -2 asks FFmpeg to choose a divisible dimension.
Keep aspect ratio to avoid stretching.
3. -c copy
Purpose: Remux compatible streams without re-encoding.
Syntax
-c copy INPUT OUTPUTExample
ffmpeg -i input.mp4 -c copy output.mkvOptions and notes: Fast and lossless at the stream level; destination format must support the streams.
This will not convert an incompatible codec just because the extension changes.
4. -ss / -to
Purpose: Trim a segment by start and end time.
Syntax
-ss START -to END -i INPUT OUTPUTExample
ffmpeg -ss 00:00:10 -to 00:00:20 -i input.mp4 clip.mp4Options and notes: Placing -ss before input can be faster; exact boundaries depend on encoding.
Check the resulting clip duration and audio/video synchronization.
5. -map
Purpose: Choose streams for the output.
Syntax
-map INPUT_INDEX:STREAM_INDEXExample
ffmpeg -i input.mp4 -map 0:v:0 -map 0:a:0 output.mp4Options and notes: -map 0 selects all streams; -an disables audio.
Stream selection prevents unexpected subtitles or extra audio tracks being copied.
Common mistakes and troubleshooting
- Command not found: confirm the tool is installed and available on your PATH; open a new terminal after changing PATH.
- Permission denied: verify the current account, file permissions and target path. Use administrator/root privileges only when genuinely required.
- Unexpected output: check the command version, quoting, current directory and exact arguments. Consult the local help or manual for options supported by your build.
- Destructive operations: preview the target and keep a backup before deleting data, rewriting history, flashing a partition or changing system configuration.
Safety tips
Review every command before running it, especially commands that delete files, change permissions, flash firmware, alter a database or expose a network service. For network scanning and remote administration, work only on devices and systems you own or are authorized to test. Keep credentials, private keys, access tokens and log files private.
Frequently asked questions
Do these commands work on every system?
Not always. Some commands are specific to Windows, Linux, Android, a particular package manager or an installed tool version. Use the syntax shown for your platform and check local help when a flag is unavailable.
Can I copy and run every example exactly?
Use the examples as templates. Replace placeholders such as filenames, package IDs, hostnames and paths with your own values, and verify the effect before executing a command that changes data or system state.
Conclusion
Use this reference as a starting point, then confirm flags in the tool’s official help or manual for your installed version. A clear understanding of syntax, options and side effects makes command-line work more reliable.