Just set up Octoprint on an existing Raspbian installation and everything has been working wonderfully. I already had a UV4L streaming server set up on my Pi accessible from 'http://192.168.1.21:8080/stream/video.mjpeg'.
Dropping the URL in the settings box and hitting TEST shows the stream just fine, but in the control tab, I get the Webcam stream not loaded message while showing a very functional link (I can click on it and see the stream).
Investigating further, It seems that the URL the site is actually using has some additional information tacked on to the end (looks like a timestamp) that is causing a 404.Any reason for this or solutions for fixing this?
I think I've heard others call this a nonce, a random or sequential number added to a URL to prevent browser caching. So enter then entire URL, as decorated, into another tab of your browser and see if that works. If it does, then you can ignore the nonce decoration at the end. If it doesn't work in the new tab with the nonce then let us know.
I think something has changed with the streaming urls in this version. :8080 quit working for me (but /webcam/ still works), and I had to change the default webcam template for my plugin.
Try changing your URL in OctoPrint Settings->Webcam to this:
/webcam/?action=stream
Edit:
I didn't notice that you were using a different streaming method. Maybe this instead:
/webcam/stream/video.mjpeg
I'm less sure now that my advice will help you at all though
Sorry, maybe I didn't explain that right. The URL only works without the extra bit. Looking at the Chrome inspector, I noticed that the OctoPrint site was adding it on when retrieving the stream
Yes, this is standard anti-caching behavior. You decorate the link with an unnecessary question mark and something random. The browser sees that it doesn't have this version and will then fetch it.
Okay, so your camera doesn't like the nonce. We may need to bring @foosel into this but I'll see if there's something in the config.yaml file which can toggle that off.
var webcamImage = $("#webcam_image");
var currentSrc = webcamImage.attr("src");
// safari bug doesn't release the mjpeg stream, so we just set it up the once
if (OctoPrint.coreui.browser.safari && currentSrc != undefined) {
return;
}
var newSrc = self.settings.webcam_streamUrl();
if (currentSrc != newSrc) {
if (newSrc.lastIndexOf("?") > -1) {
newSrc += "&";
} else {
newSrc += "?";
}
newSrc += new Date().getTime();
self.webcamLoaded(false);
self.webcamError(false);
webcamImage.attr("src", newSrc);
}
So here's where the nonce is being added in an attempt to prevent the browser from using a cached version. Perhaps in your case you'd need...
Shouldn't that nonce contain a paramater name to prevent querystring parsers from having issues? For example 'nonce_ts={timestamp here}'? I'm guessing the streaming API can contain parameters, tries to parse the querystring, and fails because the querystring isn't formatted properly.
The nonce was 100% the issue! I used the Resource Override Chrome extension to strip off the nonce and its working perfectly now! Thanks for the help. You think this is worth opening up a Github issue for?
That's hard to say. Honestly, the webcam stuff is an add-on of the OctoPi image in a way and yet the nonce code is from OctoPrint. It might be a nice feature request to have this optional within the config.yaml, methinks.
Sorry for reopening the thread, but I have faced this problem a few days ago, and after some tries, I think I found a successful solution not involving chrome addons. Looking into octoprint source code I found the file control.js (in my case located in "~/oprint/lib/python2.7/site-packages/octoprint/static/js/app/viewmodels" adds the timestamp to the url of the stream.
I have commented a few lines and it is working without the Chrome Extension. The lines I have to comment (with // at the beginning) are
if (newSrc.lastIndexOf("?") > -1) {
newSrc += "&";
} else {
newSrc += "?";
}
newSrc += new Date().getTime();