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

Find start and end of black frame sequences #409

Open
tormento opened this issue Aug 7, 2024 · 2 comments
Open

Find start and end of black frame sequences #409

tormento opened this issue Aug 7, 2024 · 2 comments

Comments

@tormento
Copy link

tormento commented Aug 7, 2024

I have a episodic series that has wrong chapters for the end of openings and the start of endings.

I'd like to recreate the correct OP and ED chapters, finding the ranges of the start and the end of the black frames sequences, that are after a OP and before the ED.

Is it possibile with your useful tool? If not, would you please add that feature?

There are 1000+ episodes, so finding them by hand is a big no.

Thank you!

@tormento tormento changed the title Find start and end of black frames Find start and end of black frame sequences Aug 7, 2024
@Breakthrough
Copy link
Owner

Breakthrough commented Aug 9, 2024

Right now it would be a bit verbose but it is possible. With the threshold detector, you can find ranges where there are black frame sequences. However, by default, the output of this detector is a cut placed in the middle of the range.

This can be controlled by the fade bias parameter. With that, you can run detection twice: once with fade bias at -1.0, and another at +1.0. The first run would place the cuts at the start of the black frame sequence, and the second run would place them at the end. The downside is you need to run detection twice and process multiple output files, but it is possible.


That being said, we are working on API improvements to support these kinds of use cases. I don't know how long it will take for those to get to the CLI tool however, but you could hack this into a custom build pretty easily even as-is by logging timecodes at each fade-in/fade-out event in ThresholdDetector.

The fade-out trigger is here:

# Just faded out of a scene, wait for next fade in.
self.last_fade['type'] = 'out'
self.last_fade['frame'] = frame_num

And the fade-in trigger:

elif self.last_fade['type'] == 'out' and (
(self.method == ThresholdDetector.Method.FLOOR and frame_avg >= self.threshold) or
(self.method == ThresholdDetector.Method.CEILING and frame_avg < self.threshold)):
# Only add the scene if min_scene_len frames have passed.
if (frame_num - self.last_scene_cut) >= self.min_scene_len:
# Just faded into a new scene, compute timecode for the scene
# split based on the fade bias.
f_out = self.last_fade['frame']
f_split = int(
(frame_num + f_out + int(self.fade_bias * (frame_num - f_out))) / 2)
cut_list.append(f_split)
self.last_scene_cut = frame_num
self.last_fade['type'] = 'in'
self.last_fade['frame'] = frame_num

In both cases, you could just print frame_num before any other processing happens there to quickly log the frames when the in/out events occur.


Thanks for posting this by the way, I'll need to investigate more about how we would handle outputting this information for the command line tool. Do you have any suggestions? #323 has been open for a while to expand the output formats of PySceneDetect, but I haven't had the time to make any meaningful progress yet. If someone is willing to help out with that it would be greatly appreciated.

@tormento
Copy link
Author

tormento commented Sep 18, 2024

As I wrote in #388 QP output file would be more than welcome.

OGM chapter format would be nice too to have.

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