strukturag / libheif

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

heif_decode_image() reports error "Unsupported feature: Unsupported codec" #868

Open LvChenhui opened 1 year ago

LvChenhui commented 1 year ago

HI, I installed GraphicsMagick that supports libheif

GraphicsMagick: 1.3.40
libheif: 1.16.1
$gm identify -verbose -debug coder heic.jpg
18:34:14 0:0.002120  0.000u 38929 constitute.c/ReadImage/1676/Coder:
  Invoking "HEIC" decoder (HEIF Image Format) subimage=0 subrange=0
18:34:14 0:0.003061  0.000u 38929 heif.c/ReadHEIFImage/486/Coder:
  Geometry: 2000x2586
18:34:14 0:0.003079  0.000u 38929 heif.c/ReadHEIFImage/488/Coder:
  Matte: False
18:34:14 0:0.003435  0.000u 38929 heif.c/ReadHEIFImage/557/Coder:
  heif_decode_image() reports error "Unsupported feature: Unsupported codec"
18:34:14 0:0.003558  0.000u 38929 constitute.c/ReadImage/1702/Coder:
  Returned from "HEIC" decoder, returned image is NULL!
gm identify: An error has occurred reading from file (heic.jpg).
gm identify: Request did not return an image.
$gm identify heic.jpg
heic.jpg HEIC 2000x2586+0+0 DirectClass 8-bit 340.1Ki 0.000u 0m:0.000003s

It seems that the installation is successful, but some commands do not support it. Is this normal?

Thanks

silverbacknet commented 1 year ago

GraphicsMagic (and many other users) only include AVIF support by default, HEIC is encumbered by an obnoxious number of patents by very litigious companies. You have to build it yourself to get that support, via de265 and x265.

It might be worth saying that HEVC/H.265 support has been excluded, since it's such a common case for open source repositories.

bradh commented 1 year ago

Can I ask why this is reported against libheif, rather than against GraphicsMagick? Did they suggest it was an upstream issue?

LvChenhui commented 1 year ago

GraphicsMagic (and many other users) only include AVIF support by default, HEIC is encumbered by an obnoxious number of patents by very litigious companies. You have to build it yourself to get that support, via de265 and x265.

It might be worth saying that HEVC/H.265 support has been excluded, since it's such a common case for open source repositories.

I've already installed de265 and x265

#yum info x265
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
Available Packages
Name        : x265
Arch        : x86_64
Version     : 2.9
Release     : 3.el7
Size        : 39 k
Repo        : rpmfusion-free-updates/x86_64
Summary     : H.265/HEVC encoder
URL         : http://x265.org/
License     : GPLv2+ and BSD
Description : The primary objective of x265 is to become the best H.265/HEVC encoder
            : available anywhere, offering the highest compression efficiency and the highest
            : performance on a wide variety of hardware platforms.
            :
            : This package contains the command line encoder.
#yum -y info libde265
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
Installed Packages
Name        : libde265
Arch        : x86_64
Version     : 1.0.2
Release     : 6.el7
Size        : 801 k
Repo        : installed
From repo   : rpmfusion-free-updates
Summary     : Open H.265 video codec implementation
URL         : http://www.libde265.org/
License     : LGPLv3+
Description : libde265 is an open source implementation of the H.265 video codec.
            : It is written from scratch for simplicity and efficiency. Its simple
            : API makes it easy to integrate it into other software.
$heif-enc --list-encoders
HEIC encoders:
- x265 = x265 HEVC encoder (2.9) [default]
AVIF encoders:
$heif-convert --list-decoders
HEIC decoders:
- libde265 = libde265 HEVC decoder, version 1.0.2
AVIF decoders:
uncompressed: yes

The error is reported in

heif.c/ReadHEIFImage/557/Coder:
  heif_decode_image() reports error "Unsupported feature: Unsupported codec"

Looks like he failed to decode it.But libde265 show installed correctly, I don't know where is the problem

Thank you for your reply

LvChenhui commented 1 year ago

Can I ask why this is reported against libheif, rather than against GraphicsMagick? Did they suggest it was an upstream issue?

I'm not entirely sure whether it's GraphicsMagick's problem or libheif's problem, but the error message points to the decode part of libheif.

18:34:14 0:0.003435  0.000u 38929 heif.c/ReadHEIFImage/557/Coder:
  heif_decode_image() reports error "Unsupported feature: Unsupported codec"

Thank you for your reply

bradh commented 1 year ago

GraphicsMagic (and many other users) only include AVIF support by default, HEIC is encumbered by an obnoxious number of patents by very litigious companies. You have to build it yourself to get that support, via de265 and x265. It might be worth saying that HEVC/H.265 support has been excluded, since it's such a common case for open source repositories.

I've already installed de265 and x265

#yum info x265
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
Available Packages
Name        : x265
Arch        : x86_64
Version     : 2.9
Release     : 3.el7
Size        : 39 k
Repo        : rpmfusion-free-updates/x86_64
Summary     : H.265/HEVC encoder
URL         : http://x265.org/
License     : GPLv2+ and BSD
Description : The primary objective of x265 is to become the best H.265/HEVC encoder
            : available anywhere, offering the highest compression efficiency and the highest
            : performance on a wide variety of hardware platforms.
            :
            : This package contains the command line encoder.
#yum -y info libde265
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
Installed Packages
Name        : libde265
Arch        : x86_64
Version     : 1.0.2
Release     : 6.el7
Size        : 801 k
Repo        : installed
From repo   : rpmfusion-free-updates
Summary     : Open H.265 video codec implementation
URL         : http://www.libde265.org/
License     : LGPLv3+
Description : libde265 is an open source implementation of the H.265 video codec.
            : It is written from scratch for simplicity and efficiency. Its simple
            : API makes it easy to integrate it into other software.
$heif-enc --list-encoders
HEIC encoders:
- x265 = x265 HEVC encoder (2.9) [default]
AVIF encoders:
$heif-convert --list-decoders
HEIC decoders:
- libde265 = libde265 HEVC decoder, version 1.0.2
AVIF decoders:
uncompressed: yes

The error is reported in

heif.c/ReadHEIFImage/557/Coder:
  heif_decode_image() reports error "Unsupported feature: Unsupported codec"

Looks like he failed to decode it.But libde265 show installed correctly, I don't know where is the problem

Does heif-convert decode the file OK?

Can you share the problem file?

LvChenhui commented 1 year ago

GraphicsMagic (and many other users) only include AVIF support by default, HEIC is encumbered by an obnoxious number of patents by very litigious companies. You have to build it yourself to get that support, via de265 and x265. It might be worth saying that HEVC/H.265 support has been excluded, since it's such a common case for open source repositories.

I've already installed de265 and x265

#yum info x265
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
Available Packages
Name        : x265
Arch        : x86_64
Version     : 2.9
Release     : 3.el7
Size        : 39 k
Repo        : rpmfusion-free-updates/x86_64
Summary     : H.265/HEVC encoder
URL         : http://x265.org/
License     : GPLv2+ and BSD
Description : The primary objective of x265 is to become the best H.265/HEVC encoder
            : available anywhere, offering the highest compression efficiency and the highest
            : performance on a wide variety of hardware platforms.
            :
            : This package contains the command line encoder.
#yum -y info libde265
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * nux-dextop: li.nux.ro
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
Installed Packages
Name        : libde265
Arch        : x86_64
Version     : 1.0.2
Release     : 6.el7
Size        : 801 k
Repo        : installed
From repo   : rpmfusion-free-updates
Summary     : Open H.265 video codec implementation
URL         : http://www.libde265.org/
License     : LGPLv3+
Description : libde265 is an open source implementation of the H.265 video codec.
            : It is written from scratch for simplicity and efficiency. Its simple
            : API makes it easy to integrate it into other software.
$heif-enc --list-encoders
HEIC encoders:
- x265 = x265 HEVC encoder (2.9) [default]
AVIF encoders:
$heif-convert --list-decoders
HEIC decoders:
- libde265 = libde265 HEVC decoder, version 1.0.2
AVIF decoders:
uncompressed: yes

The error is reported in

heif.c/ReadHEIFImage/557/Coder:
  heif_decode_image() reports error "Unsupported feature: Unsupported codec"

Looks like he failed to decode it.But libde265 show installed correctly, I don't know where is the problem

Does heif-convert decode the file OK?

Can you share the problem file?

it executed successfully, And I think this may not be an issue with the image itself. Thanks.

$heif-convert heic.jpg heic.png
File contains 1 image
Written to heic.png
bradh commented 1 year ago

So if heif-convert worked, and you still have problems with GM, you must have more than one libheif installed, or GM is doing something a bit strange .

LvChenhui commented 1 year ago

I found a command with an error, which also looks like a decoding issue.

$heif-info avif.jpg
MIME type: image/avif
main brand: avif
compatible brands: avif, mif1, miaf

image: 1000x1000 (id=1), primary
  color profile: nclx
  alpha channel: no
  depth channel: no
metadata:
  none
transformations:
  none
region annotations:
  none
properties:
Could not decode image Unsupported feature: Unsupported codec
bradh commented 1 year ago

That appears to be a different problem since it is about avif not heif. You might want to create a distinct issue and attach the file. Or since your earlier reports did not show an AVIF decoder (just de265), maybe you should fix your configuration first.

LvChenhui commented 1 year ago

oh...It was my mistake, and I was able to handle the HEIF image successfully.

heif-info heic.jpg
MIME type: image/heic
main brand: heic
compatible brands: mif1, heic

image: 2000x2586 (id=25), primary
  color profile: no
  alpha channel: no
  depth channel: no
metadata:
  none
transformations:
  none
region annotations:
  none
properties:

I'm sure only one libheif was installed. In the version of gm that does not support libheif, running the command gm identify img.heif will lead to an error. However, in our current version, it can return results as expected, as previously mentioned. But when running -verbose to get more information, errors may occur.

Thank you for your continuous help~

$gm -version
...
HEIF/HVEC ("HEIC")         yes
...
bradh commented 1 year ago

I still don't think that this is a libheif problem, since the libheif tools work as expected.

I am confused by the discussion of various versions of GM, which you probably need to work though (e.g., with ldd) to figure out what is happening.

bradh commented 1 year ago

@LvChenhui were you able to resolve your issue? If not, can you add more details that would allow your issue to be reproduced?