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

webm files don't work correctly #355

Closed
speechwrecko opened this issue Oct 12, 2023 · 4 comments
Closed

webm files don't work correctly #355

speechwrecko opened this issue Oct 12, 2023 · 4 comments

Comments

@speechwrecko
Copy link

Description:
Using scene detect on webm files doesn't work. With OpenCV it only loads about 2/5% of the total frame or 3-ish minutes of video. If you switch to pyav it seems to calculate the correct frames but produces the following exception when saving images

File "keyframe.py", line 94, in find_scenes
scene_images = scenedetect.scene_manager.save_images(scene_list, video, num_images=1, output_dir="temp_img")
File "/home/jason/.local/lib/python3.8/site-packages/scenedetect/scene_manager.py", line 481, in save_images
aspect_ratio = video.aspect_ratio
File "/home/jason/.local/lib/python3.8/site-packages/scenedetect/backends/pyav.py", line 214, in aspect_ratio
self._codec_context.display_aspect_ratio.numerator /
AttributeError: 'NoneType' object has no attribute 'numerator'

Example:

Include code samples that demonstrate the issue:

    video = open_video('file.webm', backend='pyav')
    scene_manager = SceneManager()
    scene_manager.add_detector(ContentDetector(threshold=threshold))
    scene_manager.detect_scenes(video)
    scene_list = scene_manager.get_scene_list()
    scene_images = scenedetect.scene_manager.save_images(scene_list, video, num_images=1, output_dir="temp_img")

Environment:

[PySceneDetect] PySceneDetect 0.6.2

Media/Files:

Appears on any webm file

@Breakthrough
Copy link
Owner

Good find, do you happen to know if OpenCV gets the aspect ratio correct?

That aside, this is a bug since if we can't determine aspect ratio it should assume 1.0 instead of crashing. Thanks for the report.

@Breakthrough Breakthrough added this to the v0.6.3 milestone Oct 16, 2023
@Breakthrough
Copy link
Owner

Does this happen with all videos? I was able to successfully process some with OpenCV without issue.

@Breakthrough
Copy link
Owner

Do you have an example you can share that demonstrates the bug? This should be fixed in the next release, but I wasn't able to reproduce the issue so hoping to be able to verify the fix first somehow. Thanks!

Breakthrough added a commit that referenced this issue Dec 2, 2023
Add additional checks to guard against divide by zero. Fixes #355.
@Breakthrough
Copy link
Owner

Have done my best to avoid crashing issues with this, which will be included in the next version. Unfortunately I'm unable to verify the fix, but if anyone runs into this again, feel free to open a new issue.

Breakthrough added a commit that referenced this issue Apr 18, 2024
Add additional checks to guard against divide by zero. Fixes #355.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants