Advertisement
epl70

Raspberry Pi stream to youtube

Nov 29th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. exec 3>&1 4>&2
  4. trap 'exec 2>&4 1>&3' 0 1 2 3
  5. exec 1>>/var/log/streamToYoutbue.log 2>&1
  6.  
  7. set -x
  8.  
  9. YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2/"
  10. FFMPEG="/usr/local/ffmpeg/bin/ffmpeg"
  11.  
  12. function usage() {
  13.         echo "usage:"
  14.         echo "streamToYoutbue youtube-channel-id"
  15.         exit 1
  16. }
  17.  
  18. function startStreaming() {
  19.         echo "start streaming to youtube channel $1"
  20.         date
  21.         raspivid -o - -t 0 -w 1280 -h 720 -fps 25 -b 4000000 -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 "$YOUTUBE_URL$1"
  22. }
  23.  
  24. if [ -z "$1" ]; then
  25.         usage
  26. else
  27.         startStreaming $1
  28. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement