<p>YouTube will re-encode whatever you give it. VP9 is currently too slow to encode. So the best choice is to either:</p>

<ul>
<li><p>Give it the original footage, or if it is not accepted by YouTube or is too big to upload, then...</p></li>
<li><p>Re-encode to H.264</p></li>
</ul>

<h1><code>ffmpeg</code></h1>

<p><code>ffmpeg</code> will accept just about any input and will provide a great quality output. Development is very active, so it is best to use a recent build which you can <a href="https://ffmpeg.org/download.html">download</a> for Windows, OS X, or Linux.</p>

<h2>Example commands</h2>

<h3>Encode H.264 video, <a href="https://ffmpeg.org/ffmpeg.html#Stream-copy">stream copy</a> audio, in Matroska container:</h3>

<pre><code>ffmpeg -i input.avi -c:v libx264 -preset medium -crf 18 -c:a copy output.mkv
</code></pre>

<h3>Encode H.264 video, Vorbis audio, in Matroska container:</h3>

<pre><code>ffmpeg -i input.avi -c:v libx264 -preset medium -crf 18 -c:a libvorbis -q:a 5 output.mkv
</code></pre>

<ul>
<li><p><code>-crf 18</code> is considered to be roughly visually lossless. The range is a log scale from 0-51. 0 is lossless (huge files), 23 is default.</p></li>
<li><p><code>-preset</code> controls the encoding efficiency, and therefore affects the encoding speed. Generally it is recommended to use the slowest preset you have patience for, or if in doubt just use <code>medium</code> (the default). Choices are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow.</p></li>
<li><p>Your player may not like the output, but YouTube will. If that is the case then just use a sane player such as VLC.</p></li>
</ul>

<h1>Also see</h1>

<ul>
<li><a href="https://trac.ffmpeg.org/wiki/Encode/H.264">FFmpeg Wiki: H.264 Video Encoding Guide</a></li>
<li><a href="https://trac.ffmpeg.org/wiki/Encode/YouTube">FFmpeg Wiki: How to Encode Videos for YouTube and other Video Sharing Sites</a></li>
</ul>

CC BY-SA 3.0
2015-09-05T07:11:32.937Z
2015-09-05T07:11:32.937Z
llogan
<p>Most of these answers are outdated. Youtube actually re-encodes our videos into VP9 making HD videos look rather better in terms of quality. Its only when you upload the video in its original encoding that looks degraded based on compression. It can take a day or a week for youtube to re-encode our HD videos to Vp9. I'm a youtuber myself and can really see the difference</p>

CC BY-SA 3.0
2017-02-15T16:17:52.820Z
"Its only when you upload the video in its original encoding that looks degraded based on compression. It can take a day or a week for youtube to re-encode our HD videos to Vp9." I suspect this is something YouTube would publish. Can you provide a source?
user3643
CC BY-SA 4.0
2021-03-09T02:00:51.943Z
Not as outdated as you'd think. For reasons that boggle the mind, YouTube *still* recommends uploading in h264.
Hashim Aziz
CC BY-SA 3.0
2017-02-14T22:44:28.280Z
2017-02-14T22:44:28.280Z
Logical Guy
<p><strong>tl;dr:</strong> Since Youtube reencodes all videos regardless of the upload format, it really isn't that important. Just export your video with a high bitrate to preserve quality. Also see <a href="https://video.stackexchange.com/a/15815/6273">my answer here</a> regarding quality loss caused by Youtube.</p>

<p><strong>Long answer:</strong> Each reencoding of a video to a compressed format lowers the quality. Usually, that means you'll lose quality at two points: When you export the edited video from your editing software and when you upload the exported video to Youtube, at which point it is reencoded to a highly compressed, streaming-compatible format. You have no control over that second step, so what you can do to achieve the maximum quality possible is make sure you lose as little quality as possible during the first encoding.<br>
In theory, that would mean export to a <em>perceptually</em> (even though technically not) uncompressed format like Apple ProRes or DNxHD as you suggested. However, unfortunately, <a href="https://support.google.com/youtube/troubleshooter/2888402?hl=en" rel="nofollow noreferrer">Youtube doesn't support those formats</a>, so you'll have to use a compressed format. To minimize quality loss, set a high bitrate in your export settings (assuming rendering and upload time aren't an issue. If they are, you'll have to find some middle ground; exporting with a bitrate that is higher than the bitrate of the source material won't yield any more quality, so that is as high as I would go). If you do that, it doesn't really matter which codec you use, both are highly efficient regarding file-size/quality ratio (VP9 probably a bit more so, but that's more important when you're dealing with low bitrates). <a href="https://support.google.com/youtube/answer/1722171" rel="nofollow noreferrer">Youtube recommends H264</a>, so that's what I would use. However, the best advice I can give you is to try out both, i.e. export the same video as both H264 and VP9 with identical bitrates/other settings, upload both to youtube and check which one looks better to you.</p>

CC BY-SA 3.0
2015-09-05T06:51:00.130Z
ProRes and DNxHD are not uncompressed, but are both lossy, compressed formats. However, they are both generally considered to be *perceptually* lossless.
llogan
CC BY-SA 3.0
2015-09-05T12:02:24.943Z
Oops, you're right, thanks! I'll correct that right away.
MoritzLost
CC BY-SA 3.0
2015-09-04T20:35:00.383Z
2015-09-10T18:27:13.393Z
2017-04-13T12:46:08.110Z
MoritzLost
<p>I make short films which I distribute through YouTube. I know YouTube uses VP9 for streaming, but YouTube still recommends uploading with h.264. It makes more sense to me to upload in as similar a format as will be streamed by YouTube, but I might be missing something.</p>

<p>Also, would uploading in a higher quality codec like DNxHR or Prores (I'm not concerned about bandwidth or processing time) better preserve video quality after YouTube's encoding?</p>

CC BY-SA 4.0
2018-09-30T04:31:08.260Z
It seems YouTube encodes videos also to H.264. You could stream those videos in Google Chrome, if you use h264ify extension.
jarno
<encoding><youtube><h.264><prores><vp9>
H.264 or VP9 for encoding for YouTube?
KC McLaughlin
# H.264 or VP9 for encoding for YouTube?

(Asked by: username_0 on 2015-09-04)

I make short films which I distribute through YouTube. I know YouTube uses VP9 for streaming, but YouTube still recommends uploading with h.264. It makes more sense to me to upload in as similar a format as will be streamed by YouTube, but I might be missing something.

Also, would uploading in a higher quality codec like DNxHR or Prores (I'm not concerned about bandwidth or processing time) better preserve video quality after YouTube's encoding?

**Tags:** encoding, youtube, h.264, prores, vp9

> **Comments:**
> **username_1**: It seems YouTube encodes videos also to H.264. You could stream those videos in Google Chrome, if you use h264ify extension.  

---

## 3 answers

### Answer by username_6 on 2015-09-04. Score: 13 | Accepted answer

**tl;dr:** Since Youtube reencodes all videos regardless of the upload format, it really isn't that important. Just export your video with a high bitrate to preserve quality. Also see [my answer here](https://video.stackexchange.com/a/15815/6273) regarding quality loss caused by Youtube.

**Long answer:** Each reencoding of a video to a compressed format lowers the quality. Usually, that means you'll lose quality at two points: When you export the edited video from your editing software and when you upload the exported video to Youtube, at which point it is reencoded to a highly compressed, streaming-compatible format. You have no control over that second step, so what you can do to achieve the maximum quality possible is make sure you lose as little quality as possible during the first encoding.  
In theory, that would mean export to a *perceptually* (even though technically not) uncompressed format like Apple ProRes or DNxHD as you suggested. However, unfortunately, [Youtube doesn't support those formats](https://support.google.com/youtube/troubleshooter/2888402?hl=en), so you'll have to use a compressed format. To minimize quality loss, set a high bitrate in your export settings (assuming rendering and upload time aren't an issue. If they are, you'll have to find some middle ground; exporting with a bitrate that is higher than the bitrate of the source material won't yield any more quality, so that is as high as I would go). If you do that, it doesn't really matter which codec you use, both are highly efficient regarding file-size/quality ratio (VP9 probably a bit more so, but that's more important when you're dealing with low bitrates). [Youtube recommends H264](https://support.google.com/youtube/answer/1722171), so that's what I would use. However, the best advice I can give you is to try out both, i.e. export the same video as both H264 and VP9 with identical bitrates/other settings, upload both to youtube and check which one looks better to you.

> **Comments:**
> **username_2**: ProRes and DNxHD are not uncompressed, but are both lossy, compressed formats. However, they are both generally considered to be *perceptually* lossless.  
> **username_6**: Oops, you're right, thanks! I'll correct that right away.  

---

### Answer by username_2 on 2015-09-05. Score: 7

YouTube will re-encode whatever you give it. VP9 is currently too slow to encode. So the best choice is to either:

Give it the original footage, or if it is not accepted by YouTube or is too big to upload, then...
Re-encode to H.264

ffmpeg
ffmpeg will accept just about any input and will provide a great quality output. Development is very active, so it is best to use a recent build which you can download for Windows, OS X, or Linux.
Example commands
Encode H.264 video, stream copy audio, in Matroska container:
ffmpeg -i input.avi -c:v libx264 -preset medium -crf 18 -c:a copy output.mkv

Encode H.264 video, Vorbis audio, in Matroska container:
ffmpeg -i input.avi -c:v libx264 -preset medium -crf 18 -c:a libvorbis -q:a 5 output.mkv


-crf 18 is considered to be roughly visually lossless. The range is a log scale from 0-51. 0 is lossless (huge files), 23 is default.
-preset controls the encoding efficiency, and therefore affects the encoding speed. Generally it is recommended to use the slowest preset you have patience for, or if in doubt just use medium (the default). Choices are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow.
Your player may not like the output, but YouTube will. If that is the case then just use a sane player such as VLC.

Also see

FFmpeg Wiki: H.264 Video Encoding Guide
FFmpeg Wiki: How to Encode Videos for YouTube and other Video Sharing Sites


---

### Answer by username_3 on 2017-02-14. Score: 0

Most of these answers are outdated. Youtube actually re-encodes our videos into VP9 making HD videos look rather better in terms of quality. Its only when you upload the video in its original encoding that looks degraded based on compression. It can take a day or a week for youtube to re-encode our HD videos to Vp9. I'm a youtuber myself and can really see the difference

> **Comments:**
> **username_4**: "Its only when you upload the video in its original encoding that looks degraded based on compression. It can take a day or a week for youtube to re-encode our HD videos to Vp9." I suspect this is something YouTube would publish. Can you provide a source?  
> **username_5**: Not as outdated as you'd think. For reasons that boggle the mind, YouTube *still* recommends uploading in h264.  

---

