Additional notes
Original blog post - http://blog.alexellis.io/live-stream-with-docker/
How do I rebuild the image from scratch?
This will take several hours on a Raspberry Pi Zero - but less time on a Pi 2 or Pi 3. You can edit the Dockerfile for a Pi 2/3 and change RUN make
to RUN make -j 4
to take advantage of the quad-core processor.
$ git clone https://github.com/alexellis/raspberrypi-youtube-streaming/
$ cd streaming
$ docker build -t alexellis2/streaming .
How do I edit the settings?
You should edit the entry.sh
file and then write a new Dockerfile using my image as a base:
Place a Dockerfile
in a new directory with this contents:
FROM alexellis2/streaming:17-5-2017
COPY entry.sh entry.sh
Then run a Docker build - this should take less than 10 seconds since we're only adding on top of the existing image.
$ cd streaming
$ docker build -t alexellis2/streaming .
How can I enter bash on the container?
You can replace the start-up command (ENTRYPOINT
) like this:
$ docker run --entrypoint=/bin/bash --privileged --name cam -ti alexellis2/streaming:17-5-2017
The original post by @alexellis was super easy to follow and implement, with great instructions. The same cannot be said for the instructions for modifying the settings in the entry.sh file. I'm a part time, google search educated coder, with a barely moderate skill for navigating my way around a unix environment and fell for the easy guide in the original post. The instructions above on how to create a new image with your own modified entry.sh file however, leaves a lot to be desired for the average Joe, and took me a significant amount of time to figure out and get working. TBH, I'm not sure my method worked, but I was able to get it working without spitting errors at me and starting streaming content. So, for the layman, here are my step by step instructions (I do this via SSH on a Mac in Terminal):
Make sure you're in your user root, type and enter:
cd
Make a new directory, type and enter:
mkdir streaming
Go to the new directory:
cd streaming
Now we're going to create two files and populate them. Let's start with the Docker file.
sudo nano Dockerfile
Copy this and paste it into the file:
Note: I'm running Raspbian Stretch, so my first line contains
alexellis2/streaming:07-05-2018
. If you're running Jessie, usealexellis2/streaming:17-5-2017
instead.Press Ctrl-x to exit and save the file.
Now create the entry.sh file (we're still in the streaming directory for all this, btw).
sudo nano entry.sh
Copy the contents from the original entry.sh file here, and paste it into the new file.
The new file is where you'll make your settings changes for display size, frame rate, bit rate, etc.
When you're done making the changes, press Ctrl-x to exit and save the file.
NOW, we can build the new image using the new entry.sh settings:
docker build -t alexellis2/streaming .
This should only take a few seconds. Now we can run the docker file again, making sure as @graemecoates pointed out to add the latest tag to your command. Here's what mine looks like:
docker run --privileged --name cam -ti alexellis2/streaming:latest xxxx-xxxx-xxxx-xxxx
Replacing of course the xxxx's with your own Youtube stream key.
When you need to tweak your settings, modify your entry.sh file again using sudo nano entry.sh, and run the docker build... command again.
Now, if you 'sperts out there think I did something wrong, I would love to hear it as I'm still learning!