Experimental HLS support

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.

So it was the latest nightly, here.

https://gnethomelinux.com/OctoPi/nightly/

once extracted listed as 2020-02-13-octopi-buster-lite-0.18.0.img and shows as running octopi 0.18 in OctoPrint.

pi@octopi:~ $ sudo service ffmpeg_hls status
โ— ffmpeg_hls.service - FFMPEG HLS webcam streaming service
   Loaded: loaded (/etc/systemd/system/ffmpeg_hls.service; enabled; vendor prese
   Active: active (running) since Thu 2020-02-13 16:10:29 GMT; 3 months 14 days
 Main PID: 313 (ffmpeg)
   Memory: 33.5M
   CGroup: /system.slice/ffmpeg_hls.service
           โ””โ”€313 /usr/bin/ffmpeg -framerate 30 -video_size 800x600 -i /dev/video

May 29 06:30:03 octopi ffmpeg[313]: [174B blob data]
May 29 06:30:03 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s
May 29 06:30:03 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s
May 29 06:30:16 octopi ffmpeg[313]: [174B blob data]
May 29 06:30:16 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s
May 29 06:30:16 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s
May 29 06:30:17 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s
May 29 06:30:29 octopi ffmpeg[313]: [174B blob data]
May 29 06:30:29 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s
May 29 06:30:30 octopi ffmpeg[313]: [hls @ 0x14f6d00] Opening '/tmp/webcam/hls/s

Those directories in ExecStartPre are present and I see m4a files in the hls folder.

what are URLs to use for the webcam/timelapse settings?

thanks crossed over your comment.

That would actually make sense to do, to support https too?

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 :slight_smile:

Which browser is it? Looks like CORS issue. Try using a plugin that can disable CORS.
Radical solution for this problem is to make HAProxy proxy HLS.

Yeah, chrome. Let me try re-configuring haproxy.

I use this plugin as workaround: https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf

Seems to work, but doesn't seem to be updating. That's the underside of my table sitting next to me.

I'm off to bed now, might play with this more over the weekend.

It shall autoplay. At least, it have the setting :slight_smile:

yeah, it acts like it is playing as the seconds are moving, but it's the same frame over and over it seems.

Lag is 3-5 sec.

yeah, I see some movement, but I've tried putting my finger over the picam and waited up to a minute and no change in VLC...I'll experiment over the weekend. Maybe it's my raspicam settings in octopi.txt? I just set it to raspicam and didn't mess with the options. Just enabled hls mode at the bottom.

Looking at the file list in /tmp/webcam/hls/ it seems the file list is shifting in its numbering, but I'm curious if you start at the beginning of all those files, or automatically move to the newest when the stream is loading in VLC or the OctoPrint tab?

pi@octopi:~ $ ls -l /tmp/webcam/hls
total 1056
-rw-r--r-- 1 webcam webcam   780 May 29 12:12 init.mp4
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2077.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2078.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2079.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2080.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2081.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2082.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2083.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2084.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2085.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2086.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2087.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2088.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2089.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:32 stream2090.m4s
-rw-r--r-- 1 webcam webcam 15548 May 29 13:34 stream2091.m4s
-rw-r--r-- 1 webcam webcam 22442 May 29 13:34 stream2092.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2093.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2094.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2095.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2096.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2097.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2098.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2099.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2100.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2101.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2102.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2103.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2104.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2105.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2106.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2107.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2108.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2109.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2110.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2111.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2112.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2113.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2114.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2115.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2116.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2117.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2118.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2119.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2120.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2121.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2122.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2123.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2124.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2125.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2126.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2127.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2128.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2129.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2130.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2131.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2132.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2133.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2134.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2135.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2136.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2137.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2138.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2139.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2140.m4s
-rw-r--r-- 1 webcam webcam 13219 May 29 13:34 stream2141.m4s
-rw-r--r-- 1 webcam webcam  1181 May 29 13:34 stream.m3u8
pi@octopi:~ $

Itโ€™s normal. It deletes old segments. Usually, player caches like 3 latest segments and starts playing. Thatโ€™s why we have lag.

Hey, @jneilliii. How everything is working for you?
What Iโ€™m waiting for is @foosel or other maintainer words on if we shall integrate it into main code, of just as a plugin.

1 Like

I haven't really been able to do any additional testing unfortunately, had to rebuild my pi4/hyperpixel setup.

@foosel, please take a look into my latest question - shall we make HLS support a merge request to main branch, or a plugin?