Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Last active May 21, 2022 11:02
Show Gist options
  • Save max-mapper/69e4ae18a32d7efd00d9 to your computer and use it in GitHub Desktop.
Save max-mapper/69e4ae18a32d7efd00d9 to your computer and use it in GitHub Desktop.
ffmpeg youtube live event rtmp stream from raspberry pi with raspi camera (raspivid)
  1. compile ffmpeg for arm https://github.com/fiorix/ffmpeg-arm
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -fps 30 -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://a.rtmp.youtube.com/live2/<SESSION>

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

note: it might work with libav-tools instead of ffmpeg (ffmpeg isnt on apt-get in raspbian) but I haven't tested it

example video created using above method: https://www.youtube.com/watch?v=Xn4yNavjdR4&t=28m0s

@zomerfeld
Copy link

@o2bnmaine - I'm having the same issue. Did you find a solution?

@wassimmeziou
Copy link

it has a late streaming for 20-30 secconds any idea !

@gsthina
Copy link

gsthina commented Jun 15, 2017

It's all working good. Is there any way to define a custom URL to stream? Or at least, can we get the URL of the video by code?

@ikenti
Copy link

ikenti commented Mar 13, 2018

Hi, it works for me but how do you had a sound recorded from a mic to the video? Thanks.

@ethaniel
Copy link

Did you manage to get live true 1080p using this method?

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