How to Record a Twitch Stream Automatically on a VPS

Published on

A practical guide to recording Twitch streams automatically on a VPS with Streamlink, systemd, and safe storage planning.

Written by Jochem, Infrastructure Expert, 5-10 years experience in game server hosting, VPS infrastructure, and 24/7 streaming solutions. Read author bio →

How to Record a Twitch Stream Automatically on a VPS

Record Twitch streams on a VPS

If you want to record a Twitch stream without leaving your own PC on, a small VPS can do the job reliably. The basic stack is simple: Streamlink pulls the live stream, ffmpeg writes the file, and systemd keeps the recorder running. This guide shows the clean version that works for personal archiving and creator workflows.

Before you start

Only record streams you have the right to record. If it is your own stream, a client project, or content you have permission to archive, a VPS recorder is useful. If it is someone else's content, check Twitch rules, local law, and the creator's rights before saving or redistributing anything.

What VPS specs do you need?

Recording is usually not CPU-heavy because Streamlink saves the source stream without re-encoding. Storage and bandwidth matter more.

A good baseline:

  • 2 CPU cores
  • 2-4GB RAM
  • NVMe SSD storage
  • 1Gbps port
  • Enough monthly bandwidth for your bitrate

At 6 Mbps, a stream uses about 2.7GB per hour. A 6-hour stream is roughly 16GB. Keep retention in mind.

Install Streamlink

On Ubuntu/Debian:

sudo apt update
sudo apt install -y python3-pip ffmpeg
python3 -m pip install --user streamlink

Make sure your shell can find it:

~/.local/bin/streamlink --version

A simple recording script

Create /opt/twitch-recorder/record.sh:

#!/usr/bin/env bash
set -euo pipefail

CHANNEL="yourchannel"
OUT_DIR="/var/recordings/twitch"
mkdir -p "$OUT_DIR"

while true; do
  timestamp="$(date +%Y-%m-%d_%H-%M-%S)"
  ~/.local/bin/streamlink \
    --retry-streams 60 \
    --retry-open 5 \
    "https://www.twitch.tv/${CHANNEL}" \
    best \
    -o "${OUT_DIR}/${CHANNEL}_${timestamp}.ts" || true
  sleep 30
done

Then:

sudo mkdir -p /opt/twitch-recorder /var/recordings/twitch
sudo nano /opt/twitch-recorder/record.sh
sudo chmod +x /opt/twitch-recorder/record.sh

The .ts format is safer for live recording than .mp4 because it survives interruptions better. You can remux to MP4 later.

Run it with systemd

Create /etc/systemd/system/twitch-recorder.service:

[Unit]
Description=Twitch automatic recorder
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/opt/twitch-recorder/record.sh
Restart=always
RestartSec=15
User=root

[Install]
WantedBy=multi-user.target

Enable it:

sudo systemctl daemon-reload
sudo systemctl enable --now twitch-recorder
sudo systemctl status twitch-recorder

Logs:

journalctl -u twitch-recorder -f

Storage cleanup

Do not let recordings fill the disk. Add a cleanup timer or cron job:

find /var/recordings/twitch -type f -mtime +14 -delete

That deletes files older than 14 days. Adjust retention to your storage plan.

Remux to MP4

After recording:

ffmpeg -i input.ts -c copy output.mp4

This is fast because it does not re-encode.

Hosting notes

A Netherlands VPS is a strong fit for this because Twitch ingest and playback routes across Europe are stable, and the datacenter connection stays online when your home PC is off. Our VPS hosting gives you root access, NVMe SSD, and enough bandwidth for long-running stream automation.

Bottom line

For automatic Twitch recording, use Streamlink, save to .ts, run it under systemd, and add storage cleanup from day one. The VPS does not need to be huge, but it does need stable network and enough disk for your retention window.


Need a VPS for recording scripts? → View Space-Node VPS hosting - Netherlands datacenter, NVMe SSD, full root access, and DDoS protection.

Jochem

About the Author

Jochem, Infrastructure Expert, expert in game server hosting, VPS infrastructure, and 24/7 streaming solutions with 5-10 years experience.

Since 2023
500+ servers hosted
4.8/5 avg rating

I specialize in Minecraft, FiveM, Rust, and 24/7 streaming infrastructure, operating enterprise-grade AMD Ryzen 9 hardware in Netherlands datacenters.

View my full bio and credentials →

Launch Your 24/7 Stream

Join content creators worldwide who trust our streaming infrastructure. Setup is instant and support is always available.