opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Can't get AVIF encode to work

Open Zaczero opened this issue 1 year ago • 0 comments

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))

Zaczero avatar Oct 19 '24 11:10 Zaczero