Skip to content

Instantly share code, notes, and snippets.

@alexellis
Last active May 18, 2017 19:58
Show Gist options
  • Save alexellis/92c12c4d186aaac5ef0784788854b37d to your computer and use it in GitHub Desktop.
Save alexellis/92c12c4d186aaac5ef0784788854b37d to your computer and use it in GitHub Desktop.
Live Streaming YouTube from RPi
  1. Build the first image with ffmpeg

Takes 8 hours on Pi Zero.

  1. Build image called streaming

  2. Run the streaming imagee:

docker ps -aq|xargs docker rm -f;

docker run --privileged -ti streaming <you_tube_secret_here>
FROM resin/rpi-raspbian:jessie
ENTRYPOINT []
RUN apt-get update -qy && apt-get -qy install \
build-essential git
WORKDIR /root/
RUN git clone https://github.com/FFmpeg/FFmpeg.git
workdir /root/FFmpeg
RUN apt-get install -qy libomxil-bellagio-dev
RUN ./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree
#RUN ./configure --arch=armel --target-os=linux --enable-gpl --enable-omx-rpi --enable-nonfree
RUN make
RUN make install
CMD ["/bin/bash"]
FROM alexellis2/ffmpeg-armv7
# or alexellis2/ffmpeg-armv6
RUN apt-get update && apt-get -qy install \
libraspberrypi-bin && \
rm -rf /var/lib/apt/lists/*
WORKDIR /root/
COPY entry.sh .
RUN chmod +x entry.sh
ENTRYPOINT ["./entry.sh"]
#!/bin/bash
echo Live-stream secret: $1
raspivid -o - -t 0 -w 1920 -h 1080 -vf -hf -fps 40 -b 8000000 -g 40 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i pipe:0 -c:v copy -c:a aac -ab 128k -g 40 -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