instance01 / Twitch-HLS-AdBlock

Block advertisements that are inserted in Twitch streams directly.
MIT License
261 stars 24 forks source link

Breaks stream when midroll ads appear #11

Open instance01 opened 5 years ago

instance01 commented 5 years ago

See #10.

I have a tough time actually getting a midroll ad to debug this. It'd a great help if someone encounters such an ad and could attach debug output as described in #8 by @stoically.

instance01 commented 5 years ago

This is most likely fixed with 6dc974a3df7cf7804c43be8a9618111888f951ca, but preroll ads need testing now.

stoically commented 5 years ago

Did some digging and here are my results for a midroll:

Last non-Ad .ts segment

First ad .ts segment

First non-Ad .ts segment

So it seems there's actually a 42s gap without non-Ad segments. Here's the raw HAR with sensitive values replaced.

I've tried to inject a .ts replacement video for the ad segments, generated with

ffmpeg -f lavfi -i color=c=black:s=1920x1080:d=2 -c:v h264 -vf "drawtext=fontfile=/usr/share/fonts/truetype/ubuntu/UbuntuMono-B.ttf:fontsize=60: fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text='Blocking Ads. Stay tuned.'" output.ts

but the player doesn't seem to like that.

Btw, I just noticed that the initial request to https://usher.ttvnw.net/api/channel/hls/<channelname>.m3u8, which serves the urls to the first playlists for the different encodings, has a parameter called show_ads which is set to true. Might be worth trying to rewrite that one to false. 😆

stoically commented 5 years ago

Here's a gist of what I've tried so far regarding injecting the generated ts segment using the webrequest API.