How to self-host videos with HLS
My YouTube channel got deleted over a month ago, and these days I am seeing more and more channels getting deleted. Recently, I learned that Ilias Ism's channel also got deleted and the appeal got rejected as well, so he decided to self-host all videos. And the similar thing happened with Pat from StarterStory as well, and now he's also self-hosting videos.
Ilias also wrote a detailed post about his setup of self-hosting videos, and I am going to copy all the text below, in case the X post is no longer live. And it seems like too valuable information to let go.
Yeah, very similar approach! Here's what I did:
- Setup: Hetzner dedicated server (EX63, Intel Core Ultra 7, 64GB RAM, 1TB NVMe)
- Coolify, on Docker -> Nginx -> Filesystem mount to SSD
- Nginx is serving HLS streams directly from disk
- FFmpeg is transcoding to 3 quality levels (360p, 720p, 1080p)
- Also making thumbnails
- On hover there is a preview sprite looping (example: https://video.seoroast.com/i-roasted-this-slack-app-s-seo-guinea-pig/preview-sprite.jpg)
- Cloudflare in front for caching/CDN
💰 Cost: ~€80/month for the dedicated server (which also runs the main app, database, etc)
🧠 The process:
- Upload raw MP4s to server
- Batch convert to HLS with FFmpeg (adaptive bitrate)
- Nginx serves the .m3u8 playlists and .ts segments
- hls.js on the frontend for playback
It's all on the same server - no separate storage service. The 1TB NVMe handles ~100 videos fine.
For thumbnails/sprites I generate those during conversion too.
Main win vs YouTube: No ads, full control over the player, videos load faster, and Google can't delete my channel again 😅
Ilias is encoding videos on the Hetzner server itself, so he doesn't need to keep encoding GBs of video files locally, which seems like a good idea. He converted all his 110 GB of videos to HLS.js, transcoded via FFmpeg, and then transcribed all 2,000 mins of footage with Whisper, as he mentions in this post.
But if you have a machine fast enough and don't have to transcode a lot of videos, you can also transcode your videos locally and then host them on Cloudflare R2. This method is explained in detail in this blog post.
I also found some cool blog posts on self-hosting videos that are worth-reading:
- Self-hosted videos with HLS (vincent.bernat.ch)
- Self-hosting videos with HLS (exoscale.com)
- Self-hosting a streaming video platform (trycatch.dev)
Also, I think the easiest option to self-host videos will be Cloudflare Stream service, a paid service where you can directly upload videos or via an API and then it automatically transcodes in the background. And from here you can embed the video anywhere or share as a URL.
Apart from this, Videopress by WordPress.com can be another good option, but I guess it works only with WordPress. Has a generous pricing tier though.
I also did a post about the same that might be a bit helpful.
- ← Previous
Dual-boot Linux on Windows from an .exe file
Comment via email