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

GoPro MP4 videos are only analyzed for the first 18 frames #118

Open
GabrielSandor opened this issue Oct 7, 2022 · 8 comments
Open

GoPro MP4 videos are only analyzed for the first 18 frames #118

GabrielSandor opened this issue Oct 7, 2022 · 8 comments
Labels
awaiting response improvement video-corruption Issues possibly caused by a corrupt video.

Comments

@GabrielSandor
Copy link

I ran dvr-scan with the default settings on some of my GoPro MP4 video files exported to my PC, and for some reason the analysis stops after 18 frames, even if the videos are more than 10 minutes long at 30 FPS and they do have some motion in them.

Command:
dvr-scan -i 2.mp4 --verbosity debug

Output:
INFO: controller._init_dvr_scan(): DVR-Scan v1.5.1
DEBUG: controller._init_dvr_scan(): User config file not found.
DEBUG: controller._init_dvr_scan(): Parsing program options.
INFO: scanner.init(): Initializing scan context...
INFO: video_joiner._load_input_videos(): Opened video 2.mp4 (1280 x 720 at 29.970 FPS).
DEBUG: scanner.scan_motion(): Using detector MOG2 with params: kernel_size = 5
INFO: scanner.scan_motion(): Scanning input video for motion events...
Detected: 0 | Progress: 0%|▏ | 18/18720 [00:00<03:04, 101.13 frames/s]
INFO: scanner._post_scan_motion(): Processed 18 frames read in 0.2 secs (avg 99.4 FPS).
INFO: scanner._post_scan_motion(): No motion events detected in input.

I would expect all frames in the videos to be analyzed.

Computing Environment:

@GabrielSandor
Copy link
Author

Video info from VLC Media Player, in case it helps:

Codec: H264 - MPEG-4 AVC (part 10) (avc1)
Video resolution: 1280x720
Buffer dimensions: 1280x720
Frame rate: 29.970030
Decoded format:
Orientation: Top left
Color primaries: ITU-R BT.709
Color transfer function: ITU-R BT.709
Color space: ITU-R BT.709 Range
Chroma location: Left

@Breakthrough
Copy link
Owner

Breakthrough commented Oct 8, 2022

It might be an issue with the container - can you try re-muxing the videos with ffmpeg or mkvmerge and trying again? In the long term I want to add other backends like PyAV for video input, but this is still in progress. In the meantime the only way video input is supported is using OpenCV which sometimes leads to issues like this.

You can re-mux the video with:

ffmpeg -i input.mp4 -c:v copy out.mp4

Failing that, you may need to re-encode them using ffmpeg before processing:

ffmpeg -i input.mp4 -c:v libx264 -preset fast -crf 21 out.mp4

This one is strange since typically I would expect to see a warning:

https://github.com/Breakthrough/DVR-Scan/blob/master/dvr_scan/scanner.py#L750

@GabrielSandor
Copy link
Author

@Breakthrough i just tried your advice and indeed it works, thank you! After re-muxing the video with ffmpeg, dvr-scan is able to progress through all the frames in the new video file.

I will use this as a workaround for now. Would you like me to keep this issue open until you attempt a fix in dvr-scan?

@abdullahfarwees
Copy link

@GabrielSandor to keep this issue open until you attempt a fix in dvr-scan, it would be great if you attach the sample GOpro files here. Developers might take that as a reference while fixing the issue in future

@GabrielSandor
Copy link
Author

Hello @abdullahfarwees. Due to privacy concerns, i'd rather not upload the particular GoPro files that cause the issue in dvr-scan.

@Breakthrough Breakthrough added video-corruption Issues possibly caused by a corrupt video. improvement labels Sep 19, 2023
@Breakthrough
Copy link
Owner

Breakthrough commented Sep 20, 2023

@GabrielSandor I don't think there's an easy workaround for this issue in DVR-Scan aside from using a different backend for video input as outlined above. That would be a fairly significant undertaking, so any additional detail you can provide would be very helpful.

If you are unable to share the video, would you be willing to run the same video through a related program I maintain that has added support for this? The project is PySceneDetect (www.scenedetect.com) and can be downloaded/installed in the same way as DVR-Scan.

Specifically, if you could run the following commands to include debug logs and provide them, that would let me know if using PyAV would work to fix the issue.

First, using OpenCV, the output should also stop after 18 frames as in your original example:

scenedetect -i video.mp4 --verbosity debug detect-content

Next using PyAV for video decoding:

scenedetect -i video.mp4 --verbosity debug --backend pyav detect-content

Thanks!

@GabrielSandor
Copy link
Author

Sorry @Breakthrough, it's been a while since I recorded the video and I'm afraid I can no longer find it, and in the meantime my GoPro has broken. I plan to buy a new one at some point, and if the problem re-appears I'll get back to you.

@Breakthrough
Copy link
Owner

mmokrejs was able to provide some useful context in #160 recently. I added some thoughts there on how to possibly address this. It should be possible to see if ffmpeg outputs any errors to stdout/stderr when decoding a video, so ideally DVR-Scan could warn the user after the final list of events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response improvement video-corruption Issues possibly caused by a corrupt video.
Projects
None yet
Development

No branches or pull requests

3 participants