strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.64k stars 294 forks source link

libheif / libx265 encoder GPL license and patents? #591

Open AttilaTheFun opened 2 years ago

AttilaTheFun commented 2 years ago

I keep hearing conflicting information about the patents involved with x265 HEVC encoding and I'm trying to get a straight answer.

On VideoLAN's website, they state that:

x265 is a free software library and application for encoding video streams into the H.265/MPEG-H HEVC compression format, and is released under the terms of the GNU GPL.

AFAIK the GPLv2 license basically states that, if you distribute the software in a binary or source format, you need to include a copy of the license with the distribution so other people can view the source code.

I would to use libx265 (via libheif) to produce HEIC (HEVC-encoded HEIF) files on my server. Users will first upload photos in a variety of different source formats (JPEG, PNG, HEIC, TIFF, etc.), and the server will decode these into a bitmap and then produce a HEIC image from that, storing it in S3.

My understanding is that the GPLv2 license would not pose an issue here because I'm not distributing the software to anyone, just using it to encode the image files.

That said, I understand that patents also potentially pose an issue here. Per Access Advance's faq and topic-what-do-we-license:

You most likely need a license if you sell any products that have HEVC/H.265 encoding and/or decoding capability/functionality Parties that (a) provide End Users with access to HEVC encoders and/or decoders through the internet or another public or private network or (b) process content at the End User’s request using HEVC encoders and/or decoders where the output is returned to the End User

If I want to HEIC-encode images uploaded to my social media app from their source format, am I correct in assuming that I would need a license for that?

silverbacknet commented 2 years ago

x265 is dual licensed for a reason: When you buy a commercial license for x265, Multicoreware will deal with the licensing, and certify and indemnify you against patent claims, as long as you stay honest to your application. If you use GPL x265, Multicoreware indemnifies you for nothing, and you either deal with all three patent pools plus the handful of claimants who aren't even part of the pools, or you take all the risk of a lawsuit upon yourself by using it.

GPL allows you to freely obtain and distribute source code and binaries. It does not indemnify you to patents for the use of that code to encode or decode anything. BSD-patent is one of the only licenses that seeks to clarify that, and even that only applies to patents that can be transferred, which mostly means patents held by the distributor. None of them apply to third parties with patents covering the code.

The collapse of the MPEG LA was a travesty, but it was also the impetus to make AV1 actually happen.

AttilaTheFun commented 2 years ago

Ah, interesting! I was wondering how things got so messed up.

Unfortunately, my app is primarily an iOS app, and iOS doesn't support decoding AV1 yet AFAIK. (It would be too CPU intensive to do in software and the chips don't have hardware support for it as far as I'm aware.) The M1 series chips apparently have AV1 decoding support, though, so that's a good sign.

iOS has, however, had HEVC hardware decoding support for the longest of any major manufacturer. Until Apple adds AV1 decoding to their iPhone chips I'm basically stuck with either H.264 or H.265/HEVC.

In regards to my to my original question, do you know if I would require a license just to encode photos/videos uploaded by my users to HEVC?

silverbacknet commented 2 years ago

Any use of the HEVC (and H.264) hardware encoder and decoder is covered. Anything else, a software implementation like x265 or ffmpeg, wouldn't be, even on the same platform, so for libheif it's a matter of wiring up the IOS hardware API to new plugins for libheif. (Would be an excellent contribution!) Just hosting the files somewhere doesn't matter, but something as simple as decoding for thumbnailing on your server technically could be. It's pretty onerous, but it's also quite spottily enforced; as you can imagine, they aren't going to hunt down every blog and app out there until it gets big enough.