NghiemLg
NghiemLg

Reputation: 1

Issue with cv2.VideoCapture(video_url) Not Working for Video Links (Works Fine with Local MP4 Files)

I'm experiencing an issue with cv2.VideoCapture(video_url) when trying to work with video links. The function doesn't seem to handle video URLs properly, although it works without any issues for local MP4 files. Below are the details of my setup:

Interestingly, when I previously used Ubuntu 24.04, the issue didn't seem to occur (although I'm not entirely sure if it's related).

Issue:

The program fails to open the video link and returns an error message:

Error: Unable to open video stream.
Error: Cannot read frame from video stream.

Questions:

  1. Is this issue related to the version of Ubuntu or Python I'm using?
  2. How can I resolve this so that cv2.VideoCapture works with video URLs? (Please replace the video link with any YouTube link)

I tried switching between virtual environments using Conda and venv. When I replaced the video URL with a local MP4 file, it worked. I also reinstalled ultralytics and torch. I don't know if GStreamer is not installed with OpenCV when using pip on Ubuntu 22.04.

Upvotes: -1

Views: 27

Answers (0)

Related Questions