Search code examples
videoyoutuberaspberry-piflvavconv

Raspberry PI Camera To Youtube Live Casting Issues


I'm trying to set up my PI 3 with PI Cam 2 as a webcam live streaming to YouTube.

I've used these two guides in setting up so far:

Using the below command in terminal, a connection is made to Youtube, with the Livestream on Youtube changing from Offline to Starting. The stream never starts however.

raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | avconv -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/mysecretstreamkey

I have tried to alter the settings as follows with some result. For example, changing -b to a lower number (i.e: 2000000) & also trying -fps to 24. On occasion I get a healthy live stream, but after about 10 seconds of casting, you see the spinner icon on Youtube.

My internet connection provides me with 18Mbps upload according to Ookla. Any suggestions on how I could get this working properly & reliably?


Solution

  • I solved this using FFMPEG. I followed this guide:digikey.com

    & afterwards run:

    raspivid -o - -t 0 -vf -hf -fps 10 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://rtmp-api.facebook.com:80/rtmp/STREAM-KEY
    

    Works fine now!