Thursday, December 19, 2019

Stream a looping video to Twitch using FFmpeg for testing

If you want to stream from Linux or a Raspberry Pi for testing quality, you can use FFmpeg to stream to Twitch.



It works on Windows with VMs, like Virtualbox, where OBS and Streamlabs doesn't work.

You will need your stream key, ffmpeg and a local rtmp twitch url:


Find an MP4 video around 720p in size if you're going to use a raspberry pi. Anything larger will get dropped frames. In Windows/Linux it shouldn't matter.


ffmpeg -stream_loop -1 -i VIDEO.mp4 -c:v libx264 -s 852x480 -r 30 -f flv "rtmp://YOUR_URL/STREAM_KEY?bandwidthtest=true"

The command basically takes a video and loops it over and over so you can do long term testing. It is also a low resource task (compared to X11 streaming).

The last bit, the "bandwidthtest=true", is for Twitch Inspector. You can see how the stream is without actually going live.

https://inspector.twitch.tv/

Twitch inspector will let you know how well your stream is doing, and it's more accurate than your live dashboard.


If you actually want to go live with and see the results firsthand, remove: "?bandwidthtest=true"

There are probably better flags for ffmpeg to manage keyframes and other parameters, but for testing this is stable enough.

With different platform ingest points, you can stream to Mixer/Youtube/Facebook Live and others. You should be able to stream multiple services, at the same time, if you have enough resources.