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

Support for SponsorBlock #136

Closed
hatzel opened this issue Apr 25, 2020 · 7 comments
Closed

Support for SponsorBlock #136

hatzel opened this issue Apr 25, 2020 · 7 comments
Labels
A-ytdl Area: youtube-dl C-enhancement Category: A PR with an enhancement

Comments

@hatzel
Copy link

hatzel commented Apr 25, 2020

It would be great to block sponsor reads as collected in SponsorBlock. This might involve a lot of work (i.e. calling ffmpeg manually) as modifying the actual data would be required.
In principle, however, the feature would not be immensely complicated. FFmpeg can be passed cut-lists and can if desired cut only at key-frames. The SponsorBlock API can easily be used to retrieve the blocked segments.

@hatzel
Copy link
Author

hatzel commented Apr 30, 2020

Turns out this is a lot easier than I thought. Supplying the right arguments to youtube-dl's --postprocessor-args should do the trick, so if you'd be willing to merge something like this (as an opt-in setting in the config file) I'd probably crank out a PR for this in the next few days or weeks.

I'd suggest having one global flag to set up a sponsorblock default which can than be overwritten on a per feed basis.

Maybe something like this:

[sponsorblock]
enable = true
url = "https://sponsor.ajay.app"

[feeds]
  [feed.my_feed]
  ...
  sponsorblock = false

@mxpv
Copy link
Owner

mxpv commented Apr 30, 2020

Could you please provide an example what arguments needs to be passed to youtube-dl? I'm wondering if we can do that in generic way and just give an ability to provide additional arguments to youtube-dl binary.

@mxpv mxpv added A-ytdl Area: youtube-dl C-enhancement Category: A PR with an enhancement labels Apr 30, 2020
@hatzel
Copy link
Author

hatzel commented Apr 30, 2020

Okay, after looking into this a bit more, while the approach works, there are potential problems:

youtube-dl -v --recode-video mkv --postprocessor-args "-filter_complex
   \"[0:v]trim=duration=491.69[av]; [0:a]atrim=duration=491.69[aa];
     [0:v]trim=start=562.16,setpts=PTS-STARTPTS[bv]; [0:a]atrim=start=562.16,asetpts=PTS-STARTPTS[ba];
     [av][bv]concat[outv]; [aa][ba]concat=v=0:a=1[outa]\"
         -map [outv] -map [outa]" \
     -f 18 https://www.youtube.com/watch\?v\=WIVUbBIrbM4

Potential problems arise from the fact that youtube-dl only adds this to FFmpeg invocations. If, however, youtube-dl doesn't even call FFmpeg (which for many formats it doesn't) the arguments are not used. In this case I 'enforced' FFmpeg being called using --recode-video mkv. There may also be situations where FFmpeg is invoked multiple times.

I think the only solution is to call FFmpeg explicitly, after the download has completed, instead. This would mean no modification to the youtube-dl calls are required. Would you be alright with explicitly calling FFmpeg?

For future reference:
The timecodes above were acquired from the Sponsorblock API:
$ http https://sponsor.ajay.app/api/getVideoSponsorTimes\?videoID\=WIVUbBIrbM4

{
    "UUIDs": [
        "96b9e1dc8dc5893e195c1d1f5964eab52ace9081e8568742ab46974b3cd731a2"
    ],
    "sponsorTimes": [
        [
            489.539569,
            562.494883
        ]
    ]
}

ticky added a commit to ticky/podsync that referenced this issue Aug 11, 2020
This allows inserting arbitrary extra arguments into the youtube-dl command-line within each podcast feed entry. This allows, for example, requesting that youtube-dl embed subtitles and captions into the video file, or configuring additional postprocessor arguments.

No effort has been made to make sure no incompatible arguments are provided, with the expectation that the end-user will understand what's possible, and that this is an option expressly for advanced users.

This would fix mxpv#162,and theoretically also mxpv#136!
@ticky
Copy link
Contributor

ticky commented Aug 11, 2020

Hey! I’ve implemented such an “an ability to provide additional arguments to youtube-dl binary” in #163. ☺️

I think for the use case of forcing the postprocessing to occur, @hatzel, I believe adding --add-metadata alongside the --postprocessor-args would likely do the same thing without incurring a video conversion to a different container!

@mxpv mxpv closed this as completed Aug 11, 2020
@shelvacu
Copy link

shelvacu commented Sep 9, 2020

I don't believe this should be closed, SponsorBlock integration can't be done simply with youtube_dl_args. Podsync would need to send a HTTP request to SponsorBlock's API servers, and create the --postprocessor-args accordingly.

@hatzel
Copy link
Author

hatzel commented Sep 10, 2020

I don't really have the time to tackle this currently. So unless someone else is interested it might as wells stay closed :)

@shelvacu
Copy link

I may be willing to work on this, and even if not the closed status makes it seem like this has been implemented, or perhaps won't ever be implemented even with a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ytdl Area: youtube-dl C-enhancement Category: A PR with an enhancement
Projects
None yet
Development

No branches or pull requests

4 participants