Camera stream
Hi! I couldn't find anything about this, but my apologies if this has been answered before.
I setup Link and Connect yesterday and they're running smoothly. One thing that bugs me though is that the camera feed (I'm using a Pi cam) only sends snapshots. Isn't there a way for getting a live feed, as in Octoprint?
RE: Camera stream
Hi, unfortunately the most we can do is one snapshot per 10s
RE: Camera stream
Hey Tojik,
Is there a reason for this? For our internal dashboard I'd love to be able to capture the livestreams from PrusaLink. Could you go maybe indulge me in how you get the camera streams and how one could take the streams / snapshots being thrown to Connect and divert it somewhere else?
RE:
Hi, if I knew how to get 1080p30 on a Zero W while printing circles. I would probably just put it in PrusaLink. The whole reason we don't have this is that cameras are hard.
You can probably find guides on how to stream video from a raspberry pi locally and run that alongside link pretty painlessly? Idk tho
RE: Camera stream
Yeah that's what I figured next, if it wasn't possible to hijack the PrusaLink/Connect stream I was gonna look into a pi stream next.
How would that work for the MK3.9's / MK4s by the way? We're upgrading our 3's to 3.9's from January, which means we shouldn't need to use the raspberry's anymore, but we'll also in that case lose the USB-A slots from the Pi's. Do you happen to know anything about the 4 supporting usb cameras?
RE: Camera stream
I'm in the same boat wanting live stream I'm wondering how hard it would be to recode prusalink or like you say intercept prusalink signal and send constant video stream
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models
RE: Camera stream
Go look, the entire thing sits on the internet free of charge. If you make it stream video, just publish the code so we can have it too
RE:
Go look, the entire thing sits on the internet free of charge. If you make it stream video, just publish the code so we can have it too
Yeah I've been looking into it I'm away on holiday for 2 weeks so not going to be able to do anything till I'm back
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models
RE: Camera stream
@tojik could you tell me in what file sets the time it takes photo and sends them / displays theme
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models
RE: Camera stream
Yea, you can shorten the timer, that doesn't make it a camera video stream. That just makes it take photos faster. You would then need the web to get the shots faster making an unholy amount of http requests. That's why it's called a video stream. It streams the data, not getting each frame separately. There is just one pipe to throw data into as they are being captured with buffers on both ends. That's not implemented in PrusaLink, I would be very surprised if someone made that in their free time just to have MK3 video without just using mjpg-streamer like OctoPrint
It's in Prusa-Connect-SDK-Printer /prusa/connect/printer/const.py line 236 - TRIGGER_SCHEME_TO_SECONDS
Another constant that influences how fast is the web getting the images is in Prusa-Link /prusa/link/const.py line 97 - TIME_FOR_SNAPSHOT
RE: Camera stream
Yea, you can shorten the timer, that doesn't make it a camera video stream. That just makes it take photos faster. You would then need the web to get the shots faster making an unholy amount of http requests. That's why it's called a video stream. It streams the data, not getting each frame separately. There is just one pipe to throw data into as they are being captured with buffers on both ends. That's not implemented in PrusaLink, I would be very surprised if someone made that in their free time just to have MK3 video without just using mjpg-streamer like OctoPrint
It's in Prusa-Connect-SDK-Printer /prusa/connect/printer/const.py line 236 - TRIGGER_SCHEME_TO_SECONDS
Another constant that influences how fast is the web getting the images is in Prusa-Link /prusa/link/const.py line 97 - TIME_FOR_SNAPSHOT
Also could you tell me where the code is that it gets the link of camera
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models
RE:
> Also could you tell me where the code is that it gets the link of camera
What? What link? If you want to know what api endpoint to call to get the most up to date image, read the api docs in Prusa-Link-Web repo, then using the path, you can find the endpoint in link. But what is a link of camera i have no idea.
I am aggravated. Please, if you're going to "recode prusalink" to stream video, then ask me how to do basic stuff like shorten the timer to get more snapshots, at least take the time to attempt to form a proper sentence. If you want me to do the work for you, it's rude to me that you won't even invest the time to ask properly.
Thank you
RE: Camera stream
I found it all just carnt do anything till I get back to my pi
> Also could you tell me where the code is that it gets the link of camera
What? What link? If you want to know what api endpoint to call to get the most up to date image, read the api docs in Prusa-Link-Web repo, then using the path, you can find the endpoint in link. But what is a link of camera i have no idea.I am aggravated. Please, if you're going to "recode prusalink" to stream video, then ask me how to do basic stuff like shorten the timer to get more snapshots, at least take the time to attempt to form a proper sentence. If you want me to do the work for you, it's rude to me that you won't even invest the time to ask properly.
Thank you
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models
RE: Camera stream
I've been working on a solution like this and it works well enough on a 3B to run Prusa-Link on one printer while running USB camera streams for two 1080p cameras. One challenge I keep running into is that Prusa-Link is "greedy" with camera devices and will attempt to grab control over any new camera device it finds. This creates all sorts of problems for anything else running on the system, eg: a camera streaming service cannot restart the service to change settings because prusa-link will grab the camera during the restart. It'd be great if there was a way to disable that behavior, or even disabling cameras all together such that external camera solutions could better integrate on the same pi.
RE: Camera stream
I've been working on a solution like this and it works well enough on a 3B to run Prusa-Link on one printer while running USB camera streams for two 1080p cameras. One challenge I keep running into is that Prusa-Link is "greedy" with camera devices and will attempt to grab control over any new camera device it finds. This creates all sorts of problems for anything else running on the system, eg: a camera streaming service cannot restart the service to change settings because prusa-link will grab the camera during the restart. It'd be great if there was a way to disable that behavior, or even disabling cameras all together such that external camera solutions could better integrate on the same pi.
Do you have the code or a github
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models
RE: Camera stream
@luma you could create new user/group for prusalink, and that user is not added to the users wich allow accessing camera devices.
If prusalink still needs camera ( for example if it would crash without it, I don't know ) then you could create new dummy video device and change ownership or permissions to it so it would be accessible for that user/group.
See my GitHub and printables.com for some 3d stuff that you may like.
RE: Camera stream
Hi,
here, a kinda bad reference to the configuration file of prusalink
https://github.com/prusa3d/Prusa-Link/blob/master/prusa/link/data/prusalink.ini
Make a file in /etc/prusalink/ named prusalink.ini
Put this inside
[cameras] auto_detect=False
Now it's not greedy anymore
Profit
RE:
Make a file in /etc/prusalink/ named prusalink.ini
Put this inside
[cameras] auto_detect=FalseNow it's not greedy anymore
Profit
This is exactly what I needed, thanks @tojik!
Do you have the code or a github
Nothing quite so fancy yet but the general concept is simple if you follow a couple rules:
- Stream in camera-native format, do no video processing at all on the pi
- Only send out a maximum of one stream per camera, ideally to a video server
For example, most Logitech webcams will stream MJPEG, so install MJPEG streamer or whatever else you like and make sure that you are not doing any transcoding. Then, setup a video server somewhere that's not the pi, have it ingest your pi camera stream, and then point all consumers at that video server (never at the pi). This way, if you have 3 web browser windows all with the video stream open, the load on the pi never changes, it's always just sending out a single copy of the webcam stream in it's native format with no processing to the video server and your web pages are pulling the stream from the video server.
In my setup I'm using go2rtc for the video proxy, it's a high performance solution to do what I suggest above, ingest a video stream and then supply it to multiple consumers on-demand. It utilizes very little resources when not actively streaming.
That'll get you a camera stream that you can use as needed, but it won't appear in the Prusa-Link web page and it also won't appear in Prusa Connect cloud. I don't have a solution for Prusa-Link quite yet (trying to get it to share a device via v4l2loopback hasn't worked) but there is a way to feed camera stills into Prusa Connect manually. I'm doing this in Home Assistant and it fires off a bash script every 10 seconds if a print job is currently active:
token=[prusa-connect token] ; fingerprint=[prusa-connect fingerprint]; ha_url=[home assistant url]; prusaconnect_cameras=[home assistant long lived token]; ha_camera_entity=[home assisant camera entity name]; temp_file=$(mktemp -t "${ha_camera_entity}-XXXXXX") ; curl -X GET -H "Authorization: Bearer ${prusaconnect_cameras}" -H "Content-Type: application/json" -o ${temp_file} ${ha_url}/api/camera_proxy/${ha_camera_entity} ; curl -X PUT -H "token: $token" -H "fingerprint: $fingerprint" -H "Content-Type: image/jpg" --data-binary @${temp_file} https://connect.prusa3d.com/c/snapshot ; rm $temp_file
RE: Camera stream
I've been doing some research on this in a similar vein.
I want to find a way to add spaghetti detection to Prusa Connect.
The only thought I had that seemed feasible was to have something like Obico.io or Octoeverywhere running "standalone". Just monitoring the camera feed. And then, using the Prusalink or Prusa Connect APIs to issue pause and/or stop commands.
BUT... none of the solutions have a standalone. So... wasn't sure where to go next with it. But, getting the camera feed going was possibly step 1.
I was going to try setting up a virtual printer in Octoprint but using the camera feed and somehow "fudge" the destination for the pause/stop commands.
RE: Camera stream
Hmm this would take alot to implement I reckon Octoeverywhere monitoring in the background without octoprint would be a good start I reckon
I've been doing some research on this in a similar vein.
I want to find a way to add spaghetti detection to Prusa Connect.
The only thought I had that seemed feasible was to have something like Obico.io or Octoeverywhere running "standalone". Just monitoring the camera feed. And then, using the Prusalink or Prusa Connect APIs to issue pause and/or stop commands.BUT... none of the solutions have a standalone. So... wasn't sure where to go next with it. But, getting the camera feed going was possibly step 1.
I was going to try setting up a virtual printer in Octoprint but using the camera feed and somehow "fudge" the destination for the pause/stop
Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models