When you upload video to YouTube, the wrong encoding settings cause extra quality loss during YouTube’s re-encode. This article walks through FFmpeg commands that follow YouTube’s recommended spec.

Tested with: FFmpeg 6.1 (ubuntu-latest / GitHub Actions CI-verified)


ItemYouTube recommendation
Video codecH.264 (MP4 recommended)
Frame rate24, 25, 30, 48, 50, 60 fps
Resolution1080p or higher (up to 8K)
Audio codecAAC-LC
Audio sample rate48 kHz
Audio channelsStereo (2ch) recommended
Loudness-14 LUFS integrated
ContainerMP4 (recommended)

Baseline Command (1080p H.264)

The maximum-compatibility settings for YouTube.

ffmpeg -i input.mp4 \
  -c:v libx264 \
  -preset slow \
  -crf 18 \
  -profile:v high \
  -level 4.1 \
  -pix_fmt yuv420p \
  -movflags +faststart \
  -c:a aac \
  -b:a 192k \
  -ar 48000 \
  -ac 2 \
  output_youtube.mp4

What each setting does:

OptionValueWhy
-crf 1818 (high quality)YouTube re-encodes, so start from a high-quality source
-preset slowslowCompresses efficiently when paired with CRF
-profile:v highHighProfile recommended by YouTube
-level 4.14.1Sufficient for 1080p/30fps and below
-pix_fmt yuv420pyuv420pMaximum compatibility (browsers, phones)
-movflags +faststartStart playback immediately on the Web
-b:a 192k192 kbpsYouTube’s audio bitrate ceiling
-ar 4800048 kHzYouTube’s recommended sample rate

Since YouTube re-encodes uploads, you want enough headroom in the source so the result stays high-quality after their re-encode.

SDR (Standard Dynamic Range)

ResolutionFrame rateRecommended video bitrateFFmpeg command
4K (2160p)24–30 fps35–45 Mbps-b:v 40M
4K (2160p)48–60 fps53–68 Mbps-b:v 60M
1080p24–30 fps8 Mbps-crf 18
1080p48–60 fps12 Mbps-crf 17
720p24–30 fps5 Mbps-crf 20
480p24–30 fps2.5 Mbps-crf 23

CRF mode adapts to scene complexity better than a hand-picked bitrate.

# For 1080p / 30fps
ffmpeg -i input.mp4 \
  -c:v libx264 -crf 18 -preset slow \
  -vf "scale=1920:1080:flags=lanczos,fps=30" \
  -c:a aac -b:a 192k -ar 48000 -ac 2 \
  -movflags +faststart \
  output_1080p.mp4

# For 1080p / 60fps
ffmpeg -i input.mp4 \
  -c:v libx264 -crf 17 -preset slow \
  -vf "scale=1920:1080:flags=lanczos,fps=60" \
  -c:a aac -b:a 192k -ar 48000 -ac 2 \
  -movflags +faststart \
  output_1080p60.mp4

Normalize Loudness to YouTube Standard

YouTube auto-normalizes loudness, but pre-normalizing lets you upload at exactly the loudness you intend.

# Normalize to -14 LUFS (YouTube standard)
ffmpeg -i input.mp4 \
  -af "loudnorm=I=-14:TP=-1.5:LRA=11" \
  -c:v copy \
  output_normalized.mp4

See the volume adjustment tool (browser-based) for the same processing in the browser.


Shortcut: Upload an Existing Video with Minimal Processing

If the video is already H.264, you can swap only the container without re-encoding.

# MOV to MP4 (no codec change, fast)
ffmpeg -i input.mov -c copy -movflags +faststart output.mp4

# MKV to MP4 (no codec change)
ffmpeg -i input.mkv -c copy output.mp4

Uploading in H.265 (HEVC)

H.265 yields files about 50% smaller than H.264, but since YouTube’s final re-encode targets VP9 or AV1, the quality difference at the source is negligible.

ffmpeg -i input.mp4 \
  -c:v libx265 -crf 20 -preset slow \
  -tag:v hvc1 \
  -c:a aac -b:a 192k -ar 48000 \
  -movflags +faststart \
  output_h265.mp4

-tag:v hvc1 is needed for QuickTime playback on iOS/macOS.


Common Issues and Fixes

Q. Quality drops after upload

If your source bitrate is too low, YouTube’s re-encode degrades it further. Use -crf 18 (H.264) or -crf 20 (H.265) or lower for high-quality encoding.

Q. Audio is missing or out of sync

# Check audio streams
ffprobe -v quiet -print_format json -show_streams input.mp4 | grep codec_type

If the audio codec isn’t supported by YouTube (e.g., PCM), convert to AAC.

Q. Settings for vertical video (YouTube Shorts)

# 9:16 vertical (1080x1920)
ffmpeg -i input.mp4 \
  -vf "scale=1080:1920:flags=lanczos" \
  -c:v libx264 -crf 18 -preset slow \
  -c:a aac -b:a 192k -ar 48000 \
  -movflags +faststart \
  output_shorts.mp4

Try It in Your Browser Right Now

See the video compression tool — compress for YouTube while keeping file size down.
See the volume adjustment tool — normalize to -14 LUFS.
See the video format comparison — how to choose between MP4, WebM, MOV, and MKV.


Frequently Asked Questions

8 Mbps for 1080p 30 fps and 12 Mbps for 1080p 60 fps as a minimum. YouTube re-encodes everything, so over-shooting gives YouTube more headroom for quality.

Should I upload at 1080p or 4K?

Upload at the highest resolution you have. YouTube’s 4K transcode produces a higher-bitrate 1080p variant than a 1080p upload, even for 1080p viewers.

Two-pass or CRF for YouTube uploads?

CRF 17–18 with -preset slow gives near-master quality and is simpler than two-pass. Two-pass only matters when targeting an exact upload size.

Why does my upload look soft after YouTube processing?

YouTube’s VP9/AV1 transcode is bitrate-capped per resolution. The fix is to upload higher resolution (4K → 1080p path) or wait for AV1 transcode (sharper than VP9).

Should I use HDR for YouTube?

Only if you mastered in HDR end-to-end and have a properly tagged HDR file (BT.2020, PQ or HLG). YouTube’s HDR-to-SDR fallback for non-HDR viewers can look worse than pure SDR.