Skip to content

How To Run Livestreaming

mayeaux edited this page Mar 29, 2020 · 5 revisions

How To Use Livestreaming

NodeTube’s livestreaming uses nginx-rtmp to create .hls files which are served via the backend and compiled on the fly using hls.js, which leverages the browser’s Media Source Extension functionality.

To test livestreaming locally, you can do the following.

First, install nginx-rtmp. You can navigate to docs/nginx-livestream-local.conf for an example configuration you can use to test the functionality locally. The relevant lines that you will need to change will be line 130 and 139 where you will have to accurately set it to the directory where NodeTube is being run from.

From this point, assuming you have installed nginx-rtmp properly and setup your configuration file, when you boot nginx you will have the capacity to livestream to the port specified on line 122 (port 1935). While you livestream to this endpoint nginx will handle the stream and save it as 10 second .hls clips, which the frontend will use. It will also save the stream as a recording when it is completed, which will we examine at a later point.

To stream to that endpoint you can use an app such as OBS, or you can easily run an ffmpeg command to stream a video.

ffmpeg -re -i video.mp4 -c copy -f flv rtmp://127.0.0.1:1935/live/YOURUSERNAME?key=YOURLIVESTREAMKEY

For this to work properly you will need to replace YOURUSERNAME with the username of the user you will be streaming with, and replace YOURLIVESTREAMKEY with your livestream key. This full url will be available to you on the livestreaming page available at http://localhost:3000/account/livestreaming. However, this user will need to be a plus user (aka have the plan value for the given user equal to plus (as opposed to free). The first user you will create will be an admin and have a plan of plus` allowing access to livestreaming.

Also, before you boot the app you will want to run the app as a LIVESTREAM_APP to ensure that the livestream routes are available. You should want the following settings:

# determine which routes you want activated:
# has all web app routes, allows users to interact with file hosting
FRONTEND=false

# whether you want to run the app specifically to receive uploads and serve files
FILE_HOST=false

# whether to run authentication routes and fileserving for livestreaming
LIVESTREAM_APP=true
Clone this wiki locally