Prepare a video before uploading it to YouTube
YouTube re-compresses every video, but a source file that is too large (raw recording, ProRes, camera file) can take hours to upload. This command produces a high-quality H.264 file that is much smaller and that YouTube processes without any trouble.
Updated on
Never go above the original resolution: upscaling a video doesn't improve it. The options below only reduce it if it is larger.
16 is nearly lossless but large; 18 is the best compromise for YouTube.
How to use it
- Install ffmpeg if you haven't already.
- Open a terminal in the folder containing your file.
- Copy the generated command, adjust the file names if needed, then run it.
- Open the resulting file to check the result.
Why re-encode before uploading?
A video shot with a camera, a smartphone or screen-capture software can reach several dozen megabits per second. YouTube re-compresses it anyway, but the upload takes time and depends on your connection. An H.264 file at CRF 18 is often 3 to 10 times smaller, with no visible difference after YouTube's processing.
The command settings
The "yuv420p" profile ensures compatibility. The audio is encoded in AAC at 192 kbps, above what YouTube recommends. The -movflags +faststart option places the index at the beginning of the file, which speeds up processing after the upload.
Frequently asked questions
Which format does YouTube recommend?
YouTube accepts most formats, but recommends the MP4 container with H.264 video, AAC-LC audio and the index placed at the beginning of the file (faststart). That is exactly what the command produces.
Why CRF and not a fixed bitrate?
With CRF, ffmpeg uses just the bitrate needed to reach the target quality: more bitrate on complex scenes, less on calm ones. This is more efficient than a constant bitrate.
My video is HDR or 10-bit, what should I do?
This command converts to 8-bit SDR, which can wash out the colors of an HDR source. For HDR, upload the original file directly, or use a setting specific to your camera.
How long does encoding take?
The "slow" preset takes about twice as long as "medium" for a file that is 5 to 10% smaller. For a long video, choose "medium" or "fast" if you are in a hurry.