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

Can't get AVIF encode to work #1038

Closed
Zaczero opened this issue Oct 19, 2024 · 2 comments
Closed

Can't get AVIF encode to work #1038

Zaczero opened this issue Oct 19, 2024 · 2 comments
Labels

Comments

@Zaczero
Copy link

Zaczero commented Oct 19, 2024

Expected behaviour

I expect the imencode AVIF to work properly, as it's supported by the upstream OpenCV.

Actual behaviour

cv2.imencode('.avif', img)
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:1141: error: (-2:Unspecified error) could not find encoder for the specified extension in function 'imencode'

I have tried installing libavif on my system but that did not resolve the issue. I believe this is a build-time issue.

Steps to reproduce

pip install opencv-python-headless
import cv2
import numpy as np

print(cv2.__version__)  # '4.10.0'

cv2.imwrite('test.avif', np.zeros((100, 100, 3), np.uint8))
@asmorkalov
Copy link
Collaborator

AVIF support depends on libavif library. The dependency is optional and has a lot of own 3rd-parties. AVIF is disabled in opencv-python package for now. You have to re-built OpenCV to get it supported.

@Zaczero
Copy link
Author

Zaczero commented Jan 15, 2025

Hello. I think it's an oversight and major blocker as AVIF adoption keeps growing. This forced me to switch to Pillow that is unfortunately slower than opencv.

and has a lot of own 3rd-parties

Could you please clarify? libavif depends on codec implementation, let's say libaom - is there anything else? How does it differ from other formats currently supported?

You have to re-built OpenCV to get it supported.

Can you please guide me with resources so I know how to do that? I'm not experienced with this.

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

No branches or pull requests

2 participants