1. Muxing Video & Audio Streams (Zero Re-encoding)
YouTube delivers 1080p and 4K video as separate video-only and audio-only streams. To merge them instantaneously without loss:
ffmpeg -i video.mp4 -i audio.m4a -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 output.mp4
2. Compressing MP4s with Constant Rate Factor (CRF)
Use libx264 with -crf 23 (range 18–28, lower means higher quality) to cut file sizes by 60% without perceptible difference:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a aac -b:a 128k compressed.mp4
3. Transcoding to Modern AV1
AV1 produces 30% smaller files than HEVC/H.265 at the same visual fidelity:
ffmpeg -i input.mp4 -c:v libsvtav1 -crf 28 -preset 6 -c:a libopus -b:a 96k output.mkv
4. Converting Horizontal 16:9 to Vertical 9:16 (Reels / Shorts)
Crop a centered 1080x1920 vertical canvas out of a 1920x1080 horizontal recording:
ffmpeg -i horizontal.mp4 -vf "crop=ih*(9/16):ih" -c:a copy reel_9_16.mp4
5. Trimming Videos Fast (Zero Quality Loss)
Cut from second 10 to second 45 using stream copying (runs in under 1 second):
ffmpeg -ss 00:00:10 -to 00:00:45 -i input.mp4 -c copy clip.mp4
6. Extracting MP3 Audio from Video
ffmpeg -i reel.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3