STFN

Invidious - Open Source Youtube Frontend

10 minutes

20th post for the first anniversary of my blog, woop woop!

Continuing on the theme of degoogling, which I described in more detail in this blog post ,this time I look at alternative ways to watch Youtube. Recently I cut down my YT intake significantly, but there are still great Youtubers that I enjoy watching, and their content is not available anywhere else, so I won’t be leaving the platform entirely. Fortunately, there are ways to watch videos without being too exposed to Google and its shenanigans.

Le what is an Open Source Youtube Frontend?

A few days ago, m0bi mentioned Invidious on Mastodon (toot in Polish). Invidious is an open source alternative front-end to YouTube that can be self hosted, and that combination of words raised my interest. There’s a lot to unpack here, so let’s dissect what exactly is Invidious.

First of all, what is an alternative frontend to Youtube? Youtube, as every webpage has a frontend and a backend. The backend is what is happening beneath the hood, storing video files, database calls, user authentication and authorization, tracking follows and like, all that stuff that needs to happen, but nontechnical users do not care about it all. Frontend is the layer that the user interacts with, what they see, so the actual video player, login screens, like and subscribe buttons. When you go to youtube.com you see the default, official frontend to Youtube. However, it is possible to have your own frontend that will talk to the backend as if it was the official one. This is where Invidious comes in.

Invidious is open source, meaning anyone can see and edit its code, and offer fixes that will be merged to its distribution. It allows you to create accounts that are not Youtube accounts. Thanks to that, you can follow people and build playlist, and the Google overlords will have no data on you. And it does not show ads.

I’ve been using it for a few days, and it has been great. The UI is much cleaner, there are no ads, and there is no algorithm pushing you random videos to watch. The last thing may be a downside to some, but if you migrate from YT and have an established set of people to watch, you won’t miss it. And maybe it will save you from spending too much time watching videos. With all the praise, I however spotted two downsides to Invidious:

To watch videos with Invidious (seriously, I cannot type this name correctly at the first try) you can use one of the official instances listed in the Invidious docs, or self host one. As I am a self hosting nerd, of course I went with the second option.

Self Hosting Invidious

Instructions how to self host Invidious are in its official documentation. I went with the simplified production deployment with Docker, because I do not run a reverse-proxy on my homelab (I will one day sit to it, I swear!)

I cloned the repo to my homelab and generated a secret hash:

git clone https://github.com/iv-org/invidious.git
cd invidious
pwgen 20 1

If you do not have pwgen, just apt install it. The next step is to edit the docker-compose.yml file. I copied the generated hash to the “CHANGE_ME!!” place in the YAML file. Finally I changed the ports stanza from - "127.0.0.1:3000:3000" to - "3010:3000" because as I said, I don’t have a reverse proxy, and also on my homelab port 3000 is already occupied. If you have port 3000 free, don’t change it. All that was left was simply docker compose up -d.

When I opened http://<my_homelab_ip>:3010 I saw a beautifully empty page. I searched for a video in the search bar, and it just played. Perfect.

The next step was to create an account. It’s not required, but it allow you to follow people. Because accounts are hosted locally and not connected to YT in any way, I could name it whatever I want, so I went with the traditional 123qwe username. Imagine trying that on YT, lol.

One final thing

The docs suggest that Invidious should be restarted often, preferably once every hour, so I did it with a cron job. Just fire crontab -e and add the line below at the end of the file, remember to change the path to yours. And if you have an older version of Docker, for you it might docker-compose with a hyphen.

0 * * * * /usr/bin/docker compose -f /home/stefan/Containers/invidious/docker-compose.yml restart

And that’s it, you now have a way to watch Youtube without actually going to Youtube, how cool is that?!

Thanks for reading! And thank you everyone who in the last year read my blog, left me feedback, shared it, liked it, and supported me on Ko-Fi.

Update 06-12-2023

After publishing this post I realized that I cannot set the video resolution to anything higher than 720p. It turned out that this is the default setting, I guess to reduce strain on small servers hosting Invidious.

To change it, go to the settings (little cogwheel in the top right corner), and change the Preferred video quality setting to DASH. This way you will unlock all of the available resolutions of a given video.

Before:

Changing the settings:

After:

You can help with funding my future projects by supporting me on these crowdfunding sites: