Curated collection of common FFmpeg commands, organized by category for quick lookup and copy-paste use
No matching commands found. Please try other keywords.
Convert any video format to the universal MP4 format using H.264 video codec and AAC audio codec for the best compatibility.
ffmpeg -i input.avi -c:v libx264 -c:a aac -strict experimental output.mp4
Directly copy audio and video streams without re-encoding. Extremely fast and preserves original quality.
ffmpeg -i input.mp4 -c copy output.mkv
Convert to WebM format, suitable for web video playback with smaller file sizes.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -c:a libopus output.webm
Convert video clips to GIF animations, with support for custom frame rates and palette optimization for better quality.
ffmpeg -i input.mp4 -vf "fps=10,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Convert MP4 video to HLS streaming format (M3U8 + TS segments), suitable for live streaming and video-on-demand.
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -hls_time 10 -hls_list_size 0 -hls_segment_filename "output_%03d.ts" output.m3u8
Extract audio from video files and save as high-quality MP3 format.
ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3
Convert to lossless WAV format, ideal for audio editing and post-processing.
ffmpeg -i input.mp3 -c:a pcm_s16le output.wav
Convert to AAC format with good sound quality and small file size, suitable for mobile and web use.
ffmpeg -i input.mp3 -c:a aac -b:a 192k output.aac
Convert to FLAC lossless compression format, reducing file size while maintaining audio quality.
ffmpeg -i input.wav -c:a flac output.flac
Convert to Opus format, excellent quality at low bitrates, ideal for internet voice transmission.
ffmpeg -i input.mp3 -c:a libopus -b:a 128k output.opus
Extract a segment from a video. -ss specifies the start time, -t specifies the duration.
ffmpeg -i input.mp4 -ss 00:01:00 -t 00:00:30 -c copy output.mp4
Precise cutting using re-encoding, accurate to the frame, but slower.
ffmpeg -i input.mp4 -ss 00:01:23.456 -t 00:00:10.123 -c:v libx264 -c:a aac output.mp4
Crop the video frame. crop=width:height:start_x:start_y.
ffmpeg -i input.mp4 -vf "crop=720:480:100:50" -c:a copy output.mp4
Automatically detect and crop video black bars.
ffmpeg -i input.mp4 -vf "cropdetect" -f null -
Use the concat protocol to merge video files with the same codec. Fast and lossless quality.
ffmpeg -f concat -i filelist.txt -c copy output.mp4
filelist.txt file format example, listing all files to be merged in order.
file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
Merge multiple TS segment files into a complete video.
ffmpeg -i "concat:file1.ts|file2.ts|file3.ts" -c copy output.mp4
Merge videos of different codec formats, requires re-encoding.
ffmpeg -i input1.mp4 -i input2.avi -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
Compress video file size by specifying video bitrate, balancing quality and file size.
ffmpeg -i input.mp4 -c:v libx264 -b:v 1000k -c:a aac -b:a 128k output.mp4
Compress using CRF (Constant Rate Factor). Value range 0-51, default 23. Higher values produce smaller files.
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -c:a copy output.mp4
Reduce video resolution to decrease file size. -1 means auto-calculate to maintain aspect ratio.
ffmpeg -i input.mp4 -vf "scale=1280:-1" -c:a copy output.mp4
Compress using H.265 codec, approximately 50% smaller file size than H.264 at the same quality.
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -c:a copy output.mp4
Calculate target bitrate to compress video to a specified size (e.g., compress to 10MB).
ffmpeg -i input.mp4 -c:v libx264 -b:v 800k -c:a aac -b:a 128k -pass 2 -f mp4 /dev/null && ffmpeg -i input.mp4 -c:v libx264 -b:v 800k -c:a aac -b:a 128k -pass 2 output.mp4
Burn subtitle files into the video frame so subtitles are visible on any player.
ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt" -c:a copy output.mp4
Package subtitle files into the video. Can be toggled on/off without affecting video quality.
ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text output.mp4
Extract subtitle files from videos containing soft subtitles.
ffmpeg -i input.mp4 -map 0:s:0 subtitle.srt
Customize subtitle font, size, color and other style parameters.
ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='FontName=Arial,FontSize=24,PrimaryColour=&Hffffff&'" -c:a copy output.mp4
Use more feature-rich ASS format subtitles, supporting animations, effects and more.
ffmpeg -i input.mp4 -vf "ass=subtitle.ass" -c:a copy output.mp4
Add an image watermark to the bottom right corner of the video. Position and size can be adjusted.
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=W-w-20:H-h-20" -c:a copy output.mp4
Add a text watermark to the video. Font, size, color, and position can be set.
ffmpeg -i input.mp4 -vf "drawtext=text='CGJU Tools':fontsize=36:fontcolor=white@0.8:x=20:y=20" -c:a copy output.mp4
Add a translucent image watermark that doesn't obscure the video content.
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1:v]format=rgba,colorchannelmixer=aa=0.5[wm];[0:v][wm]overlay=W-w-20:H-h-20" -c:a copy output.mp4
Common watermark position parameters. W/H is video width/height, w/h is watermark width/height.
# Top Left
overlay=20:20
# Top Right
overlay=W-w-20:20
# Bottom Left
overlay=20:H-h-20
# Bottom Right
overlay=W-w-20:H-h-20
# Center
overlay=(W-w)/2:(H-h)/2
Add a text watermark effect that scrolls from right to left.
ffmpeg -i input.mp4 -vf "drawtext=text='CGJU':fontsize=36:fontcolor=white:x=w-mod(t*100\,w+tw):y=20" -c:a copy output.mp4
View detailed video information including codec format, resolution, bitrate, duration, and more.
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
Use the ffmpeg command to view basic video file information.
ffmpeg -i input.mp4
Quickly get the width and height of a video.
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 input.mp4
Get the total duration of a video in seconds.
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
Get the total frame count and frame rate information of a video.
ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets,r_frame_rate -of csv=p=0 input.mp4
View all encoders supported by the current ffmpeg version.
ffmpeg -encoders