Another Webcam Issue. Looks like its changing the URL?

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 ''.

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:



I didn't notice that you were using a different streaming method. Maybe this instead:


I'm less sure now that my advice will help you at all though :frowning:

I read that as "the url changed from /webcam/stream/video.mjpeg to /webcam/stream/video.mjpeg?123566798..."

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.

From this:

            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) {

            var newSrc = self.settings.webcam_streamUrl();
            if (currentSrc != newSrc) {
                if (newSrc.lastIndexOf("?") > -1) {
                    newSrc += "&";
                } else {
                    newSrc += "?";
                newSrc += new Date().getTime();

                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...

            if currentSrc != undefined:

...added before the Safari test.

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.

@camander321, can you see if this url works in your browser:

I think you're onto something. If this works then there might be a one-size-fits-all-PR for this.

it really doesnt like any queries in the url at all. adding anything gives a 404

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.

What rule(s) did you add? I'm having the same problem.

Edit: Never mind. I solved it. How I solved it at: Webcam works when testing, but not in Control tab