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.
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.
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).
Use a recent
ffmpegbuild since development is so active. Static builds are available and easy.
-movflags +faststartto your command. Once encoding is finished this option will relocate the
moovatom to the beginning of the file allowing playback to begin for your viewer before the file is completely downloaded.
ffmpegattempts to avoid chroma subsampling using
-pix_fmt yuv420pis 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
-leveloptions. Be aware of attempting to force a specific level on outputs that will not conform (such as trying to force
-level 3on a 1920x1080 video).
ffmpegwill give level limit warnings in the console output if this is the case.
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.