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

Split video based on csv file #294

Merged
merged 5 commits into from Jun 21, 2023

Conversation

wjs018
Copy link
Collaborator

@wjs018 wjs018 commented Oct 25, 2022

As discussed in #235, #275, and #115 this is a frequently requested feature. I have put together a first pass at implementation based on @Breakthrough's outline in #275. I would not say this is in a complete state yet, but wanted to get some eyes on it and feedback as to how some of the details of this command should work. I have outlined the way it currently functions below:

The new detector (load-scenes command from the cli) is designed to use a csv file as input and detect scene transitions based on the scenes in the csv. It doesn't actually do any video or image analysis and it ignores things like min_scene_len or the use of a StatsManager. It also isn't really meant to be used in conjunction with other detectors (though I haven't forbidden it yet). It's main use case is for manually editing a previously generated csv file to tweak the detected scenes and then using that to split the video based on the scenes in the csv file.

    Command: 
        load-scenes
    
    Arguments:
        --input, -i
            Specify path to input csv file. Currently required as no default is set.
        
        --start-col, -s
            Specify the header of the column used to mark the start of new scenes. Column
            contents can be anything parseable by `FrameTimecode`. Defaults to "Start Frame".
        
        --end-col, -e
            Specify the header of the column used to mark the end of scenes. Defaults
            to "End Frame".
        
        --framerate, -f
            Framerate of the video. This is needed only if scene starts and ends
            are specified in timecodes rather than frame numbers to do conversions.

The way this command currently works is that it reads the input csv file row by row and as the video is processed, when the current frame number is equal to the frame number of the next scene start (per the csv), then it "detects" a cut. This means that the csv must be in order from earliest scene to latest. Also, if the start time of the video is later than the first scene in the csv, it will not detect anything. @Breakthrough, is this desired behavior? If not, then I might need some help brainstorming how to change this.

Another important bit to mention is that this detector currently can't skip over unwanted scenes. This is something that was brought up in #275, but I am not sure how to (with the current api) mark scenes to be ignored. The detectors just produce a list of cuts. @Breakthrough I am guessing this is maybe an improvement for a future api change. EDIT: Just stumbled across #123 which is a relevant discussion for this point.

As a corollary to the above point, even if the input csv file doesn't have a scene starting at frame 1, this detector (like all the others), will include a scene the begins at the first frame and goes until the first detected cut (from the csv).

One final point is that currently the --end-col/-e argument is not really used for anything. I debated just getting rid of it entirely, but some of the uses thought up in #275 would require it even though the current api (I don't think) supports them.

This command is compatible with the csv file generated by the list-scenes command as long as the -s flag is included (list-scenes -s). Otherwise, the column headers are not read correctly and the csv file in general is not formatted in a way to programmatically parse. See #243 and #136 for discussion on this.

If it isn't obvious by now, this isn't in a final form yet, but I wanted to get some feedback. I haven't updated any docs or tests yet but can do so if this starts to gel into something approaching a final form.

@wjs018 wjs018 linked an issue Oct 25, 2022 that may be closed by this pull request
@Breakthrough Breakthrough added this to the v0.6.2 milestone Nov 16, 2022
@Breakthrough Breakthrough modified the milestones: v0.6.2, v0.6.3 Feb 6, 2023
@wjs018 wjs018 changed the base branch from v0.6.1 to v0.6.2 April 4, 2023 15:03
@toomanynights
Copy link

Hey!
Just wanted to say that this feature is still very much required, at least in my use case.
I experiment a lot with this amazing tool, but each time something goes wrong, I need to go through the scene detection part again, which could easily be avoided if I could generate a .csv with timeframes for each scene just once and then use it for every subsequent attempt.
Thank you for your amazing work.

@Breakthrough Breakthrough modified the milestones: v0.6.3, v0.6.2 Jun 21, 2023
Copy link
Owner

@Breakthrough Breakthrough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in getting to this, looks like a great starting point. Will get this merged in and moved up to the v0.6.2 release as soon as possible.

Thanks so much for all your help!

@Breakthrough Breakthrough merged commit a4cbd94 into Breakthrough:v0.6.2 Jun 21, 2023
2 checks passed
@wjs018 wjs018 deleted the csv-video-split branch August 30, 2023 04:05
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

Successfully merging this pull request may close these issues.

Split video based on CSV file
3 participants