This is awesome @Chudsaviet/ I know many people have been wanting to integrate h264 video streaming. This will go a long way I think. I'm going to check out your other posts, but in case it's not listed elsewhere, what are you using on the server backend to handle the stream?
I cannot confirm if this is working for HLS, but it definitely does not break the mjpgstreamer stream in my testing. Hopefully this is helpful in some way. Feel free to fork, edit, etc. Again great addition for the community I think.
@jneilliii, thatās just WOW. It was fast
Iām using ffmpeg as HLS streamer, and nginx for serving the content.
However, HLS have a caveat by design - lag. I was able to bring it down to 3-5 sec.
You had all the logic done already, so making it a plugin was fairly easy. I just had to tweak some of the id references in javascript and strip out the css for the control tab into it's own css file. Bundle it all together and bam plugin enabled. The trick with this one is the get_template_configs and using the replaces and name option to make it look like the original even though it's not. I really hope it helps. Feel free to remove my name from the author and replace the email address, I was just throwing those in the cookiecutter template when I created the plugin framework. Like I said you did all the programming, I just packaged it for you.
These questions are hard to answer.
But generally:
Iām using hardware h264, but CPU load is still significant. Like 20% of each core on Rpi 4. Itās doing JPEG encoding for the timelapses, and moving frames back and forth, filesystem work, etc... We are able to pull JPEG frames directly from camera, but I wanted to avoid double compression, so I pull raw video. I set āniceā to ffmpeg, so it shouldnāt affect printing.
Network bandwidth depends on how much h264 bitrate you set. I set 2048 kbit/s for 800x600, but we can optimize it further. I havenāt measured MJPEG, but itās like 4 times more bandwidth I think.
So I'm struggling a little with the setup on my test pi without the octopi image. Maybe I should look for a nightly build....these are the commands I am using to try to manually add this to my already installed octopi and am getting errors randomly.
sudo su
apt-get update
apt-get install -y --force-yes --no-install-recommends ffmpeg nginx
mkdir -p /etc/octopi_streamer/hls
wget https://raw.githubusercontent.com/guysoft/OctoPi/35f334033524c763cc54293e103315b8900740fb/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service
cp ./ffmpeg_hls.service /etc/systemd/system/ffmpeg_hls.service
wget https://raw.githubusercontent.com/guysoft/OctoPi/35f334033524c763cc54293e103315b8900740fb/src/modules/octopi/filesystem/root/etc/nginx/sites-available/default
cp ./default /etc/nginx/sites-available/default
wget https://raw.githubusercontent.com/guysoft/OctoPi/35f334033524c763cc54293e103315b8900740fb/src/modules/octopi/filesystem/root/lib/systemd/system/nginx.service
cp ./nginx.service /lib/systemd/system/nginx.service
usermod -aG video pi
systemctl disable webcamd
systemctl enable nginx
systemctl enable ffmpeg_hls
service nginx start
service ffmpeg_hls start
exit
the error I see is when starting the ffmpeg_hls service...
Job for ffmpeg_hls.service failed because the control process exited with error code.
systemctl status ffmpeg_hls.service
ā ffmpeg_hls.service - FFMPEG HLS webcam streaming service
Loaded: loaded (/etc/systemd/system/ffmpeg_hls.service; enabled; vendor prese
Active: activating (auto-restart) (Result: exit-code) since Fri 2020-05-29 05
Process: 2717 ExecStartPre=/bin/rm -rf /tmp/webcam (code=exited, status=217/US
journalctl -xe
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- An ExecStartPre= process belonging to unit ffmpeg_hls.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 217.
May 29 05:41:42 octopi systemd[1]: ffmpeg_hls.service: Failed with result 'exit-
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit ffmpeg_hls.service has entered the 'failed' state with result 'exit-
May 29 05:41:42 octopi systemd[1]: Failed to start FFMPEG HLS webcam streaming s
-- Subject: A start job for unit ffmpeg_hls.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit ffmpeg_hls.service has finished with a failure.
--
-- The job identifier is 2278 and the job result is failed.
Pi Zero W can handle it. I run a fish camera on one However, I don't know if it will print with no issues due to high load.
Is it the latest clean OctoPi build?
In VLC or Safari, or the experimental OctoPrint, use http://[your octopi]:8051/hls/stream.m3u8.
You can also create a demo page for other browsers as described in HLS.js docs: https://github.com/video-dev/hls.js/
UPD: Oh, you can have issues with CORS in Firefox and Chrome. We might need to update HAProxy config to proxy the webcam.
I had an idea of restricting Nginx to run only on local interface and proxying it to HAProxy. Just haven't enough time. So yes, HAProxy in this case will do the HTTPS work too.
And also, did you take into account the test button in the webcam settings for your changes to OctoPrint? That seems to be broken. So I am able to load up the plugin I made, and tried in VLC and it seems my picam connection got messed up or it's not quite working for me.
No, no test button work done. It's a separate page if I'm correct. I just made an MVP to present the idea to the community. If it will be accepted - we will do a proper merge request together