Visualize_detections.py error & fix (grabFrame packet read max attempts exceeded)

Received the following error while trying to use visualize_detections.py

[ WARN:0@1.776] global cap_ffmpeg_impl.hpp:1676 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attempt limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096)

This appears to be a known issue with opencv and multiple-stream videos. Best solution is to just strip the audio before trying to use it for visualize_detections.py. To strip the audio run the following CLI command on your left and right video files:

ffmpeg -i input_video.mp4 -an -vcodec copy output_video.mp4

You can also try just increasing the limit, but that was unsuccessful for me. To do that add the following code in the .py file above import cv2:

import os
os.environ["OPENCV_FFMPEG_READ_ATTEMPTS"] = "16384"
import cv2

@mohamedtahaguelzim do you generally prefer to have stuff like this posted to the forum here or posted as issues on the github? I have a swe background but am very much trying not to get sucked into contributing on another project :sweat_smile: I’m happy to be a more technical tester though!

1 Like

Thank you for the bug report.
In theory this debug tool will be moved to GUI app itself so it has all in one.

Better you use the workaround you find, until this gets properly implemented inside the desktop app.

It’s fine you can use which ever you want. If it’s a bug that shall be fixed, I’m ok with transferring it over to GitHub.

Although ideally the forum is better suited for discussing ideas, and GitHub for code. Bug reports are welcome in both.

And regarding your contribution, at the moment technical testers is what is the most needed! So thank you for your work.