CGJU
CGJU
July 10, 2026 · 8 min read

Introduction: What is FFmpeg?

FFmpeg is a powerful open-source audio and video processing tool that supports almost all common audio/video format conversion, editing, filtering, and more. It includes multiple libraries such as libavcodec, libavformat, and libavutil, making it one of the most popular video processing tools available.

This article compiles the most commonly used FFmpeg commands in daily work, covering high-frequency scenarios like format conversion, audio extraction, video cutting, watermarking, subtitle synthesis, and video compression, for quick reference and use.

💡 Tip: If you don't want to memorize commands, you can directly use our online video tools — no software installation required, complete video conversion, compression, and more right in your browser.

1. Basic Commands

1. View Video Information

View detailed video information including resolution, bitrate, encoding format, duration, etc.:

ffmpeg -i input.mp4

Show only key information, no extra output:

ffmpeg -i input.mp4 -hide_banner

2. Check FFmpeg Version

ffmpeg -version

3. View Supported Encoders/Decoders

ffmpeg -encoders
ffmpeg -decoders
ffmpeg -codecs

4. View Supported Formats

ffmpeg -formats

5. View Supported Filters

ffmpeg -filters

2. Video Format Conversion

1. MP4 to AVI

ffmpeg -i input.mp4 output.avi

2. MP4 to MKV

ffmpeg -i input.mp4 output.mkv

3. MP4 to WebM

ffmpeg -i input.mp4 -c:v libvpx -c:a libvorbis output.webm

4. MP4 to MOV

ffmpeg -i input.mp4 -c copy output.mov

5. AVI to MP4

Fast conversion (no re-encoding):

ffmpeg -i input.avi -c copy output.mp4

Re-encoding (better compatibility):

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

6. Batch Format Conversion

Batch convert AVI files in current directory to MP4:

# Windows
for %i in (*.avi) do ffmpeg -i "%i" -c copy "%~ni.mp4"

# Linux/Mac
for f in *.avi; do ffmpeg -i "$f" -c copy "${f%.avi}.mp4"; done

7. Lossless Conversion (Stream Copy)

When the target format supports the same encoding, use -c copy to directly copy the stream — extremely fast and lossless:

ffmpeg -i input.mkv -c copy output.mp4

3. Audio Extraction and Conversion

1. Extract Audio from Video (MP3)

ffmpeg -i input.mp4 -vn -c:a libmp3lame output.mp3

Specify audio quality (0 is best, 9 is worst):

ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3

2. Extract Audio as AAC

ffmpeg -i input.mp4 -vn -c:a aac -b:a 128k output.aac

3. Extract Audio as WAV

ffmpeg -i input.mp4 -vn -c:a pcm_s16le output.wav

4. Audio Format Conversion

# MP3 to AAC
ffmpeg -i input.mp3 -c:a aac -b:a 128k output.aac

# WAV to MP3
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3

# FLAC to MP3
ffmpeg -i input.flac -c:a libmp3lame -b:a 320k output.mp3

5. Extract Audio of Specified Duration

ffmpeg -i input.mp4 -vn -ss 00:01:00 -t 00:00:30 -c:a copy output.mp3

Parameter explanation: -ss start time, -t duration

4. Video Cutting and Joining

1. Cut Video Clip

Starting from second 10, extract 30 seconds of video:

ffmpeg -i input.mp4 -ss 00:00:10 -t 00:00:30 -c copy output.mp4

Cut from start time to end time:

ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4
💡 Note: Using -c copy for cutting is fast but may not be precise. If you need precise cutting, remove -c copy and re-encode.

2. Precise Cutting (Re-encoding)

ffmpeg -i input.mp4 -ss 00:00:10.5 -t 00:00:30.2 -c:v libx264 -c:a aac output.mp4

3. Video Joining

Method 1: Use concat demuxer (file list method)

First create a file list filelist.txt:

file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'

Then join:

ffmpeg -f concat -i filelist.txt -c copy output.mp4

Method 2: Use concat filter (re-encoding)

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4

4. Split Video into Multiple Segments

Split video into segments of 10 minutes each:

ffmpeg -i input.mp4 -c copy -segment_time 00:10:00 -f segment output_%03d.mp4

5. Video Compression and Adjustment

1. Adjust Video Resolution

# Convert to 1280x720
ffmpeg -i input.mp4 -s 1280x720 -c:a copy output.mp4

# Scale proportionally to width 1280, height auto-calculated
ffmpeg -i input.mp4 -vf "scale=1280:-1" -c:a copy output.mp4

# Scale proportionally to height 720, width auto-calculated
ffmpeg -i input.mp4 -vf "scale=-1:720" -c:a copy output.mp4

2. Adjust Video Bitrate

ffmpeg -i input.mp4 -b:v 2000k -b:a 128k output.mp4

3. Adjust Video Quality (CRF)

CRF (Constant Rate Factor) is a quality control parameter for x264/x265 encoders, range 0-51, lower value = higher quality, recommended range 18-28:

# High quality (larger file)
ffmpeg -i input.mp4 -c:v libx264 -crf 18 -c:a copy output.mp4

# Medium quality (recommended)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a copy output.mp4

# Lower quality (smaller file)
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -c:a copy output.mp4

4. Adjust Audio Bitrate

ffmpeg -i input.mp4 -b:a 128k -c:v copy output.mp4

5. Video Compression (Reduce File Size)

ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset medium -c:a aac -b:a 96k output.mp4

Parameter explanation: -preset balance between encoding speed and compression ratio, options: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow

6. Adjust Frame Rate

ffmpeg -i input.mp4 -r 24 -c:a copy output.mp4

6. Watermarking

1. Add Image Watermark

Top-left corner:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:10" -c:a copy output.mp4

Top-right corner:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=W-w-10:10" -c:a copy output.mp4

Bottom-left corner:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:H-h-10" -c:a copy output.mp4

Bottom-right corner:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=W-w-10:H-h-10" -c:a copy output.mp4

Center:

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=(W-w)/2:(H-h)/2" -c:a copy output.mp4

2. Adjust Watermark Opacity

ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1:v]format=rgba,colorchannelmixer=aa=0.5[wm];[0:v][wm]overlay=10:10" -c:a copy output.mp4

Parameter explanation: aa=0.5 means 50% opacity

3. Add Text Watermark

ffmpeg -i input.mp4 -vf "drawtext=text='CGJU':fontsize=24:fontcolor=white:x=10:y=10" -c:a copy output.mp4

4. Animated Watermark (Moving Left to Right)

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=x='if(gte(t,2), -w+(t-2)*100, NAN)':y=10" -c:a copy output.mp4

7. Subtitle Processing

1. Add Soft Subtitles (Toggleable)

ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text output.mp4

2. Burn-in Subtitles (Hard Subtitles)

ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt" -c:a copy output.mp4

3. Extract Subtitles

ffmpeg -i input.mkv -map 0:s:0 subtitle.srt

4. Subtitle Format Conversion

ffmpeg -i subtitle.srt subtitle.ass

8. Video Rotation and Flipping

1. Rotate Video

# Rotate 90 degrees clockwise
ffmpeg -i input.mp4 -vf "transpose=1" -c:a copy output.mp4

# Rotate 90 degrees counterclockwise
ffmpeg -i input.mp4 -vf "transpose=2" -c:a copy output.mp4

# Rotate 180 degrees
ffmpeg -i input.mp4 -vf "transpose=2,transpose=2" -c:a copy output.mp4

2. Horizontal Flip

ffmpeg -i input.mp4 -vf "hflip" -c:a copy output.mp4

3. Vertical Flip

ffmpeg -i input.mp4 -vf "vflip" -c:a copy output.mp4

9. GIF Animation Creation

1. Video to GIF

ffmpeg -i input.mp4 output.gif

2. High Quality GIF

ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif

3. Convert Specific Time Range to GIF

ffmpeg -i input.mp4 -ss 00:00:05 -t 00:00:03 -vf "fps=10,scale=480:-1" output.gif

10. Image and Video Conversion

1. Video to Image Sequence

# Extract one frame per second
ffmpeg -i input.mp4 -r 1 frame_%04d.jpg

# Extract one frame every 10 seconds
ffmpeg -i input.mp4 -r 0.1 frame_%04d.jpg

# Extract all frames
ffmpeg -i input.mp4 frame_%04d.png

2. Image Sequence to Video

ffmpeg -framerate 24 -i frame_%04d.jpg -c:v libx264 -pix_fmt yuv420p output.mp4

3. Single Image to Video

ffmpeg -loop 1 -i image.jpg -t 5 -c:v libx264 -pix_fmt yuv420p output.mp4

11. Streaming Media Related

1. MP4 to M3U8 (HLS)

ffmpeg -i input.mp4 -c:v libx264 -c:a aac -hls_time 10 -hls_list_size 0 -f hls output.m3u8

2. Multi-Bitrate HLS

ffmpeg -i input.mp4 \
  -map 0 -map 0 -map 0 \
  -b:v:0 800k -s:v:0 640x360 \
  -b:v:1 1500k -s:v:1 854x480 \
  -b:v:2 3000k -s:v:2 1280x720 \
  -c:a aac -b:a 128k \
  -var_stream_map "v:0,a:0 v:1,a:0 v:2,a:0" \
  -master_pl_name master.m3u8 \
  -hls_time 10 -hls_list_size 0 \
  -f hls stream_%v/output.m3u8

3. MP4 to DASH

ffmpeg -i input.mp4 \
  -map 0 -map 0 \
  -b:v:0 1500k -s:v:0 854x480 \
  -b:v:1 3000k -s:v:1 1280x720 \
  -b:a 128k \
  -use_timeline 1 -use_template 1 \
  -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" \
  -f dash output.mpd

4. RTMP Streaming

ffmpeg -i input.mp4 -c copy -f flv rtmp://server/live/streamkey

12. Advanced Tips

1. Hardware-Accelerated Encoding

NVIDIA GPU acceleration (NVENC):

ffmpeg -i input.mp4 -c:v h264_nvenc -preset fast -cq 23 -c:a copy output.mp4

Intel QSV acceleration:

ffmpeg -i input.mp4 -c:v h264_qsv -preset medium -c:a copy output.mp4

2. Remove Video Watermark

Use delogo filter to remove watermarks:

ffmpeg -i input.mp4 -vf "delogo=x=10:y=10:w=100:h=50" -c:a copy output.mp4

3. Video Playback Speed

# 2x speed
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4

# 0.5x speed
ffmpeg -i input.mp4 -vf "setpts=2.0*PTS" -af "atempo=0.5" output.mp4

4. Video Reverse

ffmpeg -i input.mp4 -vf "reverse" -af "areverse" output.mp4

5. Video Denoising

ffmpeg -i input.mp4 -vf "nlmeans" -c:a copy output.mp4

6. Video Stabilization

# Step 1: Analyze video
ffmpeg -i input.mp4 -vf vidstabdetect -f null -

# Step 2: Apply stabilization
ffmpeg -i input.mp4 -vf vidstabtransform -c:a copy output.mp4

7. Show Progress During Batch Processing

Use -progress parameter to output progress information:

ffmpeg -i input.mp4 -c copy output.mp4 -progress pipe:1

8. Overwrite Output File Without Prompt

ffmpeg -y -i input.mp4 output.mp4

9. Process Only Video or Audio Stream

# Remove audio
ffmpeg -i input.mp4 -an -c:v copy output.mp4

# Remove video
ffmpeg -i input.mp4 -vn -c:a copy output.mp3

13. Common Parameters Quick Reference

Parameter Description
-i Specify input file
-c / -codec Specify encoder
-c copy Copy stream directly, no re-encoding
-c:v Specify video encoder
-c:a Specify audio encoder
-b:v Video bitrate
-b:a Audio bitrate
-s Resolution, e.g., 1280x720
-r Frame rate
-ss Start time
-t Duration
-to End time
-vf Video filter
-af Audio filter
-vn Remove video stream
-an Remove audio stream
-y Overwrite output file without prompt
-crf Constant Rate Factor (x264/x265)
-preset Encoding speed vs compression ratio balance

Summary

FFmpeg is an extremely powerful audio and video processing tool. Mastering these common commands can greatly improve video processing efficiency. This article covers most common scenarios from basic format conversion to advanced filters — bookmark it for future reference.

If you don't want to memorize commands, you can also directly use our online video tools, including video conversion, compression, M3U8 to MP4, and many other features — no software installation required, complete all operations right in your browser.

Related Recommendations

More great articles and useful tools

Don't Want to Memorize FFmpeg Commands?

Use our online video tools — no software installation needed, complete video conversion, compression and more right in your browser

Try It Now ➡