MediaCoder for YouTube

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

MediaCoder for YouTube

Post by meRobs » Thu Feb 14, 2013 10:38 pm

[updated 14 Feb 2013]

Before starting on this Guide I had no experience with YouTube and I had no intention of ever using it. However, after noting the queries about the use of MediaCoder for creating YouTube files and the problems that arose, I had a look at the information on the YouTube website. Such info was, to say the least, confusing and ambiguous. So, curiosity got the better of me! I did some tests.

This Guide is based on recommendations and claims made on the YouTube website as of February 2013.
I was driven by three questions:
1. What settings to use in MediaCoder?
2. Can you avoid YouTube re-converting your uploaded file?
3. How important is the video bitrate setting in MediaCoder?

1. General YouTube requirements
By default, you can upload videos to YouTube that are up to 15 minutes long; and this limit may be increased under some circumstances
(see: ... opic=16547). Also stated in this link are various allowable file formats suitable for uploading, although, YouTube recommends that you upload as MP4 (container) with H.264 video and AAC-LC audio. The frame rate should be kept the same as that of the source.

YouTube gives suggestions for “Standard quality” uploads and “High quality” uploads. The values given for standard quality are:
* for 1080p (resolution = 1920x1080), use a video bitrate of 8000 kbps and stereo audio at 384 kbps
* for 720p (resolution = 1280x720), use a video bitrate of 5000 kbps and stereo audio at 384 kbps
* for 480p (resolution = 854x480), use a video bitrate of 2500 kbps and stereo audio at 128 kbps
* for 360p (resolution = 640x360), use a video bitrate of 1000 kbps and stereo audio at 128 kbps.

Note 1: the bitrates are relatively high, especially if using H.264 and AAC-LC. I guess the intention here is to minimise degradation resulting from the fact that YouTube re-encodes the uploads (see Section 4, below).
Note 2: the width given for 480p, 854 pixels, is not divisible by 8, as preferred by most encoders. It is not even divisible by 4! The value required for 16:9 to suit a height of 480 is 853.3, and 856 would have been a good choice as it is close enough and divisible by both 4 and 8. However, whichever is chosen, 854 or 856, YouTube will re-encode it to 854. See, the table of results below.

2. Settings in MediaCoder
YouTube recommends that you upload as MP4 (container) with H.264 video and AAC-LC audio (see: ... er=1722171). Also important, is that you set the video as Progressive scan (not interlaced), using a High Profile, 2 consecutive B frames, a ‘closed’ GOP of half the frame rate and CABAC (set by default with x264 in MediaCoder). A variable bitrate should be set and the Colour Space at 4.2.0.

Consequently, on the 13 Feb 2013, I changed the settings for MP4 as given in the Encoding Guide (see: viewtopic.php?f=17&t=9643) to be compatible with the YouTube requirements. . In particular, this Guide specifies:
the Video in H.264 format (x264 encoder) at 1000 kbps via a High profile at Level 4.0 and a Fast Preset with two B frames and two Reference frames. The GOP was set at 12 and CABAC was enabled by default (see the Advanced button on the x264 tab).
The Framerate was set at ‘Original’ and, to suit 480p, Resize was set at 854x480.
The Audio was LC-AAC at 128 kbps and 48 kHz.

Also, YouTube uses players with a 16:9 aspect ratio. Hence, the Aspect Ratio and Crop settings in the Encoding Guide were changed accordingly. This will result in black bars being added to the sides or on top and bottom, if the aspect ratio of the source file is not 16:9.

Thus, the MP4 parameters in the Encoding Guide now fully suit the requirements for uploading to YouTube apart from your choice of video bitrate and the Resolution (“Resize”).

3. Uploads for test
I began by creating a good quality file in Adobe Premiere CS5.5 by modifying material from a quality 16:9 DVD in PAL with video at 6345 kbps and exporting with MPEG2 video at 7 Mbps and a GOP of 12. The audio was AC3 at 128 kbps and 48 kHz. The file was 3:30 min in duration.

This MPG file was loaded into MediaCoder set with the above MP4 parameter values. It was then converted to MP4 files at 25 fps (original Framerate) that suit:
* 360p (640x360), with video at 1000 kbps and audio at 128 kbps
* 480p (854x480), with video at 1000, 2500 or 5000 kbps and audio at 128 kbps. I also tried 856x480.
* 720p (1280x720), with video at 1000, 2500 or 5000 kbps and audio at 320 kbps (maximum settable)

In all cases, the resultant files from MediaCoder had 3 “ReFrames”, as seen in MediaInfo, which doesn’t distinguish between the B-frames and Ref.-frames. Each of these had been set in MediaCoder at ‘2’, which is the maximum number for the encoder to work to.

Once uploaded and processed, the files available for download from YouTube were:
* 4 options for 360p: ‘Medium’ MP4, 360p FLV, a 240p FLV and the ‘Mobile’ 3GP.
* 6 for 480p: ‘Medium’ MP4, 480p FLV, 360p FLV, 240p FLV, the ‘Mobile’ as 3GP and a WebM
* 7 for 720p: ‘Medium’ MP4, 720p MP4, 460p FLV, 360p FLV, 240p FLV, ‘Mobile’ 3GP and a WebM.

The files stored in YouTube were examined by MediaInfo after they were downloaded, and their properties are shown in Table 1. To get these files I used DownloadHelper, an Add-on for Firefox.
On no occasion did the downloads match the properties of the uploaded source files. For example, all source files were done with a High @ L4.0 profile, a GOP of 12 and a total of 4 ReFrames and the audio was at 48 kHz. Not once did a file stored at YouTube have these values. This demonstrates that YouTube re-encodes all uploads!

As mentioned above, I uploaded files in 360p, 480p and 720p, each at 1000 to 5000 kbps. However, I detail in Table 1 the characteristics of the various downloads that were available from YouTube for only 3 uploads: those with a video done at 1000 kbps.

Uploaded with - (if not displayed, click on the link called 'Image')

For those uploaded files that had been created at a higher bitrate, the only difference in properties was a slight increase in the video bitrate, as seen in any subsequent download. For example, for files created in 480p, increasing the source rate from 1000 to 2500 kbps resulted in a change for a 480p download from 1026 kbps to 1045 kbps, an increase of less than 2%, and an ~identical result was obtained for a source at 5000 kbps. On the other hand, source files at 720p gave 720p downloads with video at ~2197 kbps, which increased to ~2445 kbps when the source rate was 5000 kbps. This larger increase of 11.3% shows that the x264 encoder at YouTube was able to utilise the extra bitrate for greater clarity/quality with the larger number of pixels (1280x720).

Notice that, even though YouTube specify particular Resolutions and a GOP of half the Framerate, which were set for the uploads in the test, the resultant files stored on YouTube have different values!

As a test I uploaded an 480p file with a resolution of 856x480, i.e., using dimensions that were multiples of 8. YouTube converted it to 854x480 as it did for the 480p version for a 720p upload (see Table).

Also, I tried to avoid the re-encoding done by YouTube for 720p by creating an upload file with the same values as that normally encoded by YouTube. I used MediaCoder to create a 720p video at 2400 kbps and with x264 set for High @ L3.1, using Fast, a GOP of 60 and LC-AAC audio at 192 kbps and 44.1 kHz, etc. The result was a 720p MP4 with a different file size, due to a different video bitrate (2369 kbps), and no value of GOP listed in its header. Once again YouTube re-encoded!

Even the audio streams in the other files failed to have the same characteristics as their uploaded originals. In each case, the source had AAC at 320 kbps and 48 kHz, for the 720p source and 128 kbps for all others. Notice from Table 1 that all versions stored at YouTube had audio that differed from this. As an exercise I also tried a 720p upload with the audio reduced to 38 kbps/48 kHz. It was re-encoded to 192 kbps, 44.1 kHz, etc, as shown in the Table.

5. Quality
The best outcome for the MP4 uploads at 480p were their 480p FLV versions stored in YouTube. The results for originals done at 1000, 2500 and 5000 kbps (video) were downloaded and examined in VLC. I could not spot any differences between them while being played at Full-screen. However, when stepping frame by frame through fast action sequences, there was a slight difference, with that created at 1000 kbps being a little less clear! The clips done at 2500 and 5000 kbps were a little better and much the same quality as the original MP4 that had been uploaded. As far as I could judge.
Hence, if a source file done at 480p is uploaded to YouTube and watched in a browser, an original bitrate of 1000 kbps would be sufficient unless zoomed to Full screen. Then, 2500 kbps would have been a better choice and, possibly, 5000 kbps may give a marginally better outcome. A similar outcome was found for the 720p files.
Thus, the video bitrate set in MediaCoder has little effect on the versions uploaded to YouTube and the decision as to what bitrate to choose depends on how the YouTube versions are to be viewed and the judgement of quality would be personal.
It is subjective: it’s up to you!
Have you checked out the Tips & Guides for MediaCoder? Try:
Also, get older builds at:

Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Re: MediaCoder for YouTube

Post by meRobs » Fri Feb 15, 2013 1:09 am

The above post is now listed as a Guide under Tips & Guides (link below).
As such, if anyone finds an error or fault with what was stated, please let me know by raising a separate topic that refers to this one.
ALso, any constructive comments would be helpful to others.
Have you checked out the Tips & Guides for MediaCoder? Try:
Also, get older builds at: