Right click has been disabled on this site.

Streaming Recorded Videos to Twitch

Every now and again I have a need to stream pre-recorded videos to the Twitch Platform. It took me awhile to work out how this can be achieved which turned out to be a multi-step process.

In my case, I have a Rock64 single board computer running Ubuntu and Windows File Sharing (SMB), this has allowed me to create a network drive where I can put in a mp4 file and once this is seen, the rock64 will begin automatically streaming to twitch.

The first step is to install a program called Watchman which was initially developed by Facebook, it allows a folder to be monitored and when a specific file, or extension is detected it can be used to trigger an event.

The Instructions for watchman can be found here.

In terms of configuring watchman, I used the following command;

sudo watchman — trigger /home/rock64/share ‘*.mp4' — sh /home/rock64/push1.sh

This command tells watchman to watch the directory /home/rock64/share, and if it sees any file with the MP4 extension it should run the push1.sh script at /home/rock64/

The push1.sh script is fairly simple, and can be seen below;

for i in $@
ffmpeg -re -i $i -c copy -g 30 -f flv “rtmp://live-syd.twitch.tv/app/live_#TWITCHKEY”
rm $i

This command basically loops through each of the files, and runs FFMPEG to stream the file to the rtmp server address which can be found from twitch. I have not tried multiple files (I suspect it might try to play more than one) but for one file it seems to work fine.

Comments are closed.