Skip to content

Commit

Permalink
new post added
Browse files Browse the repository at this point in the history
  • Loading branch information
downIoads committed Oct 15, 2023
1 parent 388b1e6 commit f32653f
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 23 deletions.
24 changes: 20 additions & 4 deletions content/posts/twitch-adblock-streamlink.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
---
title: "Blocking Twitch Ads by using streamlink to stream to VLC"
title: "Blocking Twitch Ads by piping the stream to VLC"
date: 2023-10-14T08:00:23+02:00
description: Your Browser adblocker is not working on Twitch? Read this.
description: Your browser's ad blocker is not working on Twitch? Read this.
draft: false
tags: [windows, tutorial]
---

## Introduction
Twitch keeps changing their backend, and it recently became more difficult to block ads. A few years ago, any ad blocker seemed to work just fine. Then they changed their code, and uBlock Origin, Adblock Plus, etc. all fail to remove ads. While there are still browser plugins that promise to block Twitch ads, many of them are potentially shady, as they route your traffic over some proxy server that does who-knows-what. Since I don't like routing my traffic over shady servers and I want to avoid testing browser extensions that have way too many privileges, I tried to find a different approach. IMO, the best way is to use [Streamlink](https://github.com/streamlink/streamlink), which is an excellent tool for routing a stream to a video player you have installed locally. It supports plugins, and there are [many plugins](https://streamlink.github.io/plugins.html#twitch) available.
Twitch keeps changing their backend, and it recently became more difficult to block ads. A few years ago, any ad blocker seemed to work just fine. Then they changed their code, and uBlock Origin, Adblock Plus, etc. all fail to remove ads. While there are still browser plugins that promise to block Twitch ads, many of them are potentially shady, as they route your traffic over some proxy server that does who-knows-what. Since I don't like routing my traffic over shady servers and I want to avoid testing browser extensions that have way too many privileges, I tried to find a different approach. In this post, I will talk about two approaches:
* [Streamlink](https://github.com/streamlink/streamlink), which is an excellent tool for routing a stream to a video player you have installed locally. It supports plugins, and there are [many plugins](https://streamlink.github.io/plugins.html#twitch) available
* [Yt-dlp](https://github.com/yt-dlp/yt-dlp), which is a better version of the well-known youtube-dl.

## Setup
Install VLC and add it to your path. This just looks better than having to type out the full path to the VLC executable in the commands later.

### Streamlink
The setup on Windows is simple: install the required Python version, download the binary for your version, add VLC to the path, and then just use the following command in the terminal:
```cmd
streamlink.exe -p vlc <twitch-channel-url> best --twitch-disable-ads
Expand All @@ -26,5 +31,16 @@ If you read through the [Twitch Plugin Documentation](https://streamlink.github.

The only hope seems to be to set special API request headers using the "--twitch-access-token-param" flag that might or might not prevent embedded ads. However, even if you find a value that works, it is likely that Twitch will patch the workaround shortly after. Since my goal was to not be annoyed by repetitive ads, I am happy with the current solution of having an automatically paused stream.

### Yt-dlp
I already had this tool on my machine, so after you download it just open a CMD in the folder where yt-dlp.exe lives and run the following command:
```cmd
yt-dlp.exe --get-url "https://www.twitch.tv/mission_anime" | vlc -
```
This stream behaves almost the same as Streamlink without "--twitch-disable-ads". When there is an ad break, you will see the following:

![targets](/images/yt-dlp-twitch.png "Screenshot")

The difference to before is that now this image has an animated background (who cares), but there also is a countdown bottom-right which shows how long the current ad would take. But it turns out that this is useless, because it does not tell you how many ads you would get in a row. So it might go up to 15 seconds three times, which means that even with the countdown you have no idea how long the ad break will take. Sound is muted just like before.

## Conclusion
Streamlink is a good tool for using locally installed video players like VLC instead of having to visit bloated streaming websites. While it does allow you to mute ads (by stopping the video and silencing audio), Twitch does all it can to make it difficult to remove embedded ads. If you truly care about an ad-free Twitch experience, subscribing to Twitch Prime is the easiest and most boring solution.
Yt-dlp and streamlink are both good tools for using locally installed video players like VLC instead of having to visit bloated streaming websites. While they do allow you to mute ads (by stopping the video and silencing audio), Twitch does all it can to make it difficult to remove embedded ads. If you truly care about an ad-free Twitch experience, subscribing to Twitch Nitro or using your monthly Twitch Prime (assuming you have Amazon Prime) on your favorite channel is the easiest and most boring solution. I do think that this post is now more relevant than ever, because Youtube [recently started taking a more aggressive stance in detecting ad blockers...](https://www.ghacks.net/2023/10/10/youtube-is-cracking-down-on-ad-blockers-more-aggressively-heres-how-to-bypass-it/)
Binary file added public/images/d2r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/python_llama_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/streamlink-adblock-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/twitch-stream-adblocking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/yt-dlp-twitch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@


<section class="list-item">
<h1 class="title"><a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by using streamlink to stream to VLC</a></h1>
<h1 class="title"><a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by piping the stream to VLC</a></h1>
<time>Oct 14, 2023</time>
<br><div class="description">

Your Browser adblocker is not working on Twitch? Read this.
Your browser&#39;s ad blocker is not working on Twitch? Read this.

</div>
<a class="readmore" href="/posts/twitch-adblock-streamlink/">Read more ⟶</a>
Expand Down
2 changes: 1 addition & 1 deletion public/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<language>en-us</language>
<lastBuildDate>Sat, 14 Oct 2023 08:00:23 +0200</lastBuildDate><atom:link href="https://example.com/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Blocking Twitch Ads by using streamlink to stream to VLC</title>
<title>Blocking Twitch Ads by piping the stream to VLC</title>
<link>https://example.com/posts/twitch-adblock-streamlink/</link>
<pubDate>Sat, 14 Oct 2023 08:00:23 +0200</pubDate>

Expand Down
2 changes: 1 addition & 1 deletion public/posts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1 class="page-title">All articles</h1>


<ul class="posts"><li class="post">
<a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by using streamlink to stream to VLC</a> <span class="meta">Oct 14, 2023</span>
<a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by piping the stream to VLC</a> <span class="meta">Oct 14, 2023</span>
</li><li class="post">
<a href="/posts/hackintosh-ventura-rx6650xt/">Hackintosh #2: Running Ventura using Haswell CPU and a spoofed AMD RX 6650 XT</a> <span class="meta">Oct 10, 2023</span>
</li><li class="post">
Expand Down
2 changes: 1 addition & 1 deletion public/posts/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<language>en-us</language>
<lastBuildDate>Sat, 14 Oct 2023 08:00:23 +0200</lastBuildDate><atom:link href="https://example.com/posts/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Blocking Twitch Ads by using streamlink to stream to VLC</title>
<title>Blocking Twitch Ads by piping the stream to VLC</title>
<link>https://example.com/posts/twitch-adblock-streamlink/</link>
<pubDate>Sat, 14 Oct 2023 08:00:23 +0200</pubDate>

Expand Down
37 changes: 27 additions & 10 deletions public/posts/twitch-adblock-streamlink/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!DOCTYPE html>
<html><head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Blocking Twitch Ads by using streamlink to stream to VLC - Blog for Tech Enjoyers</title><link rel="icon" type="image/png" href=https://www.pngmart.com/files/23/Nerd-Emoji-PNG.png /><meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Your Browser adblocker is not working on Twitch? Read this." />
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Blocking Twitch Ads by piping the stream to VLC - Blog for Tech Enjoyers</title><link rel="icon" type="image/png" href=https://www.pngmart.com/files/23/Nerd-Emoji-PNG.png /><meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Your browser&#39;s ad blocker is not working on Twitch? Read this." />
<meta property="og:image" content=""/>
<meta property="og:title" content="Blocking Twitch Ads by using streamlink to stream to VLC" />
<meta property="og:description" content="Your Browser adblocker is not working on Twitch? Read this." />
<meta property="og:title" content="Blocking Twitch Ads by piping the stream to VLC" />
<meta property="og:description" content="Your browser&#39;s ad blocker is not working on Twitch? Read this." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://example.com/posts/twitch-adblock-streamlink/" /><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2023-10-14T08:00:23+02:00" />
<meta property="article:modified_time" content="2023-10-14T08:00:23+02:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Blocking Twitch Ads by using streamlink to stream to VLC"/>
<meta name="twitter:description" content="Your Browser adblocker is not working on Twitch? Read this."/>
<meta name="twitter:title" content="Blocking Twitch Ads by piping the stream to VLC"/>
<meta name="twitter:description" content="Your browser&#39;s ad blocker is not working on Twitch? Read this."/>
<script src="https://example.com/js/feather.min.js"></script>

<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel="stylesheet">
Expand Down Expand Up @@ -47,7 +47,7 @@

<article>
<div class="title">
<h1 class="title">Blocking Twitch Ads by using streamlink to stream to VLC</h1>
<h1 class="title">Blocking Twitch Ads by piping the stream to VLC</h1>
<div class="meta">Posted on Oct 14, 2023</div>
</div>

Expand All @@ -58,7 +58,12 @@ <h1 class="title">Blocking Twitch Ads by using streamlink to stream to VLC</h1>
<nav id="TableOfContents">
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#setup">Setup</a></li>
<li><a href="#setup">Setup</a>
<ul>
<li><a href="#streamlink">Streamlink</a></li>
<li><a href="#yt-dlp">Yt-dlp</a></li>
</ul>
</li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</nav>
Expand All @@ -68,8 +73,14 @@ <h1 class="title">Blocking Twitch Ads by using streamlink to stream to VLC</h1>

<section class="body">
<h2 id="introduction">Introduction</h2>
<p>Twitch keeps changing their backend, and it recently became more difficult to block ads. A few years ago, any ad blocker seemed to work just fine. Then they changed their code, and uBlock Origin, Adblock Plus, etc. all fail to remove ads. While there are still browser plugins that promise to block Twitch ads, many of them are potentially shady, as they route your traffic over some proxy server that does who-knows-what. Since I don&rsquo;t like routing my traffic over shady servers and I want to avoid testing browser extensions that have way too many privileges, I tried to find a different approach. IMO, the best way is to use <a href="https://github.com/streamlink/streamlink">Streamlink</a>, which is an excellent tool for routing a stream to a video player you have installed locally. It supports plugins, and there are <a href="https://streamlink.github.io/plugins.html#twitch">many plugins</a> available.</p>
<p>Twitch keeps changing their backend, and it recently became more difficult to block ads. A few years ago, any ad blocker seemed to work just fine. Then they changed their code, and uBlock Origin, Adblock Plus, etc. all fail to remove ads. While there are still browser plugins that promise to block Twitch ads, many of them are potentially shady, as they route your traffic over some proxy server that does who-knows-what. Since I don&rsquo;t like routing my traffic over shady servers and I want to avoid testing browser extensions that have way too many privileges, I tried to find a different approach. In this post, I will talk about two approaches:</p>
<ul>
<li><a href="https://github.com/streamlink/streamlink">Streamlink</a>, which is an excellent tool for routing a stream to a video player you have installed locally. It supports plugins, and there are <a href="https://streamlink.github.io/plugins.html#twitch">many plugins</a> available</li>
<li><a href="https://github.com/yt-dlp/yt-dlp">Yt-dlp</a>, which is a better version of the well-known youtube-dl.</li>
</ul>
<h2 id="setup">Setup</h2>
<p>Install VLC and add it to your path. This just looks better than having to type out the full path to the VLC executable in the commands later.</p>
<h3 id="streamlink">Streamlink</h3>
<p>The setup on Windows is simple: install the required Python version, download the binary for your version, add VLC to the path, and then just use the following command in the terminal:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cmd" data-lang="cmd"><span style="display:flex;"><span>streamlink.exe -p vlc &lt;twitch-channel-url&gt; best --twitch-disable-ads
</span></span></code></pre></div><p>This will automatically open VLC with the Twitch stream playing at the highest quality. The last parameter &ldquo;&ndash;twitch-disable-ads&rdquo; is taken from the Twitch Plugin documentation and sadly does not work as it should: while an ad is playing, the stream stops (frame freezes) and only continues after the ad is over (you don&rsquo;t see or hear anything of the ad). The same behavior happens if you don&rsquo;t use the &ldquo;&ndash;twitch-disable-ads&rdquo; flag. The only difference here is that the frozen frame shown is not the last frame of the stream you are watching, but instead the Twitch banner shown below:</p>
Expand All @@ -78,8 +89,14 @@ <h2 id="setup">Setup</h2>
<p><img src="/images/streamlink-adblock-error.png" alt="targets" title="Screenshot"></p>
<p>If you read through the <a href="https://streamlink.github.io/cli/plugins/twitch.html#embedded-ads">Twitch Plugin Documentation</a>, you will notice that the authors mention this problem. While VLC did not crash for me, there were stream discontinuity warnings shown in the command line. But using a different player than VLC will not fix this issue, the authors of the documentation write: &ldquo;Unfortunately, entirely preventing embedded ads is not possible unless a loophole on Twitch gets discovered which can be exploited. This has been the case a couple of times now and ad-workarounds have been implemented in Streamlink (see #3210) and various ad-blockers, but the solutions did only last for a couple of weeks or even days until Twitch patched these exploits.&rdquo;</p>
<p>The only hope seems to be to set special API request headers using the &ldquo;&ndash;twitch-access-token-param&rdquo; flag that might or might not prevent embedded ads. However, even if you find a value that works, it is likely that Twitch will patch the workaround shortly after. Since my goal was to not be annoyed by repetitive ads, I am happy with the current solution of having an automatically paused stream.</p>
<h3 id="yt-dlp">Yt-dlp</h3>
<p>I already had this tool on my machine, so after you download it just open a CMD in the folder where yt-dlp.exe lives and run the following command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cmd" data-lang="cmd"><span style="display:flex;"><span>yt-dlp.exe --get-url <span style="color:#e6db74">&#34;https://www.twitch.tv/mission_anime&#34;</span> | vlc -
</span></span></code></pre></div><p>This stream behaves almost the same as Streamlink without &ldquo;&ndash;twitch-disable-ads&rdquo;. When there is an ad break, you will see the following:</p>
<p><img src="/images/yt-dlp-twitch.png" alt="targets" title="Screenshot"></p>
<p>The difference to before is that now this image has an animated background (who cares), but there also is a countdown bottom-right which shows how long the current ad would take. But it turns out that this is useless, because it does not tell you how many ads you would get in a row. So it might go up to 15 seconds three times, which means that even with the countdown you have no idea how long the ad break will take. Sound is muted just like before.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Streamlink is a good tool for using locally installed video players like VLC instead of having to visit bloated streaming websites. While it does allow you to mute ads (by stopping the video and silencing audio), Twitch does all it can to make it difficult to remove embedded ads. If you truly care about an ad-free Twitch experience, subscribing to Twitch Prime is the easiest and most boring solution.</p>
<p>Yt-dlp and streamlink are both good tools for using locally installed video players like VLC instead of having to visit bloated streaming websites. While they do allow you to mute ads (by stopping the video and silencing audio), Twitch does all it can to make it difficult to remove embedded ads. If you truly care about an ad-free Twitch experience, subscribing to Twitch Nitro or using your monthly Twitch Prime (assuming you have Amazon Prime) on your favorite channel is the easiest and most boring solution. I do think that this post is now more relevant than ever, because Youtube <a href="https://www.ghacks.net/2023/10/10/youtube-is-cracking-down-on-ad-blockers-more-aggressively-heres-how-to-bypass-it/">recently started taking a more aggressive stance in detecting ad blockers&hellip;</a></p>

</section>

Expand Down
2 changes: 1 addition & 1 deletion public/tags/tutorial/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>Entries tagged - "tutorial"</h1>


<ul class="posts"><li class="post">
<a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by using streamlink to stream to VLC</a> <span class="meta">Oct 14, 2023</span>
<a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by piping the stream to VLC</a> <span class="meta">Oct 14, 2023</span>
</li><li class="post">
<a href="/posts/how-to-calculate-any-weekday/">How to calculate any weekday</a> <span class="meta">Jul 4, 2023</span>
</li><li class="post">
Expand Down
2 changes: 1 addition & 1 deletion public/tags/tutorial/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<language>en-us</language>
<lastBuildDate>Sat, 14 Oct 2023 08:00:23 +0200</lastBuildDate><atom:link href="https://example.com/tags/tutorial/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Blocking Twitch Ads by using streamlink to stream to VLC</title>
<title>Blocking Twitch Ads by piping the stream to VLC</title>
<link>https://example.com/posts/twitch-adblock-streamlink/</link>
<pubDate>Sat, 14 Oct 2023 08:00:23 +0200</pubDate>

Expand Down
2 changes: 1 addition & 1 deletion public/tags/windows/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>Entries tagged - "windows"</h1>


<ul class="posts"><li class="post">
<a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by using streamlink to stream to VLC</a> <span class="meta">Oct 14, 2023</span>
<a href="/posts/twitch-adblock-streamlink/">Blocking Twitch Ads by piping the stream to VLC</a> <span class="meta">Oct 14, 2023</span>
</li><li class="post">
<a href="/posts/d2-runewords/">C&#43;&#43; runeword calculator GUI for Diablo 2 Resurrected</a> <span class="meta">Jul 27, 2023</span>
</li><li class="post">
Expand Down
2 changes: 1 addition & 1 deletion public/tags/windows/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<language>en-us</language>
<lastBuildDate>Sat, 14 Oct 2023 08:00:23 +0200</lastBuildDate><atom:link href="https://example.com/tags/windows/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Blocking Twitch Ads by using streamlink to stream to VLC</title>
<title>Blocking Twitch Ads by piping the stream to VLC</title>
<link>https://example.com/posts/twitch-adblock-streamlink/</link>
<pubDate>Sat, 14 Oct 2023 08:00:23 +0200</pubDate>

Expand Down
Binary file added static/images/yt-dlp-twitch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f32653f

Please sign in to comment.