Format Conversion
basicConvert a video from one format to another
ffmpeg -i input.avi output.mp4The output format is determined by the file extension. FFmpeg automatically selects an appropriate encoder.
Complete FFmpeg usage guide with various common commands, parameter explanations and practical application scenario examples
Understanding the most powerful multimedia framework
Runs on Linux, macOS, Windows, and more
Free to use under LGPL or GPL license
Supports virtually all video/audio formats
Command-line interface for automation
Quick start guide for beginners
Convert a video from one format to another
ffmpeg -i input.avi output.mp4The output format is determined by the file extension. FFmpeg automatically selects an appropriate encoder.
Extract the audio track from a video file
ffmpeg -i video.mp4 -vn -c:a libmp3lame audio.mp3Extracts the audio stream from the video and saves it as MP3 while preserving original audio quality.
Capture a single frame at a specific timestamp
ffmpeg -i video.mp4 -ss 00:01:30 -vframes 1 screenshot.jpgCaptures a single frame at 1 minute and 30 seconds. Commonly used for thumbnails or previews.
Display detailed media file information
ffmpeg -i input.mp4Displays codec, duration, resolution, bitrate, and stream details when no output file is specified.
Convert a video clip to an animated GIF
ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" output.gifConverts video to a 10 FPS GIF with 320px width. Commonly used for memes or short animations.
Batch convert multiple files to MP4 format
for %i in (*.mov) do ffmpeg -i "%i" -c:v libx264 -crf 23 -c:a aac "%~ni.mp4"Batch converts all MOV files to MP4 using H.264 and AAC. Common for camera footage workflows.
Export all frames as an image sequence
ffmpeg -i video.mp4 frame_%04d.jpgExtracts every frame as JPEG images (frame_0001.jpg, frame_0002.jpg, etc.).
Extract a specific time range from a video
ffmpeg -i input.mp4 -ss 00:10:00 -to 00:15:30 -c copy clip.mp4Quickly trims a clip using stream copy to preserve original quality and speed up processing.
Concatenate multiple video files into one
ffmpeg -f concat -i filelist.txt -c copy output.mp4Merges multiple videos listed in filelist.txt without re-encoding.
Speed up or slow down video playback
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -an output.mp4Speeds up video by 2x (0.5*PTS). Use 2*PTS to slow down by 0.5x.
Change the video resolution
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4Resizes the video to 1280x720 pixels while preserving the original aspect ratio.
Reduce video file size
ffmpeg -i input.mp4 -c:v libx264 -crf 23 compressed.mp4Compresses the video using H.264. Lower CRF values produce higher quality. A typical range is 18–28.
Overlay an image or text watermark on the video
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:10" output.mp4Adds a PNG watermark image at position (10,10) in the top-left corner of the video.
Crop a specific region of the video
ffmpeg -i input.mp4 -vf "crop=640:360:100:100" output.mp4Crops a 640x360 region starting from position (100,100).
Rotate the video by 90°, 180°, or 270°
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4Transpose values: 0 = 90° CCW + vertical flip, 1 = 90° clockwise, 2 = 90° counter-clockwise, 3 = 90° clockwise + vertical flip.
Analyze camera shake using vid.stab
ffmpeg -i shaky.mp4 -vf vidstabdetect=shakiness=5:accuracy=15:result="transform_vectors.trf" -f null -Step 1: Analyzes camera shake and generates a transformation vector file.
Apply video stabilization
ffmpeg -i shaky.mp4 -vf vidstabtransform=smoothing=10:input="transform_vectors.trf" stable.mp4Step 2: Applies stabilization using the generated transform file. The smoothing parameter controls stabilization strength.
Remove interlacing artifacts from video
ffmpeg -i input.mp4 -vf yadif output.mp4Removes interlacing artifacts to make the video suitable for progressive displays.
Convert interlaced video to progressive
ffmpeg -i interlaced.mp4 -vf bwdif=0:-1:0 deinterlaced.mp4Uses the BWDIF filter to convert interlaced video to progressive scan for better playback quality.
Reduce noise and grain in video
ffmpeg -i noisy.mp4 -vf hqdn3d denoised.mp4Reduces visual noise and grain using the hqdn3d filter to improve overall video quality.
Increase or decrease audio volume
ffmpeg -i input.mp3 -af "volume=1.5" output.mp3Boosts the audio volume by 50%. Use values below 1.0 to reduce volume.
Convert audio from one format to another
ffmpeg -i input.wav -c:a libmp3lame -b:a 192k output.mp3Converts WAV audio to MP3 at 192 kbps, suitable for web distribution.
Extract a specific time segment from audio
ffmpeg -i input.mp3 -ss 00:01:30 -to 00:03:45 -c copy clip.mp3Extracts audio from 01:30 to 03:45 without re-encoding, preserving original quality.
Add fade-in and fade-out effects to audio
ffmpeg -i input.mp3 -af "afade=t=in:st=0:d=3,afade=t=out:st=10:d=3" output.mp3Applies a 3-second fade-in starting at 0s and a 3-second fade-out starting at 10s.
Reduce background noise in audio
ffmpeg -i input.wav -af "afftdn=nf=-20" output.wavUses FFT-based noise reduction to reduce background noise. The nf parameter controls denoising strength.
Merge multiple audio files into one
ffmpeg -i "concat:input1.mp3|input2.mp3" -c copy output.mp3Merges multiple audio files in sequence without re-encoding, preserving original quality.
Adjust the audio sample rate
ffmpeg -i input.wav -ar 44100 output.wavSets the audio sample rate to 44.1 kHz, the standard CD-quality sample rate.
Convert between mono and stereo
ffmpeg -i input.wav -ac 1 output.wavConverts stereo audio to mono. Set to 2 to convert mono to stereo.
Adjust frequency response using EQ
ffmpeg -i input.wav -af "equalizer=f=1000:width_type=o:width=2:g=5" output.wavBoosts the 1000 Hz frequency band by 5 dB to adjust tonal balance.
Apply audio dynamic range compression
ffmpeg -i input.wav -af "acompressor=threshold=0.1:ratio=9:attack=200:release=1000" output.wavApplies dynamic range compression to reduce loudness variation and make quiet parts louder.
Overlay text watermark on video
ffmpeg -i input.mp4 -vf "drawtext=text='Sample Text':x=10:y=10:fontsize=24:fontcolor=white" output.mp4Adds a white text watermark at position (10,10) with a font size of 24.
Apply blur effect to video
ffmpeg -i input.mp4 -vf "boxblur=5:1" output.mp4Applies a blur effect to the video. The first parameter controls blur strength, and the second controls quality.
Adjust brightness, contrast, and saturation
ffmpeg -i input.mp4 -vf "eq=brightness=0.1:contrast=1.2:saturation=1.5" output.mp4Adjusts brightness (+0.1), contrast (1.2x), and saturation (1.5x).
Create a vertical mirror effect
ffmpeg -i input.mp4 -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" output.mp4Creates a vertical mirror effect where the bottom half mirrors the top half.
Apply old film / vintage movie effect
ffmpeg -i input.mp4 -vf "noise=alls=20:allf=t+u, curves=vintage" output.mp4Adds film grain and vintage color curves to simulate an old movie look.
Enhance video details and clarity
ffmpeg -i input.mp4 -vf "unsharp=5:5:1.0" output.mp4Sharpens the video using the unsharp mask algorithm to enhance detail and clarity.
Detect and highlight edges in video
ffmpeg -i input.mp4 -vf "edgedetect=low=0.1:high=0.4" output.mp4Detects and highlights edges in the video, commonly used in computer vision workflows.
Convert video color space
ffmpeg -i input.mp4 -vf "colorspace=bt709:iall=bt601-6-625:fast=1" output.mp4Converts video from BT.601 color space to BT.709 color space.
Convert color video to grayscale
ffmpeg -i input.mp4 -vf "hue=s=0" output.mp4Converts color video to grayscale by setting saturation to 0.
Invert video colors
ffmpeg -i input.mp4 -vf "negate" output.mp4Inverts all color values to create a negative film effect.
Record RTMP live stream to a local file
ffmpeg -i rtmp://server/live/stream -c copy -f flv recording.flvRecords an RTMP live stream and saves it as an FLV file. Stream copy avoids re-encoding to reduce CPU usage.
Convert a video file to HLS streaming format
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f hls -hls_time 10 -hls_list_size 0 output.m3u8Converts an MP4 file to HLS format with 10-second segments, suitable for web streaming.
Stream a local file to an RTMP server
ffmpeg -re -i input.mp4 -c copy -f flv rtmp://server/live/streamPushes a local video file to an RTMP server as a live stream, commonly used for live broadcasting.
Capture and record desktop screen
ffmpeg -f gdigrab -i desktop output.mp4Records the entire desktop on Windows. On Linux, use x11grab for screen capture.
Record video from webcam device
ffmpeg -f dshow -i video="Integrated Camera" output.mp4Records video from a webcam device on Windows. Make sure to specify the correct device name.
Record audio from input device
ffmpeg -f alsa -i default output.wavRecords audio from the default input device on Linux and saves it as a WAV file.
Generate adaptive bitrate HLS streams
ffmpeg -i input.mp4 -map 0 -c:v libx264 -b:v:0 800k -s:v:0 640x360 -c:v:1 libx264 -b:v:1 1500k -s:v:1 854x480 -c:a aac -f hls -var_stream_map "v:0,a:0 v:1,a:0" -hls_segment_filename stream_%v/data%02d.ts -master_pl_name master.m3u8 stream_%v.m3u8Generates multiple HLS variants (360p and 480p) for adaptive bitrate streaming under different network conditions.
Convert a video file to MPEG-DASH format
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f dash -window_size 5 -extra_window_size 5 -remove_at_exit 1 output.mpdConverts an MP4 file to MPEG-DASH format for adaptive bitrate streaming.
Record RTSP video stream
ffmpeg -i rtsp://server/stream -c copy output.mp4Records an RTSP video stream and saves it as an MP4 file. Commonly used for IP cameras and surveillance systems.
Stream or upload video to an HTTP endpoint
ffmpeg -i input.mp4 -c copy -f mp4 http://server/uploadStreams or uploads a video file to an HTTP server endpoint using POST requests.
Create a picture-in-picture overlay
ffmpeg -i main.mp4 -i pip.mp4 -filter_complex "[1:v]scale=iw/4:ih/4 [pip]; [0:v][pip] overlay=W-w-10:10" output.mp4Creates a picture-in-picture effect by scaling the secondary video to 25% size and placing it in the top-right corner.
Use GPU hardware acceleration for video encoding
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp4Uses NVIDIA GPU acceleration to significantly speed up H.264 video encoding.
Process and combine multiple video streams
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2" output.mp4Combines two video streams side by side. Use vstack for vertical stacking.
Burn timecode into video frames
ffmpeg -i input.mp4 -vf "drawtext=fontfile=/path/to/font.ttf:text='%{pts\:hms}':x=10:y=10:fontsize=24:fontcolor=white" output.mp4Overlays SMPTE-style timecode in the top-left corner using hours:minutes:seconds format.
Modify container metadata fields
ffmpeg -i input.mp4 -metadata title="My Video" -metadata year="2023" output.mp4Edits video container metadata such as title, year, and author.
Measure video quality using PSNR
ffmpeg -i compressed.mp4 -i original.mp4 -lavfi psnr -f null -Compares compressed and source videos and outputs PSNR values to evaluate quality loss.
Control quality and limit peak bitrate
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -maxrate 2M -bufsize 4M output.mp4Uses CRF for quality-based encoding while applying VBV to cap peak bitrate.
Convert progressive video to interlaced format
ffmpeg -i progressive.mp4 -vf "fieldorder=tff" interlaced.mp4Converts progressive video to top-field-first interlaced format for broadcast workflows.
Change video frame rate
ffmpeg -i input.mp4 -vf "fps=30" output.mp4Converts video to 30 FPS using frame duplication or dropping as needed.
Reduce compression blocking artifacts
ffmpeg -i blocky.mp4 -vf "deblock" deblocked.mp4Reduces blocking artifacts caused by aggressive compression to improve visual quality.
Add the same watermark to all videos in a folder
for %i in (*.mp4) do ffmpeg -i "%i" -i watermark.png -filter_complex "overlay=10:10" "watermarked_%~ni.mp4"Batch process all MP4 files in the folder and add a watermark to the top-left corner.
Resize all videos in a folder to a unified resolution
for %i in (*.mp4) do ffmpeg -i "%i" -vf scale=1280:720 "resized_%~ni.mp4"Resize all MP4 files to 1280x720 resolution, suitable for standardizing video specs.
Extract audio from all videos in a folder
for %i in (*.mp4) do ffmpeg -i "%i" -vn -c:a libmp3lame "%~ni.mp3"Batch extract audio from all MP4 files and save as MP3 format.
Generate thumbnails for all videos in a folder
for %i in (*.mp4) do ffmpeg -i "%i" -ss 00:00:05 -vframes 1 "%~ni_thumb.jpg"Generate one thumbnail for each video at the 5-second mark.
Compress all videos in a folder to reduce file size
for %i in (*.mp4) do ffmpeg -i "%i" -c:v libx264 -crf 23 -c:a aac -b:a 128k "compressed_%~ni.mp4"Batch compress all MP4 files using CRF 23 and 128 kbps audio to balance quality and file size.
Get duration of all videos in a folder
for %i in (*.mp4) do ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "%i"Use ffprobe to output the duration of each video, useful for calculating total runtime.
Export detailed video metadata to a file
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4 > video_info.jsonExport detailed format and stream information to a JSON file for further analysis.
Analyze video frame types and timestamps
ffprobe -show_frames input.mp4Display detailed information for each frame, including frame type (I/P/B) and timestamps.
Analyze bitrate and frame-level stream details
ffmpeg -i input.mp4 -vf "showinfo" -f null -Analyze stream-level and frame-level information to inspect bitrate and encoding behavior.
Check video file integrity and compatibility
ffmpeg -v error -i input.mp4 -f null -Validate video file integrity and compatibility. Only errors will be shown.
Explore the powerful applications of FFmpeg in real-world scenarios
Convert all MOV files in a folder to MP4 format while preserving original quality
for %i in (*.mov) do ffmpeg -i "%i" -c:v libx264 -crf 18 -c:a aac "%~ni.mp4"Use a Windows batch loop to convert all MOV files. Commonly used for processing videos imported from cameras.
Extract frames from a video at regular intervals to create a thumbnail set
ffmpeg -i video.mp4 -vf "fps=1/60,scale=320:-1" thumbnails/thumb%03d.jpgExtract one frame per minute, scale to 320px width (height auto-scaled), and save as a numbered image sequence.
Extract clips from a long video or merge multiple videos
ffmpeg -i input.mp4 -ss 00:10:00 -to 00:15:30 -c copy clip.mp4Use stream copy (no re-encoding) to quickly extract a clip from 10:00 to 15:30 while preserving original quality.
Rotate a video by 90°, 180°, or 270°
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4Transpose options: 0 = 90° CCW + vertical flip, 1 = 90° CW, 2 = 90° CCW, 3 = 90° CW + vertical flip.
Optimize compression settings for the best quality-to-size ratio
ffmpeg -i input.mp4 -c:v libx264 -preset slower -crf 18 -c:a aac -b:a 128k output.mp4Use the 'slower' preset for better compression efficiency. CRF 18 provides high quality, with 128 kbps audio bitrate.
Common questions about FFmpeg usage
Use ffmpeg -i input.mp4 output.avi to convert between formats. FFmpeg automatically detects the format from file extension.
Use ffmpeg -i input.mp4 -crf 23 output.mp4. Higher CRF values mean smaller files but lower quality. Range is 0-51, default is 23.
Use ffmpeg -i video.mp4 -vn -acodec copy audio.aac. The -vn flag disables video, and -acodec copy extracts without re-encoding.
Create a file list, then use ffmpeg -f concat -i filelist.txt -c copy output.mp4 to concatenate videos without re-encoding.
More online media processing tools
Convert M3U8 streaming media to MP4 video online
Merge multiple TS segment files into a complete video
Extract audio from MP4 video and convert to MP3 format
Play HLS / M3U8 streams online directly in your browser.