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

Modify --min-duration arguments to accept a timecode instead of frame numbers #128

Merged
merged 3 commits into from
Nov 24, 2019

Conversation

tonycpsu
Copy link
Contributor

@tonycpsu tonycpsu commented Nov 9, 2019

  • Add new -m/--min-duration option for specifying a minimum number
    of seconds for each scene.
  • Scenes shorter than this value will be merged with subsequent
    scenes, or if -M/--min-duration-action is set to drop, dropped
    from the scene list entirely.

* Add new `-m`/`--min-duration` option for specifying a minimum number
  of seconds for each scene.
* Scenes shorter than this value will be merged with subsequent
  scenes, or if `-M`/`--min-duration-action` is set to `drop`, dropped
  from the scene list entirely.
@Breakthrough
Copy link
Owner

I like where this PR is going in terms of maintainability, but this essentially depreciates the --min-scene-len option for both detect-content and detect-threshold. I'm open to that for sure to make adding detectors easier in the future, but would like to make sure the existing detectors are modified accordingly to remove the redundant option.

(Or was there a reason you kept -m for the detectors as well that I might be missing? Just want to discuss this briefly before making any decisions, thanks for the PR!)

@tonycpsu
Copy link
Contributor Author

tonycpsu commented Nov 9, 2019

Er, I wish I had a better answer than "I completely forgot about --min-scene-len, but I don't... 🙈

I do think there's merit in using seconds rather than frames, as FPS varies, and I kind of feel like most people would want to specify a number of seconds. But that would break backwards compatibility for not much gain...

I also think the option to have short scenes prepended/appended to neighbors might be valuable to some, but it wasn't really my primary motivation for this, so maybe this was just a poorly-conceived idea.

Will check out if --min-scene-len works for my purposes.

@Breakthrough
Copy link
Owner

Breakthrough commented Nov 9, 2019

One other option which might work is modifying --min-scene-len to accept a timecode instead of number of frames. I completely agree that there is merit in using a unit other than frames for that purpose; for transparency, the --min-scene-len option was added before PySceneDetect actually supported timecodes.

Now that the parsing is done for them though, modifying --min-scene-len to accept any of the timecode formats would be trivial (all the parsing work is done if you look at the time command).

I would be happy to accept a PR that modifies that, or to have you submit a feature request for it. Thoughts?


The more I think about it, while I like not having to reimplement --min-scene-len for each detector, it would change the output if it was a global option for the whole program versus each detector. I'm honestly just not sure what the most appropriate use-case is for the end user; having it as a global option would be more maintainable, but allow less flexibility. Any feedback you have in that regard would be most welcome.

@tonycpsu
Copy link
Contributor Author

For now, I've just reverted my implementation and added timecode parsing for the existing option as you suggested.

I do think there's merit to allowing users to drop short scenes (it appears the current implementation just prepends them to the next scene?), and maybe some simplicity to doing it after the scene list is generated instead of in the detection code, but this'll do for now.

@Breakthrough Breakthrough changed the title Support merging/dropping of short scenes. Modify --min-duration arguments to accept a timecode instead of frame numbers Nov 10, 2019
@Breakthrough
Copy link
Owner

Breakthrough commented Nov 10, 2019

Thanks so much for this, @tonycpsu! Sorry I don't have a Travis.CI setup for the project yet, so still need to run all the unit tests on this before merging, but I don't expect any issues (again thank you for submitting very small/targeted code changes, it really helps!)

Will do my best to get this tested & merged by end of the week. Thank you again for your submission, really appreciate it!

@Breakthrough Breakthrough added this to the v0.5.2 milestone Nov 10, 2019
@Breakthrough Breakthrough self-assigned this Nov 10, 2019
@Breakthrough
Copy link
Owner

Tested manually for now; still requires documentation update. Will try to get that pushed to this PR so it can go in for this weekend.

Sorry for the delay, and thanks again for your submission!

@Breakthrough Breakthrough merged commit 2d462e3 into Breakthrough:master Nov 24, 2019
Breakthrough added a commit that referenced this pull request Nov 24, 2019
Update documentation for PR #128.

Ref. #131 for future work on this option (to be merged).
@Breakthrough
Copy link
Owner

Breakthrough commented Nov 24, 2019

Documentation updated in latest ( https://pyscenedetect-manual.readthedocs.io/en/latest/cli/detectors.html ). Default value for both -m options changed from 15 frames to 0.6 seconds. Feel free to provide any comments if you feel this new default isn't a good choice, or if you notice anything in the new documentation. All unit tests passing, and the existing implementation allowed for drop-in replacement of the frame # with a timecode (very nice!).

Thanks again for the pull request!

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

Successfully merging this pull request may close these issues.

None yet

2 participants