FFmpeg – Complete Multimedia Framework for Audio and Video Processing

4.9 Stars
Version 6.1
80 MB

Mastering FFmpeg: The Ultimate Multimedia Processing Tool

FFmpeg stands as the most comprehensive and powerful open-source multimedia framework available, capable of handling virtually any audio and video processing task imaginable. From simple format conversions to complex streaming pipelines, FFmpeg provides the foundation that powers countless media applications, streaming platforms, and professional production workflows. Understanding FFmpeg unlocks the ability to manipulate media files with precision and efficiency impossible with graphical applications.

The framework comprises several components: ffmpeg for transcoding, ffprobe for analyzing media files, and ffplay for playback. Together they support hundreds of codecs, formats, and protocols, enabling processing of everything from vintage formats to cutting-edge standards like AV1 and HDR video.

Installing FFmpeg

Linux Installation

# Ubuntu/Debian
sudo apt update
sudo apt install ffmpeg

# Fedora
sudo dnf install ffmpeg

# Arch Linux
sudo pacman -S ffmpeg

# Build from source (latest features)
git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx
make -j$(nproc)
sudo make install

# Verify installation
ffmpeg -version
ffprobe -version

macOS Installation

# Homebrew
brew install ffmpeg

# With all options
brew install ffmpeg --with-fdk-aac --with-sdl2 --with-freetype

ffmpeg -version

Windows Installation

# Chocolatey
choco install ffmpeg

# Winget
winget install FFmpeg.FFmpeg

# Scoop
scoop install ffmpeg

ffmpeg -version

Basic Conversions

# Convert format
ffmpeg -i input.mkv output.mp4

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

# Copy streams (no re-encoding)
ffmpeg -i input.mkv -c copy output.mp4

# Convert audio only
ffmpeg -i input.wav output.mp3
ffmpeg -i input.flac -c:a libmp3lame -q:a 2 output.mp3

# Extract audio from video
ffmpeg -i video.mp4 -vn -c:a copy audio.aac
ffmpeg -i video.mp4 -vn -c:a libmp3lame audio.mp3

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

Video Encoding

# H.264 encoding
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium output.mp4

# CRF values: 0 (lossless) to 51 (worst)
# 18-23 recommended for high quality
# Presets: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow

# H.265/HEVC encoding
ffmpeg -i input.mp4 -c:v libx265 -crf 28 output.mp4

# AV1 encoding
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 output.webm
ffmpeg -i input.mp4 -c:v libsvtav1 -crf 30 output.mp4

# VP9 encoding
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 output.webm

# Two-pass encoding (better quality)
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -pass 1 -f null /dev/null
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -pass 2 output.mp4

# Constant bitrate
ffmpeg -i input.mp4 -c:v libx264 -b:v 5M output.mp4

# Variable bitrate with max
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -maxrate 4M -bufsize 8M output.mp4

Video Manipulation

# Resize video
ffmpeg -i input.mp4 -vf scale=1920:1080 output.mp4
ffmpeg -i input.mp4 -vf scale=1280:-1 output.mp4  # Maintain aspect ratio
ffmpeg -i input.mp4 -vf scale=-2:720 output.mp4   # Even dimensions

# Crop video
ffmpeg -i input.mp4 -vf crop=640:480:100:50 output.mp4
# crop=width:height:x:y

# Rotate video
ffmpeg -i input.mp4 -vf transpose=1 output.mp4
# 0: CCW and vertical flip, 1: CW, 2: CCW, 3: CW and vertical flip

# Change framerate
ffmpeg -i input.mp4 -r 30 output.mp4

# Change speed
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4  # 2x speed
ffmpeg -i input.mp4 -filter:v "setpts=2*PTS" output.mp4    # 0.5x speed

# Trim video
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4
ffmpeg -i input.mp4 -ss 60 -t 30 -c copy output.mp4  # 30 seconds starting at 60s

# Concatenate videos
# Create file list: files.txt
# file 'video1.mp4'
# file 'video2.mp4'
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4

# Add padding
ffmpeg -i input.mp4 -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4

# Overlay watermark
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:10" output.mp4

# Add text
ffmpeg -i input.mp4 -vf "drawtext=text='Hello':fontsize=24:fontcolor=white:x=10:y=10" output.mp4

Audio Processing

# Convert audio format
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3
ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a
ffmpeg -i input.wav -c:a libopus -b:a 128k output.opus
ffmpeg -i input.wav -c:a flac output.flac

# Change sample rate
ffmpeg -i input.wav -ar 44100 output.wav

# Change channels
ffmpeg -i input.wav -ac 1 mono.wav
ffmpeg -i input.wav -ac 2 stereo.wav

# Adjust volume
ffmpeg -i input.mp3 -filter:a "volume=2.0" output.mp3
ffmpeg -i input.mp3 -filter:a "volume=6dB" output.mp3

# Normalize audio
ffmpeg -i input.mp3 -filter:a loudnorm output.mp3

# Trim audio
ffmpeg -i input.mp3 -ss 00:00:30 -t 60 -c copy output.mp3

# Merge audio tracks
ffmpeg -i audio1.mp3 -i audio2.mp3 -filter_complex amerge=inputs=2 output.mp3

# Extract specific audio track
ffmpeg -i video.mkv -map 0:a:1 -c copy second_audio.aac

Streaming

# Stream to RTMP
ffmpeg -re -i input.mp4 -c copy -f flv rtmp://server/live/stream

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

# DASH output
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f dash manifest.mpd

# Screen capture
# Linux
ffmpeg -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0 output.mp4

# macOS
ffmpeg -f avfoundation -framerate 30 -i "1" output.mp4

# Windows
ffmpeg -f gdigrab -framerate 30 -i desktop output.mp4

# Webcam capture
ffmpeg -f v4l2 -framerate 30 -video_size 1280x720 -i /dev/video0 output.mp4

# Stream webcam
ffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -preset ultrafast -f flv rtmp://server/live/stream

Analyzing Media

# Get file information
ffprobe input.mp4
ffprobe -v error -show_format -show_streams input.mp4

# JSON output
ffprobe -v error -print_format json -show_format -show_streams input.mp4

# Get duration
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4

# Get resolution
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4

# Get codec
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 input.mp4

# Get bitrate
ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 input.mp4

Batch Processing

# Convert all files in directory
for f in *.avi; do ffmpeg -i "$f" -c:v libx264 "${f%.avi}.mp4"; done

# Parallel processing
ls *.mkv | parallel -j4 ffmpeg -i {} -c:v libx264 {.}.mp4

# Windows batch
for %%f in (*.avi) do ffmpeg -i "%%f" -c:v libx264 "%%~nf.mp4"

Advanced Filters

# Deinterlace
ffmpeg -i input.mp4 -vf yadif output.mp4

# Denoise
ffmpeg -i input.mp4 -vf nlmeans output.mp4

# Stabilize video
ffmpeg -i input.mp4 -vf vidstabdetect -f null -
ffmpeg -i input.mp4 -vf vidstabtransform output.mp4

# Color correction
ffmpeg -i input.mp4 -vf eq=brightness=0.1:contrast=1.2:saturation=1.3 output.mp4

# Fade in/out
ffmpeg -i input.mp4 -vf "fade=in:0:30,fade=out:870:30" output.mp4

# Complex filter chains
ffmpeg -i input.mp4 -vf "scale=1280:-2,fps=30,eq=contrast=1.1" output.mp4

# Multiple inputs with filter_complex
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[0:v][1:a]concat=n=1:v=1:a=1" output.mp4

Hardware Acceleration

# NVIDIA NVENC
ffmpeg -i input.mp4 -c:v h264_nvenc -preset fast output.mp4

# AMD VCE
ffmpeg -i input.mp4 -c:v h264_amf output.mp4

# Intel Quick Sync
ffmpeg -i input.mp4 -c:v h264_qsv output.mp4

# VAAPI (Linux)
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v h264_vaapi output.mp4

# Hardware decoding
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp4

Conclusion

FFmpeg’s comprehensive capabilities make it the foundation of media processing workflows worldwide. From simple conversions to complex streaming pipelines, understanding FFmpeg commands enables precise control over audio and video manipulation. The extensive documentation and active community ensure solutions exist for virtually any multimedia processing challenge.

Developer: FFmpeg Project

Download Options

Download FFmpeg – Complete Multimedia Framework for Audio and Video Processing

Version 6.1

File Size: 80 MB

Download Now
Safe & Secure

Verified and scanned for viruses

Regular Updates

Always get the latest version

24/7 Support

Help available when you need it