<p>Use it. Nothing else can provide the the same quality per bitrate as x264 (the top-class H.264 encoder) while not taking 10,000 years to encode (x265 'n VP9).</p>

<p>Some tips:</p>

<ul>
<li><p>Use a recent <code>ffmpeg</code> build since development is so active. <a href="http://johnvansickle.com/ffmpeg/">Static builds</a> are available and easy.</p></li>
<li><p>Add <code>-movflags +faststart</code> to your command. Once encoding is finished this option will relocate the <code>moov</code> atom to the beginning of the file allowing playback to begin for your viewer before the file is completely downloaded.</p></li>
<li><p>Because <code>ffmpeg</code> attempts to avoid chroma subsampling using <code>-pix_fmt yuv420p</code> is recommended to ensure a widely compatible pixel format.</p></li>
<li><p>Some devices may require you to use a more restrictive profile and level. You can do this with the <code>-profile:v</code> and <code>-level</code> options. Be aware of attempting to force a specific level on outputs that will not conform (such as trying to force <code>-level 3</code> on a 1920x1080 video). <code>ffmpeg</code> will give <em>level limit</em> warnings in the console output if this is the case.</p></li>
<li><p>See the <a href="https://trac.ffmpeg.org/wiki/Encode/H.264">H.264</a> and <a href="https://trac.ffmpeg.org/wiki/Encode/AAC">AAC</a> encoding guides for more info.</p></li>
</ul>

CC BY-SA 3.0
2015-02-18T05:59:48.840Z
Very informative! Thank you. I can't accept the answer as it does not state much regarding my question, but I have vote your answer. Thank you again for such an informative answer!
Robin
CC BY-SA 4.0
2018-06-13T23:13:49.190Z
VP9 does required 10,000 years to encode , while x265 able to do `mealtime encoding` even on my weak VPS `for SD format` which is impossible with `VP9`
Salem F
CC BY-SA 4.0
2018-06-13T23:33:33.993Z
@SalemF Looks like x265 may have gotten faster since this answer was written. I'll have to give it a try and maybe update this answer. Now there is an even slower newcomer, AV1, which when stable will put the others to shame in this slow race.
llogan
CC BY-SA 4.0
2018-06-13T23:49:49.067Z
`Offtopic` can you take look at my question [here](https://video.stackexchange.com/q/24278/22348) as it on of HEVC downside it's harder to create live broadcast using current tools 'that's mostly support H264 with FLV container'
Salem F
CC BY-SA 3.0
2015-02-16T03:44:42.563Z
2015-02-16T03:44:42.563Z
llogan
<p>If I am right, HTML5 supports H.264 codec with mp4 container. In this case the company which developed the browser has paid it's license.</p>

<p>You can also use video servers for VOD playing, like Wowza Streaming Engine.</p>

CC BY-SA 3.0
2015-02-16T03:49:47.270Z
That's not true. Although the software has paid a license, if you are charging viewers for the content and you go above the threshold for number of subscribers you owe MPEGLA royalty fees for using the codec.
stib
CC BY-SA 3.0
2015-02-15T21:09:36.360Z
2015-02-15T21:09:36.360Z
Pethő Jonatán
<p>You are correct: h.264 is non-free and content producers as well as developers are obliged to pay royalties to MPEGLA for its use - but <strong>only</strong> if they are charging for their content, <strong>and</strong> the volume goes over the threshold MPEGLA sets (which is in the order of 100,000 paying subscribers or > 12 minutes in length if charging title-by-title). Thjey have also said that they will <em>never</em> charge for h.264 video that is freely distributed.</p>

<p>See <a href="https://video.stackexchange.com/questions/14694/mp4-h-264-patent-issues/14699#14699">MP4 / h.264 patent issues?</a>
for more info.</p>

<p><strong>TL;DR</strong> if your video is free to view, then h.264 is free for you to use, and as @LordNeckbeard points out, it's a ripper of a codec, so knock yourself out.</p>

CC BY-SA 3.0
2015-02-18T06:01:18.173Z
Just to be more clear, it will be a video sharing website like keek or youtube, and I won't take any fees from the users, just will show ads. Therefore just to be on the safer side, following your answer, I don't have to pay even if my users are more that 100,000 right?
Robin
CC BY-SA 3.0
2015-02-18T06:13:09.863Z
Remember rhat my legal advice is worth all the money you're paying me. To be "on the safer side" I'd get a lawyer once your user base > 100,000. But there's links to the MPEGLA terms in the other question I mentioned, if you want to judge for yourself.
stib
CC BY-SA 3.0
2015-02-26T06:01:31.980Z
Yeah, I've seen people ask before if making money from adds still counts as free.  The consensus on the doom9.org thread was that it's fine, you only need to pay the MPEG-LA if you're requiring money for content.  (So I think even free but donation-supported would be ok.)
Peter Cordes
CC BY-SA 3.0
2015-02-16T03:59:54.280Z
2015-02-17T00:34:01.020Z
2017-04-13T12:46:08.110Z
stib
<p>I would like to use h.264 as the codec inside .mp4 container for my user uploaded videos for my website. But I saw somewhere that h.264 is non free. I am unsure whether I can use this technology or not. My question whether I can use it to compress my user uploaded videos in my website? If yes, then its great. And if no, what other solution can I go with? Thank you.</p>

<ffmpeg><h.264>
Can I use h.264 codec inside .mp4 container for my website
Robin
# Can I use h.264 codec inside .mp4 container for my website

(Asked by: username_0 on 2015-02-15)

I would like to use h.264 as the codec inside .mp4 container for my user uploaded videos for my website. But I saw somewhere that h.264 is non free. I am unsure whether I can use this technology or not. My question whether I can use it to compress my user uploaded videos in my website? If yes, then its great. And if no, what other solution can I go with? Thank you.

**Tags:** ffmpeg, h.264


---

## 3 answers

### Answer by username_4 on 2015-02-16. Score: 6 | Accepted answer

You are correct: h.264 is non-free and content producers as well as developers are obliged to pay royalties to MPEGLA for its use - but **only** if they are charging for their content, **and** the volume goes over the threshold MPEGLA sets (which is in the order of 100,000 paying subscribers or > 12 minutes in length if charging title-by-title). Thjey have also said that they will *never* charge for h.264 video that is freely distributed.

See [MP4 / h.264 patent issues?](https://video.stackexchange.com/questions/14694/mp4-h-264-patent-issues/14699#14699)
for more info.

**TL;DR** if your video is free to view, then h.264 is free for you to use, and as @LordNeckbeard points out, it's a ripper of a codec, so knock yourself out.

> **Comments:**
> **username_0**: Just to be more clear, it will be a video sharing website like keek or youtube, and I won't take any fees from the users, just will show ads. Therefore just to be on the safer side, following your answer, I don't have to pay even if my users are more that 100,000 right?  
> **username_4**: Remember rhat my legal advice is worth all the money you're paying me. To be "on the safer side" I'd get a lawyer once your user base > 100,000. But there's links to the MPEGLA terms in the other question I mentioned, if you want to judge for yourself.  
> **username_5**: Yeah, I've seen people ask before if making money from adds still counts as free.  The consensus on the doom9.org thread was that it's fine, you only need to pay the MPEG-LA if you're requiring money for content.  (So I think even free but donation-supported would be ok.)  

---

### Answer by username_1 on 2015-02-16. Score: 6

Use it. Nothing else can provide the the same quality per bitrate as x264 (the top-class H.264 encoder) while not taking 10,000 years to encode (x265 'n VP9).

Some tips:

* Use a recent `ffmpeg` build since development is so active. [Static builds](http://johnvansickle.com/ffmpeg/) are available and easy.
* Add `-movflags +faststart` to your command. Once encoding is finished this option will relocate the `moov` atom to the beginning of the file allowing playback to begin for your viewer before the file is completely downloaded.
* Because `ffmpeg` attempts to avoid chroma subsampling using `-pix_fmt yuv420p` is recommended to ensure a widely compatible pixel format.
* Some devices may require you to use a more restrictive profile and level. You can do this with the `-profile:v` and `-level` options. Be aware of attempting to force a specific level on outputs that will not conform (such as trying to force `-level 3` on a 1920x1080 video). `ffmpeg` will give *level limit* warnings in the console output if this is the case.
* See the [H.264](https://trac.ffmpeg.org/wiki/Encode/H.264) and [AAC](https://trac.ffmpeg.org/wiki/Encode/AAC) encoding guides for more info.

> **Comments:**
> **username_0**: Very informative! Thank you. I can't accept the answer as it does not state much regarding my question, but I have vote your answer. Thank you again for such an informative answer!  
> **username_2**: VP9 does required 10,000 years to encode , while x265 able to do `mealtime encoding` even on my weak VPS `for SD format` which is impossible with `VP9`  
> **username_1**: @SalemF Looks like x265 may have gotten faster since this answer was written. I'll have to give it a try and maybe update this answer. Now there is an even slower newcomer, AV1, which when stable will put the others to shame in this slow race.  
> **username_2**: `Offtopic` can you take look at my question [here](https://video.stackexchange.com/q/24278/22348) as it on of HEVC downside it's harder to create live broadcast using current tools 'that's mostly support H264 with FLV container'  

---

### Answer by username_3 on 2015-02-15. Score: 0

If I am right, HTML5 supports H.264 codec with mp4 container. In this case the company which developed the browser has paid it's license.

You can also use video servers for VOD playing, like Wowza Streaming Engine.

> **Comments:**
> **username_4**: That's not true. Although the software has paid a license, if you are charging viewers for the content and you go above the threshold for number of subscribers you owe MPEGLA royalty fees for using the codec.  

---

