Open bharathyes opened 3 years ago
Related: #22 #23
Given how many times this has been requested I've changed my mind and intend to implement it at as an option at some point in future, with a warning indicating that it can cause stutter
@faissaloo I am curious as to what filters are used and the reason/benefits of them.
Is it just to avoid the stutters from trimming encoded files or is there more to it?
@bharathyes
@faissaloo I am curious as to what filters are used and the reason/benefits of them.
Is it just to avoid the stutters from trimming encoded files or is there more to it?
It's moreso that it was the way straightforward way I'd found of doing it. The filters used are asplit,split and concat, this is the code that handles cutting: https://github.com/faissaloo/SponSkrub/blob/3077602bff10463e5e87af2c8eb95ed285d21336/src/sponskrub/methods/cut.d#L51
Is trimming videos using ffmpeg a possibility instead of re-encoding it? Skipping chapters isn't always convenient in all devices TBH.
I was able to use these two ffmpeg commands to get desired result in bash, in case it could be adapted to DLang.
To create chunks of desired segments:
ffmpeg -nostdin -i input.mp4 -ss 00:03:00 -to 00:07:00 -c copy -movflags +faststart output.mp4
Merge the segments into a single video file:
ffmpeg -nostdin -f concat -safe 0 -i mylist.txt -c copy -movflags +faststart output.mp4
mylist.txt contains all segment filenames in format like:
My script: https://gist.github.com/bharathyes/43cc91f81e8506fc47a03591025cde75
I hope this can be done in SponSkrub since it already utilizes ffmpeg. If this has already been implemented or attempted, I would be really happy.
I am unsure of the format of data received from Sponsorblock API but this method only requires the file names and the timestamps. It should be simple to mirror the timestamps from the API to select the non-sponsor segments from it.
PS:
This is magnitudes faster than re-encoding. For me it takes less than a minute to cut out an hour long file into 5 chunks and merge back again. So this could be a valuable option.