Experimental HLS support

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?

If you don't limit it to HLS but actually make it generic support for webcam via video tag (I can't estimate how difficult that would be right now, if at all), I'd be happy to merge into core (maintenance branch).

If that CORS issue doesn't get resolved then I think you might be asking for headaches on this one @foosel.

Ah, I overlooked that. In that case plugin until the teething pains are resolved.

CORS is a mechanism that manages restrictions with including resources from different domain. In OctoPi case, the plan is to include the HLS stream in the same HAProxy instance, which will eliminate CORS issues.
Otherwise, there are some HTTP header/HTML parameters that can tell CORS to allow external resources.
The issues @jneilliii faced are there because it's experimental feature, in production CORS issues will be resolved.

What I'm worrying about:

  1. Now the streamer type (MJPG or HLS) is detected by URL's ending. If it ends with 'm3u8' - it's HLS. I think it's easier to do it like this than add a separate drop down menu to settings page. But it limits the URL flexibility, so in rare cases it won't work.
  2. I'm not sure I will be able to support flip/mirror capabilities on UI level like OctoPrint have for MJPG stream. I will research this question. But generally, the mirror/flip/other filters can and shall be done on ffmpeg level.

Hi, yeah i'm in a "rare case" cause if i let my url http://192.168.0.31/img/stream.m3u8 it does not work, it need http://192.168.0.31/img/stream.m3u8?channel=1

If you have a way to allow that kind of url ?

Maybe instead of ending by .m3u8 it could be a "if contain" .m3u8 ?

I just took a look at the plugin's code and it appears it should already be allowing for that in this function.

I wonder if maybe restarting OctoPrint is necessary to detect the URL change maybe?

Cant figure it out, i tried things but meh, same result till now

It might be CORS related based on previous discussions because you're loading the stream from a different server other than where OctoPrint is running.