Skip to content

Support for real time video stream SceneDetect #509

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

Open
qtyandhasee opened this issue May 12, 2025 · 3 comments
Open

Support for real time video stream SceneDetect #509

qtyandhasee opened this issue May 12, 2025 · 3 comments

Comments

@qtyandhasee
Copy link

Hello! Thank you for your excellent work, which has allowed me to easily implement offline video scene detection. I would like to ask if PySceneDetect currently supports real-time video stream scene detect. I noticed the VideoStream interface, but my attempts have consistently failed. Can I build a real-time video stream scene detection method by combining it with SceneManager? I look forward to your reply!

@Breakthrough
Copy link
Owner

If you are using OpenCV for video input, you could try the VideoCaptureAdapter which is intended for this use case. Could you let me know if that works for you? Thanks!

@qtyandhasee
Copy link
Author

If you are using OpenCV for video input, you could try the VideoCaptureAdapter which is intended for this use case. Could you let me know if that works for you? Thanks!

Thank you for your answer! With the API you provided, I achieved RTSP real-time video stream reading. Now, I'm testing scene detection time via a callback function in PySceneDetect. I'm wondering if a custom callback passed to detect_scenes is called after each scene cut. In scene_manager.py, the callback comment says it's for the first frame of every new scene. But detect_scenes' docs state the callback is called after each scene/event. Also, does PySceneDetect offer tools to test scene cut time? Looking forward to your reply!Thanks again for your patient response.

@Breakthrough
Copy link
Owner

Now, I'm testing scene detection time via a callback function in PySceneDetect. I'm wondering if a custom callback passed to detect_scenes is called after each scene cut. In scene_manager.py, the callback comment says it's for the first frame of every new scene. But detect_scenes' docs state the callback is called after each scene/event.

Correct - right now the API works on fast-cuts only, which is what "event" refers to. I hope to resolve this in v0.6 with a better API, but I have not yet thought about how it would work with callbacks yet. Expect this code to change significantly when v0.7 is released, and feel free to provide feedback if there is anything you need the callback to do specifically (or more information when it gets invoked).

Also, does PySceneDetect offer tools to test scene cut time?

There's some unit tests that use a fixed set of videos to ensure algorithms don't regress. @awkrail has also been working on benchmarks to compare detector performance/accuracy across a wider data set.

Also note that depending on what detector or parameters you use, the callback won't always be invoked on the same frame the video returns it. Some detectors use a sliding window or a buffer, so only after that length of time (detectors have a event_buffer_length property) has passed will the callback be invoked. If you need lower frame latency, you will need to disable most filters and use a simple detector like ContentDetector with a very low minimum scene length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants