22 Jul 2016, 19:11

Streaming using a Raspberry Pi Camera to Twitch in Full HD while injecting audio from rtl sdr


I have found the right setup to stream in 1080p from a Raspberry Pi using the camera to TwitchTV while injecting audio on the fly!

Create an account on Twitch and grab you stream key in the Dashboard.

This stream.sh script will create a FIFO start rtl_fm at freq 162.550M to listen to Canada weather bulletin (use your local NOAA channel) and inject and encode the audio to the existing h264 stream from the camera then stream it to twitch using rtmp.

#! /bin/bash
KEY="live_XXXXX_XXXXXXXXXXXXXX" # put your key here

mkfifo /tmp/streamaudio.wav
rtl_fm -f 162.550M -s 22050 -g 30 | sox -r 22050 -t raw -e signed -b 16 -c 1 -V1 - -r 22050 -t wavpcm  -  > /tmp/streamaudio.wav &

/opt/vc/bin/raspivid -n -vf -t 0 -w 1920 -h 1080 -fps 25 -o - | ffmpeg -re -i - -i /tmp/streamaudio.wav -codec copy -strict experimental -acodec libmp3lame -ar 22050 -threads 8 -f flv "$STREAM_URL/$KEY"

You can of course send other audio sources or no audio at all.

This setup is taking around 10% cpu on a Raspberry Pi 2.

If you are lucky enough my channel will be up and running.

What is RTL SDR ?

Using a 20$ USB dongle you have a software radio scranner, capable of listening to radio amateurs, NOAA weather bulletin even satellites.

Note that you can also stream from your laptop using the great and free ObsProject.

Happy streaming.

comments powered by Disqus