FFmpeg Getting Started Tutorial: 30 Practical Commands for Beginners
Anyone working with video eventually meets FFmpeg. VLC uses it, YouTube uses it, OBS uses it, every video processing software uses FFmpeg under the hood. But FFmpeg is a command-line tool with no GUI, many parameters, and obscure documentation. This tutorial gets you from zero to productive with 30 copy-paste commands.
What is FFmpeg?
FFmpeg is an open-source multimedia processing suite created by Fabrice Bellard in 2000. It's the de facto standard for audio/video processing. Three core tools:
- ffmpeg: Encode, transcode, process audio/video
- ffprobe: Inspect media file metadata
- ffplay: Simple media player
It can do almost anything: format conversion, compression, HLS slicing, merging, audio extraction, subtitle burning, screenshots, filters, streaming, screen recording, GIF creation...
Countless software is built on FFmpeg: VLC, OBS, HandBrake, Premiere (uses FFmpeg internally), Chrome's media decoding, YouTube's server-side encoding, all tools on this site.
Installation
Windows
- Visit ffmpeg.org/download.html
- Download Windows builds (gyan.dev recommended)
- Extract to
C:\ffmpeg - Add
C:\ffmpeg\binto PATH - Open new command prompt, run
ffmpeg -version
macOS
brew install ffmpeg
ffmpeg -versionLinux
# Ubuntu / Debian
sudo apt update && sudo apt install ffmpeg
# CentOS / RHEL
sudo yum install ffmpeg
ffmpeg -versionCheck encoder support
# List all encoders
ffmpeg -encoders
# Check H.264 support
ffmpeg -encoders | grep 264
# Check H.265 support
ffmpeg -encoders | grep 265Core concepts: Container, Codec, Stream
Three concepts to understand:
- Container: The "box" holding data, determines file extension. MP4, MKV, WebM, AVI, TS, MOV are containers.
- Stream: Content inside the box. A video file typically has video stream, audio stream, subtitle stream.
- Codec: Compression method for streams. H.264, H.265, VP9 are video codecs; AAC, MP3, Opus are audio codecs.
Key point: Container determines compatibility (what players can open it), codec determines decoding capability (whether player can decode it). The same MP4 container can hold H.264 or H.265 video — browser support depends on codec, not container.
For codec details, see our H.264 vs H.265 vs AV1 comparison.
Command structure
All FFmpeg commands follow this structure:
ffmpeg [global options] [input options] -i input_file [output options] output_filePosition matters:
- Global options come first
- Input options come before
-i - Output options come after input file, before output file
Example:
ffmpeg -y -ss 00:00:10 -i input.mp4 -t 5 -c:v libx264 -crf 23 output.mp4
# ↑ ↑______________↑ ↑________________________↑
# global input options output options-y: Global, overwrite output file-ss 00:00:10: Input option, start reading from 10 seconds-i input.mp4: Input file-t 5: Output option, output only 5 seconds-c:v libx264 -crf 23: Output options, H.264 encoding CRF 23output.mp4: Output file
30 practical commands
Format conversion (10 examples)
# 1. MP4 to WebM
ffmpeg -i input.mp4 -c:v libvpx-vp9 -c:a libopus output.webm
# 2. WebM to MP4
ffmpeg -i input.webm -c:v libx264 -crf 23 -c:a aac output.mp4
# 3. MKV to MP4 (stream copy, lossless and fast)
ffmpeg -i input.mkv -c copy output.mp4
# 4. MOV to MP4
ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac output.mp4
# 5. AVI to MP4
ffmpeg -i input.avi -c:v libx264 -crf 23 -c:a aac output.mp4
# 6. MP4 to GIF (basic, poor quality)
ffmpeg -i input.mp4 output.gif
# 7. MP4 to GIF (high quality two-stage)
ffmpeg -i input.mp4 -vf "fps=15,scale=540:-1:flags=lanczos,palettegen" palette.png
ffmpeg -i input.mp4 -i palette.png -filter_complex "fps=15,scale=540:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
# 8. Extract audio as MP3
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k output.mp3
# 9. Extract audio as AAC
ffmpeg -i input.mp4 -vn -c:a aac -b:a 192k output.m4a
# 10. Audio format conversion (FLAC to MP3)
ffmpeg -i input.flac -c:a libmp3lame -b:a 320k output.mp3For more conversion scenarios, see our WebM to MP4 guide and Audio format conversion guide.
Compression (5 examples)
# 11. Basic compression (CRF 23)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4
# 12. High compression (CRF 28, 60% smaller)
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset slow -c:a aac -b:a 96k output.mp4
# 13. H.265 encoding (half the size at same quality)
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -c:a aac output.mp4
# 14. Cap maximum bitrate (for streaming)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -maxrate 2M -bufsize 4M -c:a aac output.mp4
# 15. Mobile-optimized (720p + 2Mbps)
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -maxrate 2M -bufsize 4M -s 1280x720 -r 30 -c:a aac -b:a 96k output.mp4For compression principles, see our Video Compression Complete Guide.
HLS slicing (3 examples)
# 16. Basic HLS slicing
ffmpeg -i input.mp4 -codec copy -hls_time 6 -hls_playlist_type vod -hls_segment_filename "seg_%03d.ts" playlist.m3u8
# 17. Re-encode and slice
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac -hls_time 6 -hls_playlist_type vod -hls_segment_filename "seg_%03d.ts" playlist.m3u8
# 18. Live streaming (keep last 6 segments)
ffmpeg -re -i input.mp4 -codec copy -hls_time 4 -hls_list_size 6 -hls_flags delete_segments -hls_segment_filename "live_%03d.ts" live.m3u8For HLS details, see our MP4 to M3U8 tutorial.
Merging (3 examples)
# 19. TS merging (lossless stream copy)
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4
# 20. Merge different format videos (requires re-encoding)
ffmpeg -f concat -safe 0 -i filelist.txt -c:v libx264 -crf 23 -c:a aac output.mp4
# 21. Concatenate two MP4s (simple, same codec/params only)
ffmpeg -i "concat:input1.mp4|input2.mp4" -c copy output.mp4For TS merging, see our TS file merge tutorial.
Clipping and screenshots (4 examples)
# 22. Clip video segment (from 1 minute, 30 seconds)
ffmpeg -ss 00:01:00 -t 00:00:30 -i input.mp4 -c copy output.mp4
# 23. Clip video segment (more accurate, re-encode)
ffmpeg -ss 00:01:00 -i input.mp4 -t 00:00:30 -c:v libx264 -crf 23 -c:a aac output.mp4
# 24. Capture single frame as image (at 5 seconds)
ffmpeg -ss 00:00:05 -i input.mp4 -frames:v 1 output.png
# 25. Capture one frame per second
ffmpeg -i input.mp4 -vf fps=1 frame_%04d.pngFilters and subtitles (3 examples)
# 26. Scale video to 720p
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:v libx264 -crf 23 -c:a aac output.mp4
# 27. Add watermark (image at top-right)
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=W-w-10:10" -c:a copy output.mp4
# 28. Burn subtitles
ffmpeg -i input.mp4 -vf "subtitles=subs.srt" -c:v libx264 -crf 23 -c:a aac output.mp4Streaming and screen recording (2 examples)
# 29. RTMP push streaming
ffmpeg -re -i input.mp4 -c copy -f flv "rtmp://live-push.example.com/live/streamkey"
# 30. Linux screen recording (x11grab)
ffmpeg -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0 -c:v libx264 -crf 23 output.mp4For streaming details, see our Live streaming push guide.
Common parameters reference
Video parameters
| Parameter | Meaning | Common values |
|---|---|---|
-c:v | Video codec | libx264, libx265, libvpx-vp9 |
-crf | Quality (H.264/H.265) | 18 (visually lossless), 23 (balanced), 28 (high compression) |
-preset | Encoding speed | ultrafast → veryslow, slower = better compression |
-b:v | Video bitrate | 2M, 5M |
-maxrate | Max bitrate | Use with -bufsize |
-s | Resolution | 1280x720, 1920x1080 |
-r | Frame rate | 24, 30, 60 |
-vf | Video filter | scale=..., fps=..., transpose=... |
Audio parameters
| Parameter | Meaning | Common values |
|---|---|---|
-c:a | Audio codec | aac, libmp3lame, libopus, copy |
-b:a | Audio bitrate | 128k, 192k, 320k |
-ar | Sample rate | 44100, 48000 |
-ac | Channel count | 1 (mono), 2 (stereo) |
Time parameters
| Parameter | Meaning | Example |
|---|---|---|
-ss | Start time | 00:01:30 or 90 |
-t | Duration | 00:00:30 or 30 |
-to | End time | 00:02:00 |
Other common parameters
| Parameter | Meaning |
|---|---|
-i | Input file |
-c copy | Stream copy, no re-encoding (lossless and fast) |
-vn | Drop video |
-an | Drop audio |
-y | Overwrite output without asking |
-n | Don't overwrite existing files |
-metadata | Add metadata |
Common issues
| Issue | Cause | Solution |
|---|---|---|
Unknown encoder 'libx264' | Not compiled with encoder | Install full FFmpeg build |
| No audio after conversion | Audio codec incompatible | Add -c:a aac |
| File is huge | CRF too low or preset too fast | Use CRF 23+, preset medium/slow |
| Conversion slow | Preset too slow or using AV1 | Use preset medium or fast |
| "Non-monotonous DTS" error | Timestamp errors | Add -fflags +genpts |
| Cross-origin playback fails | MP4 moov atom at end | Add -movflags +faststart |
| Black frames after clip | -ss after -i inaccurate | Move -ss before -i |
FFmpeg.wasm: FFmpeg in the browser
All video tools on this site use FFmpeg.wasm — FFmpeg's C code compiled to WebAssembly, executed directly in the browser. Advantages:
- No installation, works in browser
- Files never leave your device (privacy)
- Performance close to native (30-50% slower)
Limitations: browser memory limits (large files >2GB may crash), complex filters slower than native. For everyday use, perfectly adequate. For professional production, install native FFmpeg.
Summary
FFmpeg is the Swiss Army knife of audio/video processing. The command-line interface has no GUI, but parameters are fixed, scripts can be batched, and automation is possible. Remember the command structure ffmpeg [input options] -i input [output options] output, and 30 common commands cover 80% of use cases.
Don't want to install software? Use our browser tools (powered by FFmpeg under the hood). For professional use, install native FFmpeg.
Quick reference:
- Command structure:
ffmpeg [input options] -i input [output options] output - Universal transcode:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4 - Lossless stream copy:
-c copy(no re-encoding) - Inspect metadata:
ffprobe input.mp4 - Browser version: All our video tools use FFmpeg.wasm