Skip to content

Instantly share code, notes, and snippets.

@daveio daveio/youtube.sh
Created Feb 10, 2018

Embed
What would you like to do?
Stream from the Raspberry Pi Camera to YouTube Live
#!/bin/bash
# Stream from the Pi camera to YouTube Live.
# Uses information from https://www.makeuseof.com/tag/live-stream-youtube-raspberry-pi/
# Modified to use v4l2 directly (lower cpu, lower latency, higher frame rate, basically More Better)
# Setup: standard Pi Camera setup, then sudo apt-get install libav-tools
# You may need to modify the horizontal and vertical flip options to suit your mount.
# Usage: youtube.sh YOUTUBE-SECRET-KEY
sudo modprobe bcm2835-v4l2
sudo v4l2-ctl -c rotate=0,video_bitrate=1000000,horizontal_flip=1,vertical_flip=1
sudo v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=4
sudo v4l2-ctl -p 30
avconv -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -thread_queue_size 512 -f h264 -r 30 -i /dev/video0 -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv -r 30 rtmp://a.rtmp.youtube.com/live2/$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.