user9328: 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.

user1760: 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 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 and AAC encoding guides for more info.


user1950: 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?
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.

9328: <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>
 1760: <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>
 1950: <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>
