FFmpeg Technical Guide
Command-line reference for encoding, transcoding, streaming, and format conversion. Real-world examples optimized for Shoutcast Net video and audio streaming infrastructure.
Updated November 2025 • 15 min read
FFmpeg is available for all major operating systems. Choose your platform:
Download:
https://ffmpeg.org/download.html
Extract to C:\ffmpeg
Add to PATH in System Environment Variables
Using Homebrew:
brew install ffmpeg
Verify:
ffmpeg -version
Ubuntu/Debian:
sudo apt update
sudo apt install ffmpeg
CentOS/RHEL:
sudo yum install ffmpeg
ffmpeg [global_options] [input_options] -i input_file [output_options] output_file
Common Input Options:
-i - Input file or stream-ss - Start time (seek)-t - Duration-f - Force input formatCommon Output Options:
-c:v - Video codec-c:a - Audio codec-b:v - Video bitrate-b:a - Audio bitrateConvert any video to MP4 (H.264):
ffmpeg -i input.mov -c:v libx264 -c:a aac output.mp4
Quick conversion (copy streams if compatible):
ffmpeg -i input.avi -c copy output.mp4
High quality (CRF 18-23):
ffmpeg -i input.mp4 -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k output.mp4
Balanced quality/size (CRF 23-28):
ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4
Fixed bitrate for streaming:
ffmpeg -i input.mp4 -c:v libx264 -b:v 5000k -maxrate 5000k -bufsize 10000k \
-c:a aac -b:a 128k output.mp4
| Resolution | FFmpeg Command | Use Case |
|---|---|---|
| 1080p (Full HD) | -vf scale=-2:1080 |
Desktop, high-quality streaming |
| 720p (HD) | -vf scale=-2:720 |
Standard streaming quality |
| 480p (SD) | -vf scale=-2:480 |
Mobile 4G, slower connections |
| 360p (Low) | -vf scale=-2:360 |
Mobile 3G, bandwidth limited |
Example: Scale to 720p with quality preset:
ffmpeg -i input.mp4 -vf scale=-2:720 -c:v libx264 -preset fast -crf 23 \
-c:a aac -b:a 128k output_720p.mp4
Convert to MP3:
ffmpeg -i input.wav -c:a libmp3lame -b:a 320k output.mp3
Convert to AAC (better quality):
ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a
Extract audio from video:
ffmpeg -i input.mp4 -vn -c:a libmp3lame -b:a 192k audio_only.mp3
| Quality Level | Bitrate | Command Example | Best For |
|---|---|---|---|
| High | 320 kbps | -b:a 320k |
Music streaming, DJ sets |
| Standard | 192 kbps | -b:a 192k |
Radio stations, podcasts |
| Medium | 128 kbps | -b:a 128k |
Voice content, talk radio |
| Low | 64 kbps | -b:a 64k |
Mobile, bandwidth limited |
Normalize audio volume:
ffmpeg -i input.mp3 -af "loudnorm=I=-16:TP=-1.5:LRA=11" -c:a libmp3lame -b:a 192k normalized.mp3
Remove silence from beginning/end:
ffmpeg -i input.mp3 -af "silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:\
detection=peak,aformat=dblp,areverse,silenceremove=start_periods=1:start_duration=1:\
start_threshold=-60dB:detection=peak,aformat=dblp,areverse" output.mp3
Add fade in/out:
ffmpeg -i input.mp3 -af "afade=t=in:ss=0:d=3,afade=t=out:st=27:d=3" output.mp3
Basic RTMP streaming:
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -b:v 3000k \
-maxrate 3000k -bufsize 6000k -c:a aac -b:a 128k \
-f flv rtmp://live.shoutcastnet.com/live/YOUR_STREAM_KEY
Stream with 720p encoding:
ffmpeg -re -i input.mp4 -vf scale=-2:720 -c:v libx264 -preset veryfast \
-b:v 2500k -maxrate 2500k -bufsize 5000k -g 60 -keyint_min 60 \
-c:a aac -b:a 128k -ar 44100 \
-f flv rtmp://live.shoutcastnet.com/live/YOUR_STREAM_KEY
Secure RTMPS streaming (encrypted):
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -b:v 3000k \
-c:a aac -b:a 128k \
-f flv rtmps://live.shoutcastnet.com:443/live/YOUR_STREAM_KEY
Windows - Stream webcam:
ffmpeg -f dshow -i video="Your Webcam Name":audio="Your Microphone Name" \
-c:v libx264 -preset veryfast -b:v 2500k -c:a aac -b:a 128k \
-f flv rtmp://live.shoutcastnet.com/live/YOUR_STREAM_KEY
macOS - Stream webcam:
ffmpeg -f avfoundation -framerate 30 -i "0:0" \
-c:v libx264 -preset veryfast -b:v 2500k -c:a aac -b:a 128k \
-f flv rtmp://live.shoutcastnet.com/live/YOUR_STREAM_KEY
Linux - Stream webcam:
ffmpeg -f v4l2 -framerate 30 -video_size 1280x720 -i /dev/video0 \
-f alsa -i hw:0 -c:v libx264 -preset veryfast -b:v 2500k \
-c:a aac -b:a 128k \
-f flv rtmp://live.shoutcastnet.com/live/YOUR_STREAM_KEY
-re - Read input at native frame rate (prevents sending too fast)-g 60 - GOP size / keyframe interval (2 seconds at 30fps)-preset veryfast - Encoding speed (veryfast, fast, medium, slow)-maxrate - Maximum bitrate cap for CBR streaming-bufsize - Rate control buffer (usually 2x maxrate)Create HLS playlist and segments:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -b:v 3000k -b:a 128k \
-f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename "segment%03d.ts" \
playlist.m3u8
Output: Creates playlist.m3u8 + segment000.ts, segment001.ts, etc.
Create adaptive streaming with multiple qualities:
ffmpeg -i input.mp4 \
-filter_complex \
"[0:v]split=3[v1][v2][v3]; \
[v1]scale=-2:360[v1out]; \
[v2]scale=-2:720[v2out]; \
[v3]scale=-2:1080[v3out]" \
-map "[v1out]" -c:v:0 libx264 -b:v:0 800k -maxrate:v:0 856k -bufsize:v:0 1200k \
-map "[v2out]" -c:v:1 libx264 -b:v:1 2800k -maxrate:v:1 2996k -bufsize:v:1 4200k \
-map "[v3out]" -c:v:2 libx264 -b:v:2 5000k -maxrate:v:2 5350k -bufsize:v:2 7500k \
-map a:0 -c:a:0 aac -b:a:0 96k -ar:a:0 44100 \
-map a:0 -c:a:1 aac -b:a:1 128k -ar:a:1 44100 \
-map a:0 -c:a:2 aac -b:a:2 192k -ar:a:2 44100 \
-f hls -hls_time 6 -hls_playlist_type vod \
-master_pl_name master.m3u8 \
-var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2" \
-hls_segment_filename "stream_%v/segment%03d.ts" stream_%v.m3u8
Tip: This creates master.m3u8 with three quality levels (360p, 720p, 1080p). Players automatically switch based on viewer bandwidth.
Cut video (no re-encoding):
ffmpeg -ss 00:01:30 -to 00:03:45 -i input.mp4 -c copy output.mp4
Trim with re-encoding:
ffmpeg -i input.mp4 -ss 00:00:10 -t 00:00:30 -c:v libx264 -c:a aac output.mp4
Concatenate multiple videos:
# Create file list.txt with:
# file 'video1.mp4'
# file 'video2.mp4'
# file 'video3.mp4'
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
Add watermark/logo overlay:
ffmpeg -i input.mp4 -i logo.png -filter_complex \
"[1:v]scale=120:-1[logo];[0:v][logo]overlay=W-w-10:10" \
-c:a copy output.mp4
Extract single frame at specific time:
ffmpeg -i input.mp4 -ss 00:00:05 -vframes 1 thumbnail.jpg
Generate thumbnails every 10 seconds:
ffmpeg -i input.mp4 -vf "fps=1/10" thumbnails/thumb%04d.jpg
Create thumbnail strip/sprite:
ffmpeg -i input.mp4 -vf "select='not(mod(n,100))',scale=160:90,tile=10x10" sprite.jpg
Hardware acceleration (NVIDIA):
ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc -preset fast -b:v 5000k \
-c:a aac -b:a 192k output.mp4
Multi-threaded encoding:
ffmpeg -i input.mp4 -c:v libx264 -threads 8 -preset fast output.mp4
Two-pass encoding (best quality/size ratio):
# Pass 1
ffmpeg -i input.mp4 -c:v libx264 -b:v 3000k -pass 1 -an -f null /dev/null
# Pass 2
ffmpeg -i input.mp4 -c:v libx264 -b:v 3000k -pass 2 -c:a aac -b:a 128k output.mp4
Stream MP3 to Icecast/Shoutcast:
ffmpeg -re -i music.mp3 -c:a libmp3lame -b:a 192k \
-f mp3 icecast://source:PASSWORD@stream.shoutcastnet.com:8000/stream
Playlist loop for 24/7 radio:
ffmpeg -stream_loop -1 -re -i playlist.m3u -c:a libmp3lame -b:a 192k \
-f mp3 icecast://source:PASSWORD@stream.shoutcastnet.com:8000/radio
Mix multiple audio sources:
ffmpeg -i music.mp3 -i voiceover.mp3 \
-filter_complex "[0:a][1:a]amix=inputs=2:duration=shortest" \
-c:a libmp3lame -b:a 192k output.mp3
Problem: FFmpeg build missing required codec support.
Solution: Check available encoders with ffmpeg -encoders. Install full FFmpeg build with all codecs, not minimal version.
Alternative: Use different codec: -c:v libx264 instead of h264_nvenc
Causes: Network instability, bitrate too high, keyframe interval wrong.
Solutions:
-b:v 2000k instead of 5000k-g 60 for 2-second GOP at 30fps-maxrate 2000k -bufsize 4000k-preset veryfast instead of slowSolution 1 - Fix A/V sync:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -async 1 output.mp4
Solution 2 - Audio delay adjustment:
ffmpeg -i input.mp4 -itsoffset 0.5 -i input.mp4 -map 0:v -map 1:a -c copy output.mp4
Solutions for faster encoding:
-preset ultrafast or veryfast-hwaccel cuda (NVIDIA) or -hwaccel qsv (Intel)-vf scale=-2:720 instead of 1080p-crf 28 instead of 18-threads 8-c:v libx264 - H.264 video (universal)-c:v libx265 - H.265/HEVC (better compression)-c:v libvpx-vp9 - VP9 for WebM-c:a aac - AAC audio (universal)-c:a libmp3lame - MP3 audio-c:a libopus - Opus (best quality)ultrafast - Fastest, largest fileveryfast - Good for live streamingfast - Balanced speed/qualitymedium - Default, good balanceslow - Better quality, slowerveryslow - Best quality, very slow-vf scale=-2:720 - Resize to 720p-vf crop=1280:720:0:0 - Crop video-vf fps=30 - Change frame rate-af volume=2.0 - Double volume-af loudnorm - Normalize audio-af afade=t=in:d=3 - Fade in 3 sec-crf 18 - High quality (18-23)-crf 23 - Balanced (default)-crf 28 - Lower quality/smaller-b:v 5000k - Fixed video bitrate-b:a 192k - Audio bitrate-maxrate 5000k - Max bitrate capUse these FFmpeg commands with Shoutcast Net's professional streaming infrastructure. Get RTMP ingest, HLS/DASH adaptive delivery, DVR recording, and global CDN. No encoding expertise required—our platform handles it automatically.
14-day free trial • No credit card • Full FFmpeg support