<p><strong>Some general info about the formats used:</strong></p>
<p>YouTube uses 4 container formats and 4 different codecs. It depends on the popularity of the video what codecs are used for your video (see below why). Generally, every of your uploaded videos will be encoded in h.264 and will be muxed into an .flv and .mp4 container. That's the standard and this will happen for every video. Though .flv will only be used for resolutions below 720p. Meaning only 360p and 480p will exist in an .flv container. Though every video below 720p will also have a mp4 version available. For 240p YouTube is also using 3gp which is a rather old codec (based on MPEG-4 Part 2 (not to be confused with MPEG4 Part 10 aka h.264) meant for mobile devices (long before the smartphone era), it comes in the container .3gpp.</p>
<p>The other codec used is VP8 which is coming in the WebM container format. WebM is a format developed by Google and was meant as a standard video codec for HTML5, support for it is by now pretty good in most modern browsers.
WebM was introduced with the HTML5 version of YouTube. YouTube only encodes some videos in WebM after they got uploaded and mostly only popular videos (going by the videos I saw encoded in WebM) so it's not certain your video will be present in WebM. Though this is changing with WebM gaining some more support.</p>
<p>YouTube also supports VP8/VP9 in the WebM container. This is supported by all major browsers for several years now. With WebM, they also introduced support for the Opus audio codec (besides AAC which is used in all other containers).</p>
<p>In regard of your linked question (maybe they should be merged?)</p>
<p><strong>What codec/container should you use for uploading?</strong></p>
<p>That depends, if you are limited/concerned by your upload speed then use h.264 Level 3.1/4.1 with Main Profile for SD or High Profile for HD. YouTube will accept this just fine and it will look nice after it got encoded by the YouTube servers. I would usually recommend a bitrate of ~4-5 Mbit/s for 720p material and ~8-9 Mbit/s for 1080p. For 4k go for ~15-25Mbit/s or more depending on the complexity of the footage. &quot;Cartoon&quot; content with few colours can usually have a much lower bitrate in general.
This is usually a good balance between size and quality. If you want better quality go with a higher bitrate, and if you want a smaller video go with a lower bitrate.</p>
<p>But be aware that YouTube will ALWAYS encode your video once it's uploaded, doesn't matter what codec and settings you use. So if you want the theoretically best quality for your uploads, choose a lossless codec for uploading or at least visually lossless.
See YouTube as the final output into a delivery/consumer format and the upload to YouTube is the last step in production and during production you want to stay lossless.
But please note this is all just a theoretical thing, practically I'd say it really doesn't matter as we are talking about YouTube and not about TV broadcast or Cinema. In almost all cases a very high bitrate h264 encode (20-40mbit/s) will suffice even for high-end content.</p>
<p>But if you really want to do it the &quot;perfect&quot; way, use a production codec and not a consumer codec like h.264.
MJPEG would be a good codec for that, YouTube definitely supports that in an .avi or .mov container. MJPEG is a lossy codec but the visual quality will be the same as the source (if you chose a high enough quality setting, this is practically JPEG as the video codec).
Going with a real lossless codec would be a waste of hard-drive space and bandwidth in my opinion.</p>
<p>But if you want to upload your video truly lossless and don't care about the upload time, I recommend using a standard QuickTime codec as they should be nearly all supported by YouTube (note that not all of them are lossless, h264 is also a standard QuickTime codec). Though YouTube doesn't state which QuickTime codecs are supported, unfortunately. Animation or JPEG2000 should work I guess. Both codecs can be 100% lossless depending on settings in case of JPEG2000.</p>
<p>When it comes to frame rates, if you can choose then use 25FPS or 30FPS  during recording/animating (by now YouTube also supports 50 and 60FPS+ video, so use that if your content benefits from a higher framerate), YouTube likes standard framerates like 25 or 30FPS the most (or again one of the higher FPS options) but if your footage comes already in another frame rate like 24FPS then stick with that and don't interpolate up or down. YouTube will handle the conversion for you and generally does that better then your average encoder. They have to deal with all kind of framerates every day and solved this (actually very complicated) issue really well.</p>
<p><strong>Audio:</strong></p>
<p>For the audio use PCM if you want to stay lossless with the audio as well but again this is really just a theoretical quality improvement. AAC will usually do the same job quality wise (subjective) and will be smaller. I recommend a bitrate of at 128-192kbps for AAC. The size impact is usually not as big as the video codec so you can also just go with 192kbps or higher if you feel your audio content is very sensitive. YouTube will convert audio to ~24kbps(Mobile aka 3gp) ~64kbps(240p), ~128kbps(360p/480p) and ~192kbps(720p+) using the AAC and Opus (WebM only) codec.</p>

CC BY-SA 3.0
2013-02-17T14:11:23.650Z
I agree to this answer. But there is a practical limit: the upload speed. How much time are you allowing for an upload? A whole weekend, a night, or a couple of hours until the end of your working day.

I myself put the limit to 2 GB for 10 minutes of video, which needs around 4 hours of upload time in my case. But is this really restricting the quality? My 2 GB video has a bit rate of 30 Mbit/s, which YouTube converts to 3 Mbit/s. A lossless encoding would multiply the upload time, but the YouTube output would still be at 3 Mbit/s.

Please set your personal limits by yourself.
Fred42vid
CC BY-SA 3.0
2013-02-17T15:20:03.317Z
Sure thats why I made it (hopefully) quite clear that its theoretical and in no way practical. H.264 is to be recommended for almost all cases.
The only actual practical usecase for MJPEG I can think of is when color banding occours with the first h.264 encode which will get worse with the second encode from YouTube.
timonsku
CC BY-SA 3.0
2015-01-15T11:30:31.710Z
Youtube support h.264 high profile, so you should use it always.  Main profile for SD content is silly.  Leaving out 8x8dct is always a bad idea.  In x264, enabling 8x8dct is the most efficient tradeoff of CPU time for better quality per file-size (aka rate:distortion or RD).
Peter Cordes
CC BY-SA 3.0
2015-01-15T11:33:48.903Z
H.264 will look a lot better at the same bitrate than MJPEG.  If you want better quality, just turn up the bitrate (or the quality setting in constant-quality instead of target bitrate mode).  You can go all the way to lossless h.264 if you don't mind uploading a huge file.  It will probably be smaller than lossless j2k.  Both are perfect quality, though, since that's what lossless means.
Peter Cordes
CC BY-SA 3.0
2015-01-15T11:35:33.103Z
For audio, IDK if youtube supports FLAC or not.  If so, that would be your go-to choice for lossless.  Otherwise yeah, high bitrate AAC made with a good encoder.  (`-c:a libfdk-aac`, not the default `faac` or builtin `aac` encoders in ffmpeg.)
Peter Cordes
CC BY-SA 4.0
2012-12-30T19:51:51.187Z
2020-09-29T16:20:42.743Z
2020-09-29T16:20:42.743Z
timonsku
<p>Your question is "How does YouTube encode my uploads and what codec should I use to upload?".</p>

<p>Digging deeper into your question I see: "Should I adjust my own encoding to "play nice" with Youtube's codec, or does it matter, quality-wise? I know I can throw pretty much anything on Youtube and it will take it, so I'm mostly concerned with video quality.".</p>

<p>The answer is YouTube uses Lavf57.25.100 to encode new Videos while Videos over a few years old were encoded with a proprietary Encoder (that doesn't have "Lavf57.25.100" embedded in it's ID but instead has this sentence: "IsoMedia File Produced by Google, 5-11-2011"). The old Videos were not reencoded when the Algorithm was changed.</p>

<p>It is acceptable to use many different Codecs, YouTube recommendeds H.264 - see here: <a href="https://support.google.com/youtube/answer/1722171?hl=en" rel="nofollow noreferrer">https://support.google.com/youtube/answer/1722171?hl=en</a> .</p>

<p>For some reason you choose not to ask about the Container (which isn't the same thing as a Codec). You also assume that 1080P is going to be available and don't ask about the most important thing - Bitrate (followed by Resolution).</p>

<p>If you upload a 1080P Resolution Video at 60FPS then the maximum Resolution available is 720P (at 60 FPS, on a Mobile Device, capable of 1080P), uploading a 1080P Video at 29.97 FPS permits 1080P viewing on a Mobile Device.</p>

<p>What IS important is Bitrate and Resolution if "quality" is your goal. You can't upscale or use lossless to cheat since YouTube runs a 'Compression Test' to determine how much they can crush your Video with minimal degradation - upload mush and it will be highly compressed mush, upload high Resolution and high Bitrate, then YouTube will back off on the crushing, and deliver a much better viewing experience.</p>

<p>See: <a href="https://support.google.com/youtube/answer/1722171?hl=en" rel="nofollow noreferrer">https://support.google.com/youtube/answer/1722171?hl=en</a> .</p>

<p>Notice that different Resolutions and 'Quality Expectations'. For 4K Video with low expectations you can upload Videos that have a Bitrate of 35-45 Mbps but if you're a "Producer" and quality is your goal you need both a higher Framerate and to use at least 66-85 Mbps for the Camera Bitrate (before you compress it very gently).</p>

<p>If you upscale a low Resolution Video and use an uncompressed Codec hoping to get the finest quality possible you'll be caught (and reduced to mush).</p>

<p>Record using a Production Quality Camera, high Framerate and Bitrate Video, very gently compressed (Ffmpeg Q=&lt;10) to get the best results - the "Codec" (your words) is not the sole determining factor (though I'd advise against an old one).</p>

<p>Ffmpeg supports .MP4 Containers and the H.264 Codec, so use those. </p>

<p>People often complain that YouTube ruins their Videos, the problem is that they didn't upload high enough quality in the first place to 'trip the switch' and cause YouTube's Compressor to tread gently upon your Upload. Pixel-peeking perfect Videos are possible. The GIGO Rule applies. </p>

CC BY-SA 4.0
2021-02-22T09:31:35.150Z
Thanks for the official "Recommended upload encoding settings" [link](https://support.google.com/youtube/answer/1722171?hl=en), that directly answers the "what codec should I use to upload?" part!
Klesun
CC BY-SA 4.0
2024-07-08T21:19:22.550Z
What is known about what YouTube does during the 'Compression Test', i.e. what encoder settings it tries and how it computes whether results are acceptable? That probably can be reverse engineered by uploading different videos and checking the encoded results. Have you come across such an analysis/info?
root
CC BY-SA 3.0
2017-06-23T03:37:05.557Z
2017-06-23T03:37:05.557Z
Rob
<p>They are Encoded with Lavf57.25.100 .</p>

<p>This is one of a few conflicting Help Pages that contains better Info than some of the others: <a href="https://support.google.com/youtube/answer/6039860?hl=en" rel="nofollow noreferrer">https://support.google.com/youtube/answer/6039860?hl=en</a></p>

CC BY-SA 3.0
2017-03-12T01:56:58.647Z
2017-03-12T01:56:58.647Z
Rob
<p>Related to <a href="https://video.stackexchange.com/questions/5317/what-codecs-formats-are-appropriate-for-full-motion-video-recording-for-youtube">What codecs/formats are appropriate for full motion video recording for youtube?</a> I'm wondering exactly how I can expect Youtube to handle my videos. I know they have a rather zealous processing set up that generates multiple copies of my upload at different resolutions; 1080p, 720p and 480p and apparently a mobile one, at the very least.</p>

<p>What codec(s) do they use? As a producer I have an option to download the file as an MP4; however I note a third party downloader (which is extremely shady and crappy) brings the files down as FLV. I'm basically wondering if my codec is going to be preserved or overwritten with H.264 or whatever they use. Considering their amazing compatibility across devices I assume they either use a very common standard or multiple codecs for each video.</p>

<p>So what codec can I expect my videos to be output in, and if it depends, what does it depend on? Should I adjust my own encoding to "play nice" with Youtube's codec, or does it matter, quality-wise? I know I can throw pretty much anything on Youtube and it will take it, so I'm mostly concerned with video quality.</p>

CC BY-SA 3.0
2016-01-24T13:41:42.990Z
here's a tool to see available formats for a video: http://www.h3xed.com/web-and-internet/youtube-audio-quality-bitrate-240p-360p-480p-720p-1080p
akostadinov
<video><codec><youtube>
How does YouTube encode my uploads and what codec should I use to upload?
Zelda
# How does YouTube encode my uploads and what codec should I use to upload?

(Asked by: username_0 on 2012-11-13)

Related to [What codecs/formats are appropriate for full motion video recording for youtube?](https://video.stackexchange.com/questions/5317/what-codecs-formats-are-appropriate-for-full-motion-video-recording-for-youtube) I'm wondering exactly how I can expect Youtube to handle my videos. I know they have a rather zealous processing set up that generates multiple copies of my upload at different resolutions; 1080p, 720p and 480p and apparently a mobile one, at the very least.

What codec(s) do they use? As a producer I have an option to download the file as an MP4; however I note a third party downloader (which is extremely shady and crappy) brings the files down as FLV. I'm basically wondering if my codec is going to be preserved or overwritten with H.264 or whatever they use. Considering their amazing compatibility across devices I assume they either use a very common standard or multiple codecs for each video.

So what codec can I expect my videos to be output in, and if it depends, what does it depend on? Should I adjust my own encoding to "play nice" with Youtube's codec, or does it matter, quality-wise? I know I can throw pretty much anything on Youtube and it will take it, so I'm mostly concerned with video quality.

**Tags:** video, codec, youtube

> **Comments:**
> **username_1**: here's a tool to see available formats for a video: http://www.h3xed.com/web-and-internet/youtube-audio-quality-bitrate-240p-360p-480p-720p-1080p  

---

## 3 answers

### Answer by username_2 on 2012-12-30. Score: 36

**Some general info about the formats used:**

YouTube uses 4 container formats and 4 different codecs. It depends on the popularity of the video what codecs are used for your video (see below why). Generally, every of your uploaded videos will be encoded in h.264 and will be muxed into an .flv and .mp4 container. That's the standard and this will happen for every video. Though .flv will only be used for resolutions below 720p. Meaning only 360p and 480p will exist in an .flv container. Though every video below 720p will also have a mp4 version available. For 240p YouTube is also using 3gp which is a rather old codec (based on MPEG-4 Part 2 (not to be confused with MPEG4 Part 10 aka h.264) meant for mobile devices (long before the smartphone era), it comes in the container .3gpp.

The other codec used is VP8 which is coming in the WebM container format. WebM is a format developed by Google and was meant as a standard video codec for HTML5, support for it is by now pretty good in most modern browsers.
WebM was introduced with the HTML5 version of YouTube. YouTube only encodes some videos in WebM after they got uploaded and mostly only popular videos (going by the videos I saw encoded in WebM) so it's not certain your video will be present in WebM. Though this is changing with WebM gaining some more support.

YouTube also supports VP8/VP9 in the WebM container. This is supported by all major browsers for several years now. With WebM, they also introduced support for the Opus audio codec (besides AAC which is used in all other containers).

In regard of your linked question (maybe they should be merged?)

**What codec/container should you use for uploading?**

That depends, if you are limited/concerned by your upload speed then use h.264 Level 3.1/4.1 with Main Profile for SD or High Profile for HD. YouTube will accept this just fine and it will look nice after it got encoded by the YouTube servers. I would usually recommend a bitrate of ~4-5 Mbit/s for 720p material and ~8-9 Mbit/s for 1080p. For 4k go for ~15-25Mbit/s or more depending on the complexity of the footage. "Cartoon" content with few colours can usually have a much lower bitrate in general.
This is usually a good balance between size and quality. If you want better quality go with a higher bitrate, and if you want a smaller video go with a lower bitrate.

But be aware that YouTube will ALWAYS encode your video once it's uploaded, doesn't matter what codec and settings you use. So if you want the theoretically best quality for your uploads, choose a lossless codec for uploading or at least visually lossless.
See YouTube as the final output into a delivery/consumer format and the upload to YouTube is the last step in production and during production you want to stay lossless.
But please note this is all just a theoretical thing, practically I'd say it really doesn't matter as we are talking about YouTube and not about TV broadcast or Cinema. In almost all cases a very high bitrate h264 encode (20-40mbit/s) will suffice even for high-end content.

But if you really want to do it the "perfect" way, use a production codec and not a consumer codec like h.264.
MJPEG would be a good codec for that, YouTube definitely supports that in an .avi or .mov container. MJPEG is a lossy codec but the visual quality will be the same as the source (if you chose a high enough quality setting, this is practically JPEG as the video codec).
Going with a real lossless codec would be a waste of hard-drive space and bandwidth in my opinion.

But if you want to upload your video truly lossless and don't care about the upload time, I recommend using a standard QuickTime codec as they should be nearly all supported by YouTube (note that not all of them are lossless, h264 is also a standard QuickTime codec). Though YouTube doesn't state which QuickTime codecs are supported, unfortunately. Animation or JPEG2000 should work I guess. Both codecs can be 100% lossless depending on settings in case of JPEG2000.

When it comes to frame rates, if you can choose then use 25FPS or 30FPS during recording/animating (by now YouTube also supports 50 and 60FPS+ video, so use that if your content benefits from a higher framerate), YouTube likes standard framerates like 25 or 30FPS the most (or again one of the higher FPS options) but if your footage comes already in another frame rate like 24FPS then stick with that and don't interpolate up or down. YouTube will handle the conversion for you and generally does that better then your average encoder. They have to deal with all kind of framerates every day and solved this (actually very complicated) issue really well.

**Audio:**

For the audio use PCM if you want to stay lossless with the audio as well but again this is really just a theoretical quality improvement. AAC will usually do the same job quality wise (subjective) and will be smaller. I recommend a bitrate of at 128-192kbps for AAC. The size impact is usually not as big as the video codec so you can also just go with 192kbps or higher if you feel your audio content is very sensitive. YouTube will convert audio to ~24kbps(Mobile aka 3gp) ~64kbps(240p), ~128kbps(360p/480p) and ~192kbps(720p+) using the AAC and Opus (WebM only) codec.

> **Comments:**
> **username_3**: I agree to this answer. But there is a practical limit: the upload speed. How much time are you allowing for an upload? A whole weekend, a night, or a couple of hours until the end of your working day.  I myself put the limit to 2 GB for 10 minutes of video, which needs around 4 hours of upload time in my case. But is this really restricting the quality? My 2 GB video has a bit rate of 30 Mbit/s, which YouTube converts to 3 Mbit/s. A lossless encoding would multiply the upload time, but the YouTube output would still be at 3 Mbit/s.  Please set your personal limits by yourself.  
> **username_2**: Sure thats why I made it (hopefully) quite clear that its theoretical and in no way practical. H.264 is to be recommended for almost all cases. The only actual practical usecase for MJPEG I can think of is when color banding occours with the first h.264 encode which will get worse with the second encode from YouTube.  
> **username_4**: Youtube support h.264 high profile, so you should use it always.  Main profile for SD content is silly.  Leaving out 8x8dct is always a bad idea.  In x264, enabling 8x8dct is the most efficient tradeoff of CPU time for better quality per file-size (aka rate:distortion or RD).  
> **username_4**: H.264 will look a lot better at the same bitrate than MJPEG.  If you want better quality, just turn up the bitrate (or the quality setting in constant-quality instead of target bitrate mode).  You can go all the way to lossless h.264 if you don't mind uploading a huge file.  It will probably be smaller than lossless j2k.  Both are perfect quality, though, since that's what lossless means.  
> **username_4**: For audio, IDK if youtube supports FLAC or not.  If so, that would be your go-to choice for lossless.  Otherwise yeah, high bitrate AAC made with a good encoder.  (`-c:a libfdk-aac`, not the default `faac` or builtin `aac` encoders in ffmpeg.)  

---

### Answer by username_5 on 2017-06-23. Score: 3

Your question is "How does YouTube encode my uploads and what codec should I use to upload?".

Digging deeper into your question I see: "Should I adjust my own encoding to "play nice" with Youtube's codec, or does it matter, quality-wise? I know I can throw pretty much anything on Youtube and it will take it, so I'm mostly concerned with video quality.".

The answer is YouTube uses Lavf57.25.100 to encode new Videos while Videos over a few years old were encoded with a proprietary Encoder (that doesn't have "Lavf57.25.100" embedded in it's ID but instead has this sentence: "IsoMedia File Produced by Google, 5-11-2011"). The old Videos were not reencoded when the Algorithm was changed.

It is acceptable to use many different Codecs, YouTube recommendeds H.264 - see here: <https://support.google.com/youtube/answer/1722171?hl=en> .

For some reason you choose not to ask about the Container (which isn't the same thing as a Codec). You also assume that 1080P is going to be available and don't ask about the most important thing - Bitrate (followed by Resolution).

If you upload a 1080P Resolution Video at 60FPS then the maximum Resolution available is 720P (at 60 FPS, on a Mobile Device, capable of 1080P), uploading a 1080P Video at 29.97 FPS permits 1080P viewing on a Mobile Device.

What IS important is Bitrate and Resolution if "quality" is your goal. You can't upscale or use lossless to cheat since YouTube runs a 'Compression Test' to determine how much they can crush your Video with minimal degradation - upload mush and it will be highly compressed mush, upload high Resolution and high Bitrate, then YouTube will back off on the crushing, and deliver a much better viewing experience.

See: <https://support.google.com/youtube/answer/1722171?hl=en> .

Notice that different Resolutions and 'Quality Expectations'. For 4K Video with low expectations you can upload Videos that have a Bitrate of 35-45 Mbps but if you're a "Producer" and quality is your goal you need both a higher Framerate and to use at least 66-85 Mbps for the Camera Bitrate (before you compress it very gently).

If you upscale a low Resolution Video and use an uncompressed Codec hoping to get the finest quality possible you'll be caught (and reduced to mush).

Record using a Production Quality Camera, high Framerate and Bitrate Video, very gently compressed (Ffmpeg Q=<10) to get the best results - the "Codec" (your words) is not the sole determining factor (though I'd advise against an old one).

Ffmpeg supports .MP4 Containers and the H.264 Codec, so use those.

People often complain that YouTube ruins their Videos, the problem is that they didn't upload high enough quality in the first place to 'trip the switch' and cause YouTube's Compressor to tread gently upon your Upload. Pixel-peeking perfect Videos are possible. The GIGO Rule applies.

> **Comments:**
> **username_6**: Thanks for the official "Recommended upload encoding settings" [link](https://support.google.com/youtube/answer/1722171?hl=en), that directly answers the "what codec should I use to upload?" part!  
> **username_7**: What is known about what YouTube does during the 'Compression Test', i.e. what encoder settings it tries and how it computes whether results are acceptable? That probably can be reverse engineered by uploading different videos and checking the encoded results. Have you come across such an analysis/info?  

---

### Answer by username_5 on 2017-03-12. Score: 1

They are Encoded with Lavf57.25.100 .

This is one of a few conflicting Help Pages that contains better Info than some of the others: <https://support.google.com/youtube/answer/6039860?hl=en>


---

