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

cv2.imshow freezes after av is imported #1050

Open
samiamlabs opened this issue Nov 16, 2022 · 8 comments
Open

cv2.imshow freezes after av is imported #1050

samiamlabs opened this issue Nov 16, 2022 · 8 comments
Labels

Comments

@samiamlabs
Copy link

samiamlabs commented Nov 16, 2022

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
@samiamlabs samiamlabs added the bug label Nov 16, 2022
@RemiFabre

This comment was marked as off-topic.

1 similar comment
@apirrone

This comment was marked as off-topic.

@HanzCEO
Copy link
Contributor

HanzCEO commented Dec 25, 2022

So the solution was to upgrade to pyav 10?

@jlaine
Copy link
Member

jlaine commented Jan 23, 2023

Looks like a re-occurrence of #978 . Is this still current with PyAV 10?

@marcusvaltonen
Copy link

marcusvaltonen commented Mar 10, 2023

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.

@Linusnie
Copy link

Linusnie commented May 5, 2023

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

@coder111111
Copy link

I can verify this issue still happens with opencv-python 4.7.0.72 and av 10.0.0
Running Debian/Sid, x64

@hmasum52
Copy link

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?

@WyattBlue WyattBlue reopened this Jun 17, 2024
@PyAV-Org PyAV-Org deleted a comment from github-actions bot Jun 17, 2024
@WyattBlue WyattBlue removed the stale label Jun 18, 2024
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

10 participants