Breakthrough / PySceneDetect

:movie_camera: Python and OpenCV-based scene cut/transition detection program & library.
https://www.scenedetect.com/
BSD 3-Clause "New" or "Revised" License
3.35k stars 402 forks source link

Failed to open video with opencv: Ensure file is valid video and system dependencies are up to date. #415

Open kehuanfeng opened 3 months ago

kehuanfeng commented 3 months ago

Description:

Failed to open video with opencv: Ensure file is valid video and system dependencies are up to date.

Command:

scenedetect -i file_example_MP4_480_1_5MG.mp4 split-video

Output:

[PySceneDetect] PySceneDetect 0.6.4
[PySceneDetect] Failed to open video with opencv: Ensure file is valid video and system dependencies are up to date.

Usage: scenedetect [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...
Try 'scenedetect -h' for help.

Error: Invalid value for -i/--input: Failed to open input video using opencv backend: Ensure file is valid video and system dependencies are up to date.

Environment:

[PySceneDetect] PySceneDetect 0.6.4

System Info
------------------------------------------------------------
OS           Linux-5.14.0-362.24.1.el9_3.0.1.x86_64-x86_64-with-glibc2.35
Python       3.10.12

Packages
------------------------------------------------------------
av           12.3.0
click        8.1.7
cv2          4.7.0
moviepy      1.0.3
numpy        1.24.4
platformdirs 4.2.0
scenedetect  0.6.4
tqdm         4.66.2

Tools
------------------------------------------------------------
ffmpeg       4.4.2-0ubuntu0.22.04.1
mkvmerge     v65.0.0 ('Too Much') 64-bit

Media: https://file-examples.com/wp-content/storage/2017/04/file_example_MP4_480_1_5MG.mp4

kehuanfeng commented 3 months ago

BTW, I can use ffmpeg to cut the sample video file successfully,

ffmpeg -i file_example_MP4_480_1_5MG.mp4 -ss 10 -t 5 new_example.mp4
Breakthrough commented 3 months ago

It seems that OpenCV is failing to open that video. You can try using a different backend like PyAV:

scenedetect -i file_example_MP4_480_1_5MG.mp4 -b pyav split-video

Can you try that and/or MoviePy and let me know if that works for you?