AdamSpannbauer / python_video_stab

A Python package to stabilize videos using OpenCV
https://adamspannbauer.github.io/python_video_stab/html/index.html
MIT License
680 stars 118 forks source link

grabFrame packet read max attempts exceeded, try to increase value from current value 4096 #135

Open NikolasHofmann opened 6 months ago

NikolasHofmann commented 6 months ago

Describe the bug

I get error messages repeatedly and the files are not being fully procesed. I tried it with a much shorter "first_file.mp4" and it went through after giving one OpenCV FFMPEG error message- The other files are shot with the same GoPro Hero 8 Black camera and are considerably larger.

With your handy "show_progress=True" I am now monitoring te second file being processed. It seems to be working now, currently at 43% but I am curious about all the error messages.

EDIT The video finished stabellizing. I added both of the original videos and the stabelized ones to the google drive link. Is the finished video supposed to look like that?

I am new to coding and this is my first time issuing a bug report on github. I am very sorry as this error is most likely caused by my incompetence and I am truly sorry to waste your time. If I interpret the error messages correctly this problem seems to be related to opencv.

Forgive me for my incompetence, but is there a way to solve this isssue in the way that the error message is recommending? I have forked your repository and I am working in the venv in pycharm. Can I somehow go to the OPENCV file and set this OPENCV_FFMPEG_READ_ATTEMPTS variable to something much higher like 40960 ?

Thank you so much for your consideration.

This is what shoes up on my console:


['first_file.mp4', 'GH010462_ALTA436341618146697648.MP4', 'GH010463_ALTA436341618146697648.MP4', 'GH010464_A LTA436341618146697648.MP4', 'GH010465_ALTA436341618146697648.MP4', 'GH010466_ALTA436341618146697648.MP4', 'G H010467_ALTA436341618146697648.MP4', 'GH010468_ALTA436341618146697648.MP4', 'GH010469_ALTA436341618146697648 .MP4', 'GH010470_ALTA436341618146697648_2.MP4', 'GH010471_ALTA436341618146697648.MP4', 'GH020462_ALTA4363416 18146697648.MP4', 'GH020470_ALTA436341618146697648_2.MP4', 'GH020471ALTA436341618146697648.MP4', 'GH030471 ALTA436341618146697648.MP4', 'GX010457_1674536717543.MP4'] Stabilizing |█████ | 14%OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported wit h codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v' Stabilizing |████████████████████████████████| 100% ?[?25hFinished stabilizing first_file.mp4 Stabilizing | | 0%[ WARN:0@34.993] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@35.026] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14 )' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v' Stabilizing | | 0%[ WARN:0@35.229] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@35.391] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@35.552] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@35.740] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@35.906] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@38.860] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@41.988] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@44.774] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@47.629] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@50.476] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing | | 0%[ WARN:0@53.606] global cap_ffmpeg_impl.hpp:1541 grabFrame packet read max attempts exceeded, if your video have multiple streams (video, audio) try to increase attemp t limit by setting environment variable OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096) Stabilizing |██████████████ | 43%


Provide version info What version of Python are you running? 3.11 What version of OpenCV are you running? opencv-contrib-py44.9.0.80 What version of vidstab are you running? 1.74

pycharm 2023.3.4 Windows 10

Provide error message

OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)'

OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'

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

Provide code snippet What code were you trying to run when the issue occurred?

from vidstab import VidStab
from os import listdir
from os.path import isfile, join

# apply to all files in directory
onlyfiles = [f for f in listdir("D:/GoPro-Exports") if isfile(join("D:/GoPro-Exports", f))]
print(onlyfiles)

stabilizer = VidStab()
for file in onlyfiles:
    stabilizer.stabilize(input_path=f'D:/GoPro-Exports/{file}', output_path=f'D:/GoPro-Exports/stabilized/stabilized_{file}'
                         , show_progress=True)
    print(f'Finished stabilizing {file}')

Are you able to provide the video?

https://drive.google.com/drive/folders/1TWjUHpcaPFEfR77_qE1nGQ2bwLsT0RjT?usp=sharing

Additional context

CodingMechineer commented 1 month ago

I am having a similar problem as @NikolasHofmann Did somebody found a solution in the meanwhile?

sandau-matt commented 1 month ago

I'm seeing this issue as well. I'm not sure if this helps, but the video that I'm trying to read was also shot with a GoPro HERO 8. GoPro HERO 11 videos do not seem to cause this issue.