Instantly share code, notes, and snippets.

Embed
What would you like to do?
HackingOnLiveStreaming

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
@quarterturn

This comment has been minimized.

Copy link

quarterturn commented Jul 20, 2017

When you say "Place a Dockerfile in a new directory" where do you mean for it to go?

If I create, say "temp" directory in /streaming/, and put the Dockerfile inside that and run "docker build..." it fails:
Sending build context to Docker daemon 4.608kB
Step 1/6 : FROM ffmpeg:17-5-2017
repository ffmpeg not found: does not exist or no pull access

If I mv Dockerfile to Dockerfile.orig and create a new Dockerfile containing the "FROM..." and "COPY..." lines above,
it seems to work:
Sending build context to Docker daemon 4.096kB
Step 1/2 : FROM alexellis2/streaming:17-5-2017
---> 63e724cc90ea
Step 2/2 : COPY entry.sh entry.sh
---> 1bdb01e32006
Removing intermediate container c3bdad2f13c4
Successfully built 1bdb01e32006
Successfully tagged alexellis2/streaming:latest

However, running the container it is obvious it did not replace it, as (in my example of what I fixed) the video is still upside down, which means it did not actually copy my edited entry.sh into the container.

I've played around a bit just trying to edit entry.sh by use of "docker exec.." but it is not persistent.

@jorenham

This comment has been minimized.

Copy link

jorenham commented May 14, 2018

I'm having the same issue as @quarterturn

@graemecoates

This comment has been minimized.

Copy link

graemecoates commented May 28, 2018

I tripped over this as well, but realised when the docker build command is completed, you have to run the docker file by using the "latest" tag. eg:

docker run --privileged --name cam -d --restart=always alexellis2/streaming:latest xxxx-xxxx-xxxx-xxxx

Also, make sure your entry.sh has the right perms (chmod +x), or it fails to run....

@nickpagz

This comment has been minimized.

Copy link

nickpagz commented Jan 17, 2019

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:

FROM alexellis2/streaming:07-05-2018
COPY entry.sh entry.sh
RUN chmod +x entry.sh
ENTRYPOINT ["./entry.sh"]

Note: I'm running Raspbian Stretch, so my first line contains alexellis2/streaming:07-05-2018. If you're running Jessie, use alexellis2/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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment