PHP to create a MJPEG output
docker docker-compose 3 containers for Redis Guestbook @ https://kubernetes.io/docs/tutorials/stateless-application/guestbook/ (this repo has a docker-compose.yaml that should work for docker) (or just a PHP container, and you have to install the redis or a way to store JPG files)
Redis guestbook is a PHP sample from Google to connect to Redis, an in-memory database. By using their images, I skip needing to configure PHP, redis, or installing the redis client. The PHP takes 60 jpg, and turns them into a MJPEG. It stores each JPG in redis. Each JPG frame needs to be uploaded individually, with ?cmd=set&key=&value=, in a POST submission. To see last JPG frame uploaded, use ?cmd=set&key=, in a GET submission. To see MJPEG, of images uploaded in order, use ?cmd=mjpeg&key=, in a GET submission. The MJPEG feed only lasts 3600 seconds.
You don't need redis. You can upload your own images and save it to session. You can modify it anyway you want. It is simple enough. MJPEG is a very very old technology. I don't know how much longer, browsers will support it. But it is free, and a lot of free software like Linux motion uses it.
Copy this script
git clone https://github.com/studio-1b/php-mjpeg.git
Install the php and redis containers
docker-compose up
or to run them in background
docker-compose up -d
You need to copy the img.php
docker cp img.php <PHP container name>:/var/www/html
Probably will be:
docker cp img.php php-mjpeg-php-redis-1:/var/www/html
You can upload JPG images with curl
curl -H "Content-type: application/x-www-form-urlencoded" -X POST --data cmd=set --data key=A --data-urlencode value@IMG.b64 http://<IP>:<port>/img.php
It will store 60.
You can view JPG image in your browser
http://<IP>:<port>/img.php?cmd=get&key=A
You can upload JPG images with curl
http://<IP>:<port>/img.php?cmd=mjpeg&key=A
To embed in a html file
<img src="http://<IP>:<port>/img.php?cmd=mjpeg&key=A">
I will only show a video with last 60 uploads, BUT it will continue streaming waiting for another upload (ie. using curl above). So if you send a image every minute, a person receiving the stream on their browser with the URL, will receive the last uploaded jpg automatically. This PHP and URL only will last 60min, then abort. You can remove this for your own purposes. But bandwidth over the internet costs $.
I have this in AWS. Don't abuse. AWS cost me $ with every gigabyte.
http://100.24.142.145:10000/img.php?cmd=mjpeg&key=E
It isn't a livestream, but it could.