Question How to automatically start recording a stream via streamlink when it goes live?

xestry

Bathwater Drinker
Aug 1, 2022
56
1,837
1,252
0fya082315al84db03fa9bf467e3.png
I'm currently using the below command line in Powershell to record (taken out the URL + file paths of course). However I have to manually start this when I see a stream go live. Is there a way to add something to this command so it can just automatically start recording if/when a stream begins without me having to manually do it?

streamlink -o "P:\.ts" --twitch-proxy-playlist=https://lb-eu2.cdn-perfprod.com,https//lb-eu.cdn-perfprod.com,https://lb-as.cdn-perfprod.com,https://lb-na.cdn-perfprod.com --hls-live-restart "
Please, Log in or Register to see links and images
" best
 
  • Like
Reactions: yticpmis234

dripping-cannon

Superfan
Nov 3, 2022
39
739
932
0fya082315al84db03fa9bf467e3.png
I dunno how to do it in Windows as I am not really a Windows user.

In a linux box though I use the script below to automatically retry streamlink, with a filename that says the date and time, on a network drive.


#!/bin/bash

while true
do
/home/FOLDERNAME/Streamlink/streamlink-current.AppImage --afreeca-user USENAME --afreeca-password PASSWORD --retry-streams 120 --stream-timeout 50 --stream-segment-threads 10 --stream-segment-attempts 30 --stream-segment-timeout 20 --hls-live-edge 10 --ringbuffer-size 600M play.afreecatv.com/CHANNELNAME original -o /mnt/hgfs/Streamlink_target/CHANNELNAME-{time:%y%m%d-%H%M}.ts
sleep 40
done


Hope it helps.
 

nitropenta

Bathwater Drinker
Mar 11, 2022
35
3,025
1,242
0fya082315al84db03fa9bf467e3.png
I can offer a Windows solution, as I recently had to solve the same issue myself. This is code lifted from first-page google, and in the same vein as the linux script above.

Paste it into a .txt file and change the file extension to .ps1 (powershell script). If you put it on your path, you're able to call it via the filename (minus extension) from a powershell instance, provided you first enable the execution of unsigned scripts in powershell. There are guides on how to do that if you search for it. When you call the script, it will ask you to input a channel - so, the bit that comes after
Please, Log in or Register to see links and images


It's a simple while loop. You can use any streamlink command, but pay attention to how the $channel and $timestamp parameters are used here to increase functionality.

param( [Parameter(Mandatory=$true)] $channel ) function StreamlinkLoop { $timestamp = Get-Date -Format "yyyy-MM-ddTHHmm" streamlink.exe -o "P:\$channel - $timestamp.mp4" https://www.twitch.tv/$channel best --retry-streams 180 --ringbuffer-size 128M --twitch-disable-hosting --hls-live-restart --twitch-disable-ads } while ($true) { StreamlinkLoop }