0

My operating system is 'Mac OS Big Sur 11.4' and Python3 version is 3.9.6 and OpencV version is 4.5.3. The project is running on virtual environment. It still can read from images and webcam. It shows an error when I try to read a stream from a video file.

vid = cv.VideoCapture(FLAGS.video_path)

When I printed the 'FLAGS.video_path', it showed:

/documents/projects/YOLOv3-Object-Detection-with-OpenCV-arunava/road-traffic.mp4

So, then I tried to read the stream.

if not vid.isOpened():
            print("Error opening video")
        else:
            print("Video capture was success")

And it printed out "Error opening video".

I tried these solutions from stackoverflow.

I've read official documentation too.

Can you please help me?

schoolboy
  • 71
  • 1
  • 7
  • provide output of `print(cv.getBuildInformation())`. check `assert os.path.exists(FLAGS.video_path)`, if that's okay, then try decoding the video with ffmpeg: `ffmpeg -i your_video_file -f null -` (make sure to copy that exactly: minus f, space, null, space, minus) – Christoph Rackwitz Jul 14 '21 at 11:32
  • 1
    This is the OpenCV Build Information. [Snippet](https://pastecode.io/s/6xsa6jp7) . And as your suggestion, I found out that FFmpeg has decoder for my video file. – schoolboy Jul 14 '21 at 13:02
  • your opencv was built *without* support for ffmpeg. that's what you need to fix. I see support for "avfoundation". i don't know if that only accesses camera devices or if it can read common video formats. – Christoph Rackwitz Jul 14 '21 at 17:10

0 Answers0