Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ffmpeg youtube live event rtmp stream from raspberry pi with raspi camera (raspivid)
  1. apt-get install ffmpeg - it is now available on raspbian repos (last checked April 2018)
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -w 1280 -h 720 -fps 30 -b 3000000 -cfx 128:128 -drc high | 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://a.rtmp.youtube.com/live2/<SESSION>

custom additions:
-cfx 128:128: for grayscale video
-drc high: dynamic range compression for situations where bright skies and dark shadows are present in the same frame

you can tweak -b and -fps to your liking. the settings above work well for 1080p. by not specifying width -w or height -h we get the full 1920x1080 resolution from the raspi camera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment