Edit: I should probably remove some of the worrying conclusions about using x264 / ffmpeg that I now believe are unfounded. I put a section at the end to clear it up. For now I'm going to leave the whole mess here. Don't panic, x264 and ffh264 appear to be fine, legally, even for producing commercial videos at the standard royalty rates.
Just to clear up some terminology: mp4 (the container format) may be covered by some patents, but nobody charges license fees for software or content.
h.264, aka AVC aka MPEG-4 part10 is heavily patented, and software or hardware for encoding/decoding h.264 video streams needs a license from the MPEG Licensing Authority (MPEG LA). Content also needs a license. (free and automatic for content that's given away for free.)
h.265, aka HEVC (next gen video codec successor to h.264) has about the same patent licensing as h.264, also through the MPEG LA.
wikipedia says the MPEG LA also licenses MPEG2, VC-1, and for some reason IEEE-1394 (firewire).
AAC audio, aka MPEG-4 something something, also needs a license (from via licensing, not the MPEG LA) for implementations in software or hardware. IDK about AAC content.
To answer the question raised by epiclapser's comment about royalties for software / hardware that can create h.264 video, software that can create or decode h.264 needs a license for implementing the patented algorithms that are part of the codec. For commercial software, this is paid by the software authors / distributors to the MPEG LA, so it's legal for people to use the software they buy.
Most distributors of Free software, like x264 and ffmpeg, don't pay, so people that download x264 aren't legally allowed to use it without paying a patent royalty. People use it anyway without actually getting sued, as long as they're not a big target. For personal use, I don't think there's any reason to worry.
I haven't looked, but I haven't heard about anyone ever getting sued for using ffmpeg's h.264 decoder or x264's h.264 encoder. x264 users are recommended to obtain a license for its use directly from the MPEG LA. (x264licensing.com is for people that want to buy a non-GPL license for x264. Using it unmodified through ffmpeg, the x264 CLI, or anything else the GPL allows, doesn't require you to pay the x264 copyright holders. I linked it because their FAQ clarifies that they can't sell you a license to use the h.264 patents, you still need that separately.) I have no idea how many small-budget users just fly under the radar and don't do anything about patents.
I don't expect you'd have a problem selling access to h.264 video as long as you paid the content royalties stib described, even if you created those streams with x264. (Which you should, because it gets better quality per bitrate than any other h.264 encoder, esp. if you give it lots of CPU time to do a rate-distortion optimal encode, with the
slower or even
veryslow preset. Spend CPU time once when encoding, save bandwidth every time someone downloads.)
In an attempt to provide royalty-paid binaries for an h.264 encoder/decoder library to enable better interoperability, Cisco released Open H264. It's compiled from BSD-licensed source code. Unfortunately, it isn't actually much use for most applications because both the encoder and decoder are limited to Baseline profile. And it's not changed very much from the reference implementation, so the encoder quality is bad compared to x264, and the decoder probably isn't fast.
This blog post has some interesting comments about the royalty setup for h.264 software implementations.
If the MPEG LA started seriously harassing Free software users / distributors, people would probably take advantage of Cisco's royalty-paid binaries. Until then, nobody wants to let software patents force them to use worse software.
If you think these patent licensing issues are a load of crap for something that's supposed to be interoperable and a worldwide standard, use VP9 video and Opus audio. VP9's current encoder equals or beats x264 on most content. Last I saw, a blind listening test found Opus was at least as good as anything else (including Apple HE-AAC) at 64kb/s. Web browser support for it is still weak, outside of Google Chrome, though. IDK what's wrong with firefox being so slow to add an open-source audio decoder library.
I may be misinterpreting things. This discussion of how to license x264 for use in the US (with replies from Dark Shikari, x264 maintainer) seems to only focus on use by broadcasting corporations. I still can't figure out why Firefox would be on the hook for 5M$ for including an h.264 decoder other than Cisco's openh264, but somehow x264 and ffmpeg are distributed for free. I mplayer (and I think ffmpeg) still have their website hosted in Hungary (http://www.mplayerhq.hu), I think for reasons of US Patent, DMCA, and similar sillyness.
This article makes me think that the MPEG LA only wants money from people distributing implementations. I didn't find anything about how to license your personal copy of x264 to be legal for personal or non-profit use. (mixed opinions in the comments thread on the exact meaning of the non-commercial use clause in Final Cut Pro, for example. I tend to believe the interpretation that it's only intended to stop you from running a stream through it as a broadcaster, or similar.)
edit2: Distributing source code doesn't count as distributing a "product", which is why pre-built binaries of x264 and ffmpeg are hosted outside the US, in countries with less restrictive laws. There is much discussion about this exact issue in a thread on doom9 that I wish I'd found yesterday. >.< At least one guy on that thread actually did get a reply from his lawyer, for his x264 GUI.
It's probably not a bad idea to ask the MPEG LA if you need to pay extra for using x264 / ffmpeg, as well as selling the output h.264 content, if you're talking to them anyway. I guess compiling your own copy of x264 counts as making only a single instance of a "product". Under 100k units, there are no royalty fees for h.264. Otherwise you might be safer downloading a binary, so if anyone's on the hook, it's not you. But that's just silly. I am NOT a lawyer.
I'd love to see a comment from anyone that can shed some light on whether you had to pay extra to the MPEG LA if you were using x264 to make your for-pay content, vs. a commercial royalty-paid encoder.
I think I've made sense of this now. There was never a need for a patent license to operate an h.264 decoder/encoder, just to distribute. That was the confusion that led to this post.
So if you have a copy of x264 and ffmpeg, you're fine. You can use them just as you would use any commercial software. (With fewer restrictions, too, since some commercial software is only licensed for distribution to non-commercial users. Don't panic about this, they say their EULAs are over-broad to make sure they don't leave loopholes...)
And if you downloaded them as source, or binaries from a server in a country without annoying software-patent laws, the people you downloaded it from are also fine.