I just read Recommended upload encoding settings article from official google support. I think this is the best settings for encoding my youtube videos.

Can you help me find out how to encode that settings in ffmpeg for 720p or 1080p videos?

Here's the settings

enter image description here

Thanks in advance.

1 Answer 1



ffmpeg -i in.mp4 -vf yadif,format=yuv420p -force_key_frames expr:gte(t\,n_forced/2) -c:v libx264 -crf 18 -bf 2 -c:a aac -q:a 1 -ac 2 -ar 48000 -use_editlist 0 -movflags +faststart out.mp4

-vf specifies video filters

yadif will deinterlace videos if they're interlaced.

format=yuv420p will produce pixel format with 4:2:0 chroma subsampling.

-force_key_frames expr:gte(t\,n_forced/2) will place keyframes every half-second, so that will be the GOP size.

-c:v libx264 will use the x264 encoder to produce a H264 video stream.

-crf 18 will produce a visually lossless file. Better than setting a bitrate manually.

-bf 2 will limit consecutive B-frames to 2

-c:a aac will use the native encoder to produce an AAC audio stream.

-q:a 1 sets the highest quality for the audio. Better than setting a bitrate manually.

-ac 2 rematrixes audio to stereo.

-ar 48000 resamples audio to 48000 Hz.

-use_editlist 0 avoids writing edit lists.

-movflags +faststart places moov atom/box at front of the output file.

  • 2
    I believe you wrote this answer using this Recommended Upload Settings as reference. Here's the command for Content ID Partners: ffmpeg -i in.mp4 -vf yadif,format=yuv422p -force_key_frames expr:gte(t\,n_forced/2) -c:v libx264 -b:v <60M for 1080, 50M for 720, 15M for SD> -bf 2 -c:a flac -ac 2 -ar 44100 -use_editlist 0 -movflags +faststart out.mp4.
    – MCCCS
    Aug 5, 2019 at 15:16
  • Any idea how I can run this on fish shell where parentheses (t\,n_forced/2) are interpreted as a command? Nov 15, 2019 at 6:36
  • 1
    Enclose expr:gte(t\,n_forced/2) in single or double quotes, I guess
    – Gyan
    Nov 15, 2019 at 6:55
  • 2
    -force_key_frames "expr:gte(t,n_forced/2)"
    – Polly
    Apr 15, 2020 at 9:51
  • 1
    @Zoom Content ID Partners can (and should) use 44.1kHZ and the lossless audio codec PCM-FLAC (note: I forgot to add 16 or 24 bits audio to my command). They should use higher bitrates for video. They should use 4:2:2 not 4:2:0. Note that my command is untested.
    – MCCCS
    Mar 31 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.