Twitch-HLS-AdBlock
Twitch-HLS-AdBlock copied to clipboard
Breaks stream when midroll ads appear
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.
This is most likely fixed with 6dc974a3df7cf7804c43be8a9618111888f951ca, but preroll ads need testing now.
Did some digging and here are my results for a midroll:
Last non-Ad .ts segment
- Request time: "Tue, 19 Mar 2019 12:04:39 GMT"
- m3u8 value: #EXT-X-PROGRAM-DATE-TIME:2019-03-19T12:04:36.892Z
First ad .ts segment
- Request time: "Tue, 19 Mar 2019 12:04:41 GMT"
- m3u8 value: #EXT-X-PROGRAM-DATE-TIME:2019-03-19T12:04:38.892Z
First non-Ad .ts segment
- Request time: "Tue, 19 Mar 2019 12:05:21 GMT"
- #EXT-X-PROGRAM-DATE-TIME:2019-03-19T12:05:18.892Z
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. 😆~~
Here's a gist of what I've tried so far regarding injecting the generated ts segment using the webrequest API.