PyAV
PyAV copied to clipboard
cv2.imshow freezes after av is imported
Overview
My setup is a docker container with Ubuntu 22.04 and python 3.10 and av installed through pip as a dependency of aiortc.
The python scripts freeze on the cv2.imshow line after av is imported. There is no opencv window either. If I don't import av it works.
Expected behavior
The pip installed version of av should not cause any issues for opencv.
Actual behavior
cv2.imshow does not work after av is imported
Traceback: There is no error print or traceback, and I was not able to find any info additional info through the VSCode debugger.
Investigation
I tried building/installing v10.0.0 of PyAV from the source, which fixed the issue.
Reproduction
import cv2
import numpy as np
import av
def main(args=None):
img = np.zeros((200, 200, 3), dtype=np.uint8)
cv2.imshow('ImageWindow', img)
cv2.waitKey()
if __name__ == '__main__':
main()
Versions
- OS: Ubuntu 22.04
- PyAV versions: 9 and greater
+1
+1
So the solution was to upgrade to pyav 10?
Looks like a re-occurrence of #978 . Is this still current with PyAV 10?
Looks like a re-occurrence of #978 . Is this still current with PyAV 10?
With Python 3.9.14 on Ubuntu 20.04 and
av==10.0.0 opencv-python==4.7.0.72
I still get this issue. EDIT: Without building from source.
As a temporary fix I found that calling cv2.imshow before import av prevents the freeze:
import numpy as np
import cv2
cv2.imshow('ffmpeg fix', np.array([1], dtype=np.uint8))
cv2.destroyAllWindows()
import av
red = np.ones((256, 256, 3)) * np.array([0, 0, 255])
cv2.imshow("red", red.astype(np.uint8))
cv2.waitKey(0)
cv2.destroyAllWindows()
I can verify this issue still happens with opencv-python 4.7.0.72 and av 10.0.0 Running Debian/Sid, x64
I am facing the issue in raspberry pi 4. python 3.11 av==12.1.0 opencv-python==4.10.0.82
What is the fix?
I can't repro. It's probably that I'm using MacOS. Looks like a Linux desktop issue. In fact, it's almost certainly an X11 issue. If someone showed that this can't be reproded in Wayland either, this issue should be closed.
Still can't repo. closing