Over this past year streaming to Twitch with TouchDesigner has exploded, due to a simplification of the video pipeline. What used to require multiple software apps and video protocols is now just a Top. Rad, I know. If you wanted to stream to Twitch, its as simple as using a Video Stream Out TOP. With the world opening, here and there, little by little, IRL streaming is starting back as well. Vaccines are becoming more available and subsequently I'm 5G'd up, which is perfect for streaming bandwidth! Thanks Bill! (joke). So I guess the real question is can you IRL stream with TouchDesigner?
This Tutorial will cover the basics of getting a phone video stream (SRT) over cellular into TouchDesigner and out to Twitch (RTMP). Let's get into the hardware and software needed to do this. Oh and remember how I said the video pipeline became less complex? Well, it's going to get a little more complicated again, haha.
Smartphone (Android or Apple)
PC/Mac with TouchDesigner on it, connected to the internet
Router with a builtin VPN "optional"
Docker or SRT_mini Server
If you haven't heard of Docker, it is a tool used by software devs to ensure code running on their computers runs on their clients computers. It's a hacker's best frie... nevermind. Docker is great for sharing code and applications between multiple people. It's also free! Yay! Within Docker you have these things called containers, which have the libraries, and code needed to run applications. The container we are going to be running will be an SRT video streaming server.
As an alternative to the SRT docker server, you can use a software called SRTmini Server. It is actually much easier to use and you won't even need the vpn listed above. However, it cost around $30 usd monthly. If you are a company you can get a lifetime license, but I don't know how much that is. Because I don't want to pay 30 dollars monthly for something that I could get for free, we are going to continue this Tutorial as though we are all broke from buying the TD license for the first time and use Docker. Please don't take this post down Derivative, I love you! XD
Why SRT video? SRT (Secure Reliable Transport) offers low latency and high quality with H.265/HEVC encoding. It's new and shiny and gives you better quality video at the same bitrate compared to RTMP. This allows us to run on lower bitrates when the cellular signal is less than ideal, but still maintain good quality video for streaming. Where an RTMP signal would drop out completely an SRT signal may just get a little fuzzy around the edges.
running the SRT server
I am not going to tell you how to install Docker, but encourage you to follow the install instructions that they provide at Get Docker. They have instructions for Mac, Windows, and Linux, so why not learn from the people who made it. Some handy terminal functions docker provides are:
- docker pull, downloads a container image from their online repository of containers
- docker ps, shows the currently running containers
- docker ps -a, shows all containers
- docker run, creates a container from an image and starts it for the first time
- docker start, starts an already existing container
- docker stop, stops a running container
pulling the image
Let's start by pulling the docker container image of the SRT video server we are going to be using.
- open up a terminal
- type out
docker pull ravenium/srt-live-server
- drink some water, hydration is important for an IRL streamer.
running the container for the first time
Normally to start the server, you will just call docker start _your_server_name_ in your terminal. However, that's for containers that exist. We have only downloaded the image of our server, so we will not just need to call docker run _your_server_name_, but will need to give docker a little more information.
From the docker hub page for this container we will need to run the code below in a terminal.
docker run -d -p 1935:1935/udp --name mysrt ravenium/srt-live-server
Now you have successfully installed a virus. Just kidding, but please be aware that not all containers are your friend. Looking at you crypto miner docker containers. Let's break this down to know what each piece of that command means.
- -d tells docker to run this container detached from the current terminal window. Meaning it'll be running as a background process on your pc
- -p 1935:1935/udp tells your computer to bind it's 1935 udp port to the docker container's 1935 port. Change these to your liking, but inlcude the /udp with your pc's port number. This is the port that your phone broadcasting app will eventually try to connect to.
- --name mysrt sets the containers name to "mysrt". You can use this name when you call docker start/stop (docker start mysrt and docker stop mysrt)
- ravenium/srt-live-server is container image's name and must be called at the end
Open a new terminal and type "docker ps", if you see mysrt returned back to you, YOU'VE DONE IT!
The app I am going to use is the Larix Broadcaster. It's free and available to both Android and Iphone users. Here is a handy Youtube video showing you how to configure an rtmp stream out from your phone. Here is how it roughly works:
- Open the app
- Touch the cog icon
- Click on connections
- Click on new connections
- Type in a name, can be whatever you like
- URL srt://[mysrt server's computer IP address]:1395
- example srt://127.0.0.1:1395
- SRT sender mode to caller
- set latency to 2000
- set streamid to input/live/test
That's the basics of it. For the IP address of your PC/MAC you are looking for the IPv4 address. This address is the one that all other devices on your private network know your pc as, so it's kinda like your computers internet name.
Connect your phone to your wifi (hopefully you have wifi), later we'll switch to cellular. Now back at the main camera view of the larix broadcaster app, click the big circle to start streaming your phone camera. If you didn't stop the mysrt server on your computer, your phone should connect and start tracking the amount of data it's sent.
Keep going you are almost there!
receiving the srt stream in touchdesigner
Attached to this Tutorial is an example toe! Praise the included toe! Let's open the file and get changing stuff!
The first thing we will need to change is the IP address in the Stream in Top. The included address should be srt://127.0.0.1:1935?streamid=output/live/test. We will be changing the the 127.0.0.1 to the IP address of your computer. This should be the same address you put into the Larix broadcaster phone app.
The second thing we need to check is that the port matches that of the mysrt server.
The third thing we need to check is that the live/test part of the ?streamid=output/live/test is the same as the stream id you entered into the larix broadcaster app. Do not that in TouchDesigner it should be output/live/test and not input/live/test as in Larix.
The fourth thingy, let's get connected to Twitch. In the Stream out Top, you should see the following in destination url: rtmp://live-yto.twitch.tv/app/live_1234567_sduhy3xJ1KJ34Eg6CjksdJLubFS7gtUY replace the live_1234567_sduhy3xJ1KJ34Eg6CjksdJLubFS7gtUY bit with your stream key obtained from your Twitch chat settings. Activate the top and you are streaming to Twitch.
YAY, you have successfully streamed live from your phone to Twitch using TouchDesigner!
Just kidding, we haven't gotten to the best part yet!
oh god theres more - the vpn
So not going to lie, my router comes with a OpenVPN server on it and I heavily recommend it. For instance this TP-Link router is around $60 usd and has an OpenVPN server built-in. All you'd have to do is follow the router's instructions for activating the OpenVPN, save the configuration files. There are some other options of using a raspberry pi as a VPN sever, use spare PC on your network, or following the OpenVPN install guide using and cloud service.
On the phone side no matter which option or router you purchased, if you use OpenVPN you will get a configuration profile file you can download to your PC and copy/paste to your phone. Download the OpenVPN app, Click import profile, find that profile file, connect, and you are good to go!
Hmm, something doesn't feel right. You don't have a router with a vpn server and noticed I just kinda hand waived the task of teaching you how to setup your own vpn to some other person/Youtube video. Okay, okay, there is one other way without using a vpn and you still aren't using the SRTMini Server although it does have a feature to solve this. Port Forwarding!
Port forwarding is where you tell your router to forwards all data coming in on a specific port from the internet to your computer's port. The port we would want to forward is the 1935 specifically for udp traffic. This is way less secure so it's not advisable as a long term solution. Unfortunately every router is different when it comes to making a guide on port forwarding, so you should look up your router and follow the manufacturer's guide.
By this point you may just think I am trolling. I don't blame you. But what if I told you there is actually one other other way!
quick and dirty time-travel
Using a Vortex Manipulator errrr..... I mean, Let's use Obs Ninja.
Forget everything I've said up until this point you won't need it.
- Open a webbrowser
- Go to the Obs Ninja webpage
- Create a room
- Enter a Room name
- Enter a password
- Click Enter the Room Controller Center
View the Room Controller Center and look for the "Invite a Guest" link
Get out your phone
Open up a web browser and Type in that Guest Link
Type in the Password you set
Allow the web browser to access your mobile phones camera and mic
You should see something like this
Back on at the Obs ninja control center Find the Copy solo Link and copy it
Open up that SRT example Toe, TouchDesigner file
In the webrender Top, past the Copy Solo Link and activate it
Allow the connection through the firewall
You should see something like this
OBS Ninja what a GOAT. I mean TouchDesigner is the GOAT, don't hurt me Derivative.
If you have any comments or feedback feel free to leave it. The next tutorial I plan on making is about remote controlling TouchDesigner with custom hardware. I actually wrote something similar for a Hackaday blog post, but it is lacking some OSC communication instructions. Another great way of controlling TouchDesigner remotely is using The TouchOSC app. Teaser of my IRL controllers below.