-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
256 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: "Blocking Twitch Ads by using streamlink to stream to VLC" | ||
date: 2023-10-14T08:00:23+02:00 | ||
description: Your Browser adblocker 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. | ||
|
||
## Setup | ||
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 | ||
``` | ||
This will automatically open VLC with the Twitch stream playing at the highest quality. The last parameter "--twitch-disable-ads" 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't see or hear anything of the ad). The same behavior happens if you don't use the "--twitch-disable-ads" 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: | ||
|
||
![targets](/images/twitch-stream-adblocking.png "Screenshot") | ||
|
||
Okay, but why does the "--twitch-disable-ads" flag not work as expected? I did read in the documentation that VLC is not a recommended video player because of how it handles stream discontinuities. If you look at the CMD output during an ad, it will show: | ||
|
||
![targets](/images/streamlink-adblock-error.png "Screenshot") | ||
|
||
If you read through the [Twitch Plugin Documentation](https://streamlink.github.io/cli/plugins/twitch.html#embedded-ads), 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: "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." | ||
|
||
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. | ||
|
||
## 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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<!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 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: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."/> | ||
<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"> | ||
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet"> | ||
|
||
|
||
<link rel="stylesheet" type="text/css" media="screen" href="https://example.com/css/main.11f18f89079b6a945895b72d837341dfd89f35ac277810cdb01c507ea0faeb47.css" /> | ||
<link id="darkModeStyle" rel="stylesheet" type="text/css" href="https://example.com/css/dark.c95c5dcf5f32f8b67bd36f7dab66680e068fce2b303087294114aabf7a7c080b.css" disabled /> | ||
|
||
|
||
|
||
</head><body> | ||
<div class="content"><header> | ||
<div class="main"> | ||
<a href="https://example.com/">Blog for Tech Enjoyers</a> | ||
</div> | ||
<nav> | ||
|
||
<a href="/posts">Posts</a> | ||
|
||
<a href="/about">About</a> | ||
|
||
<a href="/tags">Tags</a> | ||
|
||
| <a id="dark-mode-toggle" onclick="toggleTheme()" href=""></a> | ||
<script src="https://example.com/js/themetoggle.js"></script> | ||
|
||
</nav> | ||
</header> | ||
<main> | ||
|
||
<article> | ||
<div class="title"> | ||
<h1 class="title">Blocking Twitch Ads by using streamlink to stream to VLC</h1> | ||
<div class="meta">Posted on Oct 14, 2023</div> | ||
</div> | ||
|
||
|
||
<aside> | ||
<hr> | ||
Table of Contents: | ||
<nav id="TableOfContents"> | ||
<ul> | ||
<li><a href="#introduction">Introduction</a></li> | ||
<li><a href="#setup">Setup</a></li> | ||
<li><a href="#conclusion">Conclusion</a></li> | ||
</ul> | ||
</nav> | ||
<hr> | ||
</aside> | ||
|
||
|
||
<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’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> | ||
<h2 id="setup">Setup</h2> | ||
<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 <twitch-channel-url> 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 “–twitch-disable-ads” 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’t see or hear anything of the ad). The same behavior happens if you don’t use the “–twitch-disable-ads” 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> | ||
<p><img src="/images/twitch-stream-adblocking.png" alt="targets" title="Screenshot"></p> | ||
<p>Okay, but why does the “–twitch-disable-ads” flag not work as expected? I did read in the documentation that VLC is not a recommended video player because of how it handles stream discontinuities. If you look at the CMD output during an ad, it will show:</p> | ||
<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: “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.”</p> | ||
<p>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.</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> | ||
|
||
</section> | ||
|
||
<div class="post-tags"> | ||
|
||
|
||
<nav class="nav tags"> | ||
<ul class="tags"> | ||
|
||
<li><a href="/tags/windows">windows</a></li> | ||
|
||
<li><a href="/tags/tutorial">tutorial</a></li> | ||
|
||
</ul> | ||
</nav> | ||
|
||
|
||
</div> | ||
</article> | ||
|
||
|
||
|
||
</main> | ||
<footer> | ||
<div style="display:flex"></div> | ||
<div class="footer-info"> | ||
2023 <a | ||
href="https://github.com/athul/archie">Archie Theme</a> | Built with <a href="https://gohugo.io">Hugo</a> | ||
</div> | ||
</footer> | ||
|
||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.