gabe565 / CastSponsorSkip

⏭️ Skip YouTube ads and sponsorships on all local Google Cast devices
Apache License 2.0
311 stars 7 forks source link

Add possibility to mute non skipable adverts #7

Open Runesmacher opened 1 year ago

Runesmacher commented 1 year ago

Would it be possible to mute advertisements that can not be skipped? Or just mute all adds in general? These adds are usually played louder then my videos and are therefore quite annoying.

Transfered over from sponsorBlockCast #34

gabe565 commented 1 year ago

Great idea! This should be doable as long as I can reliably detect an ad is playing with go-chromecast.

gabe565 commented 1 year ago

Experimental support for muting ads has been added in v0.3.0! It's disabled by default, and can be enabled by passing the --mute-ads flag or by setting the env CSS_MUTE_ADS=true.

Please try it out and give some feedback in this issue.

schumi4 commented 1 year ago

Works for me with 0.3.2!

nichobi commented 1 year ago

This is very cool! One thing that might be improved is when YouTube plays multiple short ads in a row. Currently it plays the first ad for a moment before muting, unmutes when it ends, then takes a moment before it mutes the next ad. If it's possible to detect multiple ads, it would be neat to keep it muted throughout.

gabe565 commented 1 year ago

@nichobi I agree! That's part of the reason I have this marked as experimental for now. I'd like to keep multiple ads muted, but I also don't want the unmute to be too late or else the actual video could be muted for up to a second. For the initial feature, I decided to be more aggressive on unmute, but I'll definitely be looking to change that balance!

Runesmacher commented 1 year ago

Love the implementation :D It was recently updated in HomeAssistant. It does seems to only mute a second or 2 into the ad everytime, but i always have like a litle loading time before the ad shows? Maybe it can somehow detect this loading? Can i maybe make it check faster in a setting whitout overloading the system? As said before the unmute between ads is a thing, but it does remute them, maybe a configurable time we can find acceptable to have the main vid muted or so?

gabe565 commented 1 year ago

Thank you! I'll see if I can make it mute while an ad is buffering. It should be even quicker thank that, though. What do you have CSS_PLAYING_INTERVAL set to? I would recommend setting it to 500ms.

schumi4 commented 1 year ago

I would also suggest (maybe as an option) to mute on first ad, then keep muted in case there are multiple ads until actual video playback is detected. I would gladly sacrifice the first second of the video in order to have consistently muted adverts.

gabe565 commented 1 year ago

I agree, and I've actually tested that out, but unfortunately there's a bit of a tradeoff.

At the moment, it will mute if an ad is currently playing, and unmute otherwise (like if the video starts playing or if it's buffering). This seems fast enough to never cut into the actual video, but the downside is that up to the first half of a second plays for every ad (even when they play consecutively).

I tested changing that functionality so that it would mute when an ad is playing, and stay muted when buffering. This made ads mute much more quickly and fixed the issue of the second ad umuting for a split second, but once ads ended, it would stay muted for up to half of a second of the actual video.

If you think this is acceptable, I could probably add a flag to change this behavior. Some people might prefer missing a tiny bit of the video to ensure the ads are always muted.

I have one other thought I'd like to investigate first. I know Cast devices support queuing videos. I'm not sure if ads show up in the queue, but it would be really nice if I could detect if another ad was upcoming.

Runesmacher commented 10 months ago

Thank you! I'll see if I can make it mute while an ad is buffering. It should be even quicker thank that, though. What do you have CSS_PLAYING_INTERVAL set to? I would recommend setting it to 500ms.

It is indeed set to 500ms, lately i also started noticing a lot more false positives with my video staying muted after some adds :(

gabe565 commented 10 months ago

@Runesmacher Oh no! Do you see anything helpful in the logs when that happens?

Runesmacher commented 10 months ago

Seems that it was my own automation that restarts it that did it at the wrong time 😅 The adds recently started showing this new timer, maybe there is a way to read this one? It is a global timer over all adverts. PXL_20231210_100629414 MP