Skip to content

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

  1. Visit ffmpeg.org/download.html
  2. Download Windows builds (gyan.dev recommended)
  3. Extract to C:\ffmpeg
  4. Add C:\ffmpeg\bin to PATH
  5. Open new command prompt, run ffmpeg -version

macOS

bash
brew install ffmpeg
ffmpeg -version

Linux

bash
# Ubuntu / Debian
sudo apt update && sudo apt install ffmpeg

# CentOS / RHEL
sudo yum install ffmpeg

ffmpeg -version

Check encoder support

bash
# List all encoders
ffmpeg -encoders

# Check H.264 support
ffmpeg -encoders | grep 264

# Check H.265 support
ffmpeg -encoders | grep 265

Core 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:

bash
ffmpeg [global options] [input options] -i input_file [output options] output_file

Position matters:

  • Global options come first
  • Input options come before -i
  • Output options come after input file, before output file

Example:

bash
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 23
  • output.mp4: Output file

30 practical commands

Format conversion (10 examples)

bash
# 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.mp3

For more conversion scenarios, see our WebM to MP4 guide and Audio format conversion guide.

Compression (5 examples)

bash
# 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.mp4

For compression principles, see our Video Compression Complete Guide.

HLS slicing (3 examples)

bash
# 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.m3u8

For HLS details, see our MP4 to M3U8 tutorial.

Merging (3 examples)

bash
# 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.mp4

For TS merging, see our TS file merge tutorial.

Clipping and screenshots (4 examples)

bash
# 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.png

Filters and subtitles (3 examples)

bash
# 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.mp4

Streaming and screen recording (2 examples)

bash
# 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.mp4

For streaming details, see our Live streaming push guide.

Common parameters reference

Video parameters

ParameterMeaningCommon values
-c:vVideo codeclibx264, libx265, libvpx-vp9
-crfQuality (H.264/H.265)18 (visually lossless), 23 (balanced), 28 (high compression)
-presetEncoding speedultrafastveryslow, slower = better compression
-b:vVideo bitrate2M, 5M
-maxrateMax bitrateUse with -bufsize
-sResolution1280x720, 1920x1080
-rFrame rate24, 30, 60
-vfVideo filterscale=..., fps=..., transpose=...

Audio parameters

ParameterMeaningCommon values
-c:aAudio codecaac, libmp3lame, libopus, copy
-b:aAudio bitrate128k, 192k, 320k
-arSample rate44100, 48000
-acChannel count1 (mono), 2 (stereo)

Time parameters

ParameterMeaningExample
-ssStart time00:01:30 or 90
-tDuration00:00:30 or 30
-toEnd time00:02:00

Other common parameters

ParameterMeaning
-iInput file
-c copyStream copy, no re-encoding (lossless and fast)
-vnDrop video
-anDrop audio
-yOverwrite output without asking
-nDon't overwrite existing files
-metadataAdd metadata

Common issues

IssueCauseSolution
Unknown encoder 'libx264'Not compiled with encoderInstall full FFmpeg build
No audio after conversionAudio codec incompatibleAdd -c:a aac
File is hugeCRF too low or preset too fastUse CRF 23+, preset medium/slow
Conversion slowPreset too slow or using AV1Use preset medium or fast
"Non-monotonous DTS" errorTimestamp errorsAdd -fflags +genpts
Cross-origin playback failsMP4 moov atom at endAdd -movflags +faststart
Black frames after clip-ss after -i inaccurateMove -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

References

Last updated: