Comments (5)
There is the -m
, --min-scene-len
option you can give to scenedetect (documentation here). This takes a timecode as an argument and will ignore any detected scene transitions that happen less that that amount of time or number of frames since the previous transition.
For example
scenedetect -i video.mp4 -m 5s detect-content
would ignore any detected scene transitions that happen less than 5 seconds from the previous detected scene transition. So, it would just be part of the scene before it.
from pyscenedetect.
There is the
-m
,--min-scene-len
option you can give to scenedetect (documentation here). This takes a timecode as an argument and will ignore any detected scene transitions that happen less that that amount of time or number of frames since the previous transition.For example
scenedetect -i video.mp4 -m 5s detect-contentwould ignore any detected scene transitions that happen less than 5 seconds from the previous detected scene transition. So, it would just be part of the scene before it.
Ok, thank you very much. Could you plz tell me the python call api equivalent to this CLI?
from pyscenedetect.
Using the python api, you would set min_scene_len
per detector when you create it (default is 15 frames, see here for definition in the __init__
function of the ContentDetector
). So, you would construct your detector while defining min_scene_len
like ContentDetector(min_scene_len=30)
to set it to 30 frames instead of the default 15. You can see a basic python api example here. In this example, you would define it in the constructor for ContentDetector
when you are calling the add_detector
function.
One difference between the cli and python api is, I believe, the python api expects min_scene_len
to be an int corresponding to a minimum number of frames. By contrast, using the cli, you can either specify the number of frames or a timecode. If you need to programatically find the framerate of your video, you should be able to access that through a property of the VideoStream
object. So, let's say you open video.mp4
using
from scenedetect import open_video
video = open_video("video_file.mp4") # This returns a VideoStream object
you can then access the framerate of the video through video.frame_rate
.
@Breakthrough I am just realizing from this conversation how the cli and python api treat min_scene_len
differently. Is my understanding of this correct? And, if so, should min_scene_len
be made more flexible for the python api in a future version or set at the SceneManager
level rather than per detector?
from pyscenedetect.
Your understanding is correct! The current API could be updated to use a FrameTimecode
for detectors.
The idea I have for the long-term 1.0 API would be something where detectors simply generate a set of events (e.g. Event.CUT, Event.START for fade in, Event.END for fade out), and feed those to a SceneManager. Then, SceneManager could be responsible for actually respecting min_scene_len by dropping CUT events that are too close together when you call get_scene_list()
. One benefit of doing this as a post-processing step is the ability to call multiple times with different lengths without needing to run detection again. This would break how callbacks currently work, but perhaps that is okay as doing this kind of filtering online in a callback is relatively easy (e.g. ignore Event.CUTs that are just too close to the last one).
That being said your suggestion is a good idea and might bring us one step closer to that vision. It's certainly possible to deprecate min_scene_len
on detectors, and add a new argument for that purpose to SceneManager.get_scene_list()
. One downside of this approach though is it will not work correctly with the callback
function that detect_scenes()
takes, so this may need to be an intrinsic property of a given detection run (e.g. passed to detect_scenes()
or made a property of SceneManager
) and handled as an online filter.
from pyscenedetect.
thanks!close
from pyscenedetect.
Related Issues (20)
- Fix Github license detection
- How run it with asyncio and fastapi
- The performance of detecting shot changes is poor HOT 5
- Change `list-scenes` defaults: don't output file, skip cuts
- [Bug] memory leak HOT 9
- Remove this issue please
- How to detect entire scenes and not only shot changes? HOT 1
- Add StreamJoiner to concatenate multiple videos
- Inconsistent error handling when start time exceeds video length
- url input ,1080p video much slower HOT 8
- Use csv as input for scene splitting HOT 1
- No output to list-scenes HOT 3
- horizontal wipe cuts
- ffmpeg segment_times options HOT 4
- QP file output HOT 4
- Can't get save_images to work HOT 1
- 'Error splitting video (ffmpeg returned 1) ' occurs while using 'split_video_ffmpeg' HOT 6
- Define minimum and maximum number of splits in split-video HOT 1
- Extend image_name_template to allow timestamp HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyscenedetect.