apt-get install libav-tools
now insert this command:
alias ffmpeg=avconv
To start the stream, run this command:
raspivid -o - -t 0 -w 1280 -h 720 -fps 30 -b 6000000 -g 50 | 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/your youtube id
find you session here" in above line in your youtube channel
-o -
makes it write the video data to STDOUT so it gets piped into ffmpeg
.-t 0
is how you make it record forever-vf -hf
flips it horizontal and vertical so it looks correct-fps 30
sets frames per second to 30-b 6000000
- output bitrate limit. YouTube recommends 400-600kbps, this is 600kbps. Change this to save upload bandwidth at the expense of a lower quality video-re
- tells -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero
-acodec aac -ab 128k
-strict experimental
- adds a fake audio channel filled with zeroes (silence). YouTube rejects streams without an audio channel. You can also change the input device to a microphone if you want (I haven't done this yet)-g 50
adds a keyframe every 50 frames. Feel free to tweak, its one of those tradeoff variables.-f h264
and -f flv
tells flv
output (flv
is the container format that works with YouTube. Others might work but I haven't tried them)-w
and -h
to