Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] libheif #2516

Open
zedd-0 opened this issue Sep 24, 2023 · 34 comments
Open

[add] libheif #2516

zedd-0 opened this issue Sep 24, 2023 · 34 comments

Comments

@zedd-0
Copy link

zedd-0 commented Sep 24, 2023

hi, is it possible to add libheif to this script?
https://github.com/strukturag/libheif

@hydra3333
Copy link
Contributor

hydra3333 commented Sep 25, 2023

I don't recall if ffmpeg supports those formats already in some manner ...
Ah. It seems ffmpeg itself does not support heif
https://stackoverflow.com/questions/65435536/convert-a-heif-file-to-png-jpg-using-ffmpeg

After quick google, I have not yet spotted anything in ffmpeg to say it supports libheif and a reasonable guess would be that ffmpeg needs to be updated to support it.

In fact https://github.com/strukturag/libheif#software-using-libheif does not list ffmpeg as software which uses libheif.

On that basis, since MABS is a build system for ffmpeg and dependencies, I guess that no change to MABS would achieve what you are seeking ?

Lack of heif support seems to be a long overdue shortcoming in ffmpeg, based on TRAC comments.

@L4cache
Copy link
Contributor

L4cache commented Sep 25, 2023

I don't recall if ffmpeg supports those formats already in some manner ... Ah. It seems ffmpeg itself does not support heif https://stackoverflow.com/questions/65435536/convert-a-heif-file-to-png-jpg-using-ffmpeg

After quick google, I have not yet spotted anything in ffmpeg to say it supports libheif and a reasonable guess would be that ffmpeg needs to be updated to support it.

In fact https://github.com/strukturag/libheif#software-using-libheif does not list ffmpeg as software which uses libheif.

On that basis, since MABS is a build system for ffmpeg and dependencies, I guess that no change to MABS would achieve what you are seeking ?

Lack of heif support seems to be a long overdue shortcoming in ffmpeg, based on TRAC comments.

It's funny (or not) that ffmpeg supports so called "avif" but no "heic". It's just a container!
No big deal though, things are just starting to get complicated as some people already removed jpeg-xl from a most popular product in the area. (Google Chrome)

@hydra3333
Copy link
Contributor

Yes, things seem a tad peculiar.
For better or worse, I'd always thought of ffmpeg as a mainstream video processing product and so was unsurprised to note some deficiencies around image processing.

@gitoss
Copy link

gitoss commented Jun 16, 2024

hi, is it possible to add libheif to this script? https://github.com/strukturag/libheif

Using media-autobild's msys shell, I was able to compile libheif with all HEVC & AV1 encoders/decoders I want to use - there are no Windows binaries around the web for that.

I didn't use add it to media-suite_compile.sh, but did a manual cmake - which was a LOT of hassle, I had to set the respective PKGCONF LIBRARY and INCLUDE_DIR params.

If anyone happens to have a patch / addition for media-suite_compile.sh which is 'fire and forget', please do share.

@LigH-de
Copy link
Contributor

LigH-de commented Nov 6, 2024

There is another request in the German Gleitz video forum

@hydra3333
Copy link
Contributor

I'm a bit late to the party. A new comment over on ffmpeg TRAC: https://trac.ffmpeg.org/ticket/6521#comment:23

@L4cache
Copy link
Contributor

L4cache commented Nov 15, 2024

I'm a bit late to the party. A new comment over on ffmpeg TRAC: https://trac.ffmpeg.org/ticket/6521#comment:23

That commit was not related to libheif. It's the native demuxer in FFmpeg.
They don't need external libraries for this job because HEIF is a variant of MP4, they can just reuse the already existing codes.

But still no muxer support for HEIC.
I'm thinking, how hard could it be?

@LigH-de
Copy link
Contributor

LigH-de commented Nov 15, 2024

And even as long as ffmpeg hesitates to implement new support for single image formats based on established video format I-frames, some people are interested in at least separate encoders for these formats.

@L4cache
Copy link
Contributor

L4cache commented Nov 15, 2024

I'll see what I can do after it finished building everything with new version of clang ;)

@L4cache
Copy link
Contributor

L4cache commented Nov 16, 2024

Test branch
https://github.com/L4cache/media-autobuild_suite/tree/test-libheif

I don't know what to do with the linking issues...
I'll open PR after at least the libde265 one is fixed...

@LigH-de
Copy link
Contributor

LigH-de commented Nov 17, 2024

Successfully built libheif 1.19.3 8a139a6

32 and 64 bit code contain a different selection of codecs; and heif-dec contains no HEIC decoder. (I wonder if libavcodec is able?)

@hydra3333
Copy link
Contributor

Thank you.

Also, eek at

32 and 64 bit code contain a different selection of codecs; and heif-dec contains no HEIC decoder. (I wonder if libavcodec is able?)

@LigH-de
Copy link
Contributor

LigH-de commented Nov 19, 2024

Well, of course, some codecs like VVC exist in 64 bit only. No surprise. The other issue sounds more important, if it is called "heif-dec", it should be able to fulfill its name at least. So hoping for libde265 or any alternative decoder to work,

@L4cache
Copy link
Contributor

L4cache commented Nov 19, 2024

libde265 is working (or, "linking" to be precise?) I haven't tested the actual decoding though.

@LigH-de
Copy link
Contributor

LigH-de commented Nov 19, 2024

I did not test daily. Now that I downloaded the latest release, VulkanLoader fails... makes testing hard until solved.

@zedd-0
Copy link
Author

zedd-0 commented Nov 19, 2024

32 and 64 bit code contain a different selection of codecs; and heif-dec contains no HEIC decoder. (I wonder if libavcodec is able?)

There's something strange about that.
When I assemble the libheif decoder from the MSYS2 32-bit repository myself (precompiled binarys),
it lists 'libde256' as the decoder, and it works too.

some links:
https://packages.msys2.org/packages/mingw-w64-i686-libheif
https://repo.msys2.org/mingw/i686/
https://repo.msys2.org/msys/i686/
(liblzma is unlisted and needs to be renamed.)

@LigH-de
Copy link
Contributor

LigH-de commented Nov 19, 2024

As I already mentioned: At that time when I tested it, this branch did not yet solve the linking issue.

Now it is fixed, libde265 links. But I could not yet test it again.

@LigH-de
Copy link
Contributor

LigH-de commented Nov 19, 2024

Disabling vulkan and libplacebo due to issues. And OpenH264 asks for a newer version because MSYS2 ships newer headers.

The following codecs are reported for my build v1.19.5 c057050:

Win32

heif-enc.exe --list-encoders

AVC encoders:
AVIF encoders:
- aom = AOMedia Project AV1 Encoder 3.11.0-106-g80070c4b [default]
HEIC encoders:
- x265 = x265 HEVC encoder (4.0+61-7cc4030) [default]
- kvazaar = kvazaar HEVC encoder
JPEG encoders:
- jpeg = libjpeg-turbo 3.0.4 (libjpeg 8.0) [default]
JPEG 2000 encoders:
JPEG 2000 (HT) encoders:
Uncompressed encoders:
- uncompressed = builtin [default]
VVIC encoders:

heif-dec.exe --list-decoders

AVC decoders:
- openh264 = OpenH264 2.4.1
AVIF decoders:
- dav1d = dav1d v7.0.0
- aom = AOMedia Project AV1 Decoder 3.11.0-106-g80070c4b
HEIC decoders:
- libde265 = libde265 HEVC decoder, version 1.0.15
JPEG decoders:
- jpeg = libjpeg-turbo 3.0.4 (libjpeg 8.0)
JPEG 2000 decoders:
JPEG 2000 (HT) decoders:
uncompressed:
- uncompressed = builtin
VVIC decoders:

Win64

heif-enc.exe --list-encoders

AVC encoders:
AVIF encoders:
- aom = AOMedia Project AV1 Encoder 3.11.0-106-g80070c4b [default]
- svt = SVT-AV1 encoder v2.3.0-56-g94a1a85
HEIC encoders:
- x265 = x265 HEVC encoder (4.0+61-7cc4030) [default]
- kvazaar = kvazaar HEVC encoder
JPEG encoders:
- jpeg = libjpeg-turbo 3.0.4 (libjpeg 8.0) [default]
JPEG 2000 encoders:
JPEG 2000 (HT) encoders:
Uncompressed encoders:
- uncompressed = builtin [default]
VVIC encoders:
- vvenc = vvenc VVC encoder [default]
- uvg266 = uvg266 VVC encoder

heif-dec.exe --list-decoders

AVC decoders:
- openh264 = OpenH264 2.4.1
AVIF decoders:
- dav1d = dav1d v7.0.0
- aom = AOMedia Project AV1 Decoder 3.11.0-106-g80070c4b
HEIC decoders:
- libde265 = libde265 HEVC decoder, version 1.0.15
JPEG decoders:
- jpeg = libjpeg-turbo 3.0.4 (libjpeg 8.0)
JPEG 2000 decoders:
JPEG 2000 (HT) decoders:
uncompressed:
- uncompressed = builtin
VVIC decoders:
- vvdec = VVCDEC decoder (3.0.0)

Could x264 or OpenH264 be used as AVC encoder?

The Win32 binary not supporting VVC is no surprise, Fraunhofer did not provide x86 optimized code; x86-64 code can use more internal registers and more RAM per process, so developing a separate x86 branch would not be efficient.

@L4cache
Copy link
Contributor

L4cache commented Nov 20, 2024

x264 support is not implemented in upstream. There's a commented line in CMakeLists refering OpenH264 encoding but it's not implemented as well. (it's in the TODO list, maybe?)
So... there's no any AVC encoding support at the moment.

@LigH-de
Copy link
Contributor

LigH-de commented Nov 21, 2024

You may have a little typo in the install script, a path is doubled:

Error copying file "G:/MABS/local64/G:/MABS/local64/bin-video/heif-dec.exe" to "G:/MABS/local64/G:/MABS/local64/bin-video/heif-convert.exe".

PS: May not be your fault, rather upstream. Looks not even very sensible to me.

@L4cache
Copy link
Contributor

L4cache commented Nov 21, 2024

Sometimes I wonder myself where did that heif-convert.exe go?
Thanks for pointing out, but that's something more weird than a typo:
I first noticed the heif-convert was gone after I set the install location to the /local64/bin-video folder instead of the "default" folder, by adding video as the first argument of do_cmakeinstall.
After I realized it was just a link / copy (depending on OS) of heif-dec I just stopped bothering it.

https://github.com/strukturag/libheif/blob/2e02ee2b64941c3f693f6536d637926d450b97fb/examples/CMakeLists.txt#L31-L36

But this copy process is controled by the CMake, since the rest of the executables get installed in the right place... I don't think I did a typo. It must be CMake that did something wrong.

@LigH-de
Copy link
Contributor

LigH-de commented Dec 6, 2024

BTW: libde265 compiles to a separate dec265.exe too; but it does not print any console output, not even its own help text. Probably nothing to really worry about, as long as nobody seriously wants to use it...

@L4cache
Copy link
Contributor

L4cache commented Dec 7, 2024

BTW: libde265 compiles to a separate dec265.exe too; but it does not print any console output, not even its own help text. Probably nothing to really worry about, as long as nobody seriously wants to use it...

You ready? imma say it, here it goes: it's fine on my side. (kinda hate to say it but it's the fact...)
You had similar issue with av1an as well, I guess it's something unusual with you system?

@LigH-de
Copy link
Contributor

LigH-de commented Dec 7, 2024

In case of Av1an, it was necessary to have Python 3.12+ and VapourSynth in it installed.

Does dec265 have the same requirements? If so, is that documented?

@L4cache
Copy link
Contributor

L4cache commented Dec 7, 2024

In case of Av1an, it was necessary to have Python 3.12+ and VapourSynth in it installed.

Does dec265 have the same requirements? If so, is that documented?

I don't think so, the here built dec265's requirement should be just itself (and some standrad Windows libraries / runtimes).

@LigH-de
Copy link
Contributor

LigH-de commented Dec 7, 2024

My system is indeed a little special, it is Windows 10 upgraded from Windows 7. I noticed that the OS detection may behave slightly differently when running either as normal user or "as Administrator". In case of Stellarium, the Qt6 installer failed, only the Qt5 installer worked... But I see no reason why any console application would not want to print anything (possibly fail before any output and crash?). In a most recent build, Av1an creates a log which looks very brief to me.

@gitoss
Copy link

gitoss commented Dec 7, 2024

I have already commented on the pull request, but that wasn't the proper place:

I suggest adding shared compilation option for libheif, i.e. like av1an or like mabs already does for ffmpeg.

The reason is that libheif produces several exe files - which are all similarly huge in the static build. Some like heif-info do trivial things, but always include all of what is heif.dll in a shared build.

@lukenash707
Copy link

I'm a bit of a newbie when it comes to coding but I'm try to fumble my way through getting chat gpt to make a script to extract frames from a 10 bit video .mov using FFMPEG, I want to output 10 bit heic files but I can't seen to find a prebuilt binary for ffmpeg with heic/heif support is one out there or is this still in progress?

@gitoss
Copy link

gitoss commented Jan 16, 2025

I want to output 10 bit heic files but I can't seen to find a prebuilt binary for ffmpeg with heic/heif support is one out there or is this still in progress?

Lacking ffmpeg internal heif support, you can of course always write an intermediary high-quality jpeg file with ffmpeg and use that in the stand-alone heif-enc encoder...

@lukenash707
Copy link

Yeah, unfortunately that would destroy the 10bit data which I’d like to keep, ive experimented with avif, jxl, png, and tiff but the decoder takes about 100x as long than working with jpeg! I think im just going to have to stick with 8 bit now until they add heif support

@gitoss
Copy link

gitoss commented Jan 16, 2025

but the decoder takes about 100x as long than working with jpeg!

Oh my, I'm often encoding 10-bit heif (--encoder x265) from 16 bit png sources and didn't realize that decoding other than jpeg is a bottleneck... I'll have to benchmark that sometimes.

If you can reproduce a severe decoding issue, you might add a bug ticket for libheif https://github.com/strukturag/libheif/issues

@L4cache
Copy link
Contributor

L4cache commented Jan 16, 2025

Well, by design the HEVC, even with only one Intra frame, is much, much more complex than jpeg (1992).
Same thing can be said for other modern formats as well.

@LigH-de
Copy link
Contributor

LigH-de commented Jan 16, 2025

Please don't mind me reminding you that this project is not the perfect place for cozy discussions about the usage of tools, as mentioned in the readme of this project. Forums like doom9 or VideoHelp are more suitable.

@gitoss
Copy link

gitoss commented Jan 16, 2025

If you can reproduce a severe decoding issue, you might add a bug ticket for libheif https://github.com/strukturag/libheif/issues
Please don't mind me reminding you that this project is not the perfect place for cozy discussions about the usage of tools, as mentioned in the readme of this project. Forums like doom9 or VideoHelp are more suitable.

In the coziest way possible I'm all about isolating if there's a possible bug that should be handled in the approprate place, either by mabs or upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants