faissaloo / SponSkrub

Strip advertisements from downloaded YouTube videos
GNU General Public License v3.0
177 stars 7 forks source link

Cutting out sections and losslessly combine remaining parts #22

Closed nicolaasjan closed 3 years ago

nicolaasjan commented 3 years ago

I mentioned this on Reddit and @pukkandan suggested me to open an issue here.

If I'm not mistaken, it looks like SponSkrub re-encodes the video with ffmpeg, which takes a very long time and obviously also causes quality loss. It would be nice if the segments were cut out in a lossless way, like the program lossless-cut does.

I'm not a programmer myself, so maybe I'm asking something that's very difficult, or even impossible to implement... If it could be done, it would be an enormous improvement.

faissaloo commented 3 years ago

Doing the actual cutting is the job of ffmpeg, Sponskrub just decides what needs cutting. Looking at what lossless-cut does, it seems like this would be a nightmare to program for little benefit anyway so I won't be implementing this. If complex lossless cutting is a thing people want it should be added to ffmpeg.

nicolaasjan commented 3 years ago

I see... Well that's a pity.

I assumed lossless-cut made use of an existing ffmpeg capability.

pukkandan commented 3 years ago

for little benefit anyway

I don't know how difficult this is to implement (and am not saying you have to do it), but the benefit is most definitely not little. Not only would this make sponskrub's processing lossless, but also much faster. For longer videos, the re-encoding currently takes a significant amount of time. This is one of the reasons I personally use -chapter only. Cutting simply isn't worth the time for me and I just instruct my video player to skip the sponskrub- chapters instead.

nicolaasjan commented 3 years ago

I just instruct my video player to skip the sponskrub- chapters instead.

How can this be done with mpv? Most of the time I play the video's through mpv via the Open With extension.

/usr/bin/mpv --ytdl-format=bestvideo"[height<=1080][ext=mp4]"+bestaudio[ext=m4a]/best[ext=mp4]/best

pukkandan commented 3 years ago

@nicolaasjan I use potplayer

No inbuilt way to to this in mpv afaik. Found this while searching about it: https://github.com/po5/chapterskip

faissaloo commented 3 years ago

@pukkandan

I don't know how difficult this is to implement (and am not saying you have to do it), but the benefit is most definitely not little. Not only would this make sponskrub's processing lossless, but also much faster. For longer videos, the re-encoding currently takes a significant amount of time. This is one of the reasons I personally use -chapter only. Cutting simply isn't worth the time for me and I just instruct my video player to skip the sponskrub- chapters instead.

You make a good point, I'll keep that in mind

@nicolaasjan

I assumed lossless-cut made use of an existing ffmpeg capability.

What lossless-cut seems to do is run a bunch of cuts with separate ffmpeg calls plus some additional restrictions from their end to make sure the cut can be done losslessly to put it simply. It's pretty cool, most of what it's doing is in: https://github.com/mifi/lossless-cut/blob/master/src/ffmpeg.js

nicolaasjan commented 3 years ago

@nicolaasjan I use potplayer

No inbuilt way to to this in mpv afaik. Found this while searching about it: https://github.com/po5/chapterskip

Thanks for the link!

But I couldn't figure out what to put where, so I couldn't make it work with an already downloaded and SponSkrub marked video...

However I found: https://github.com/po5/mpv_sponsorblock This worked when I watch a video (like this one) with mpv streaming via the browser.