-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples for MJPG, fix mediamtx stream web
- Loading branch information
1 parent
e20b721
commit 59edb5f
Showing
19 changed files
with
208 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Web Cam - MJPG stream | ||
|
||
This processing requires ffmpeg package. | ||
|
||
Most standalone webcams are actually mjpg cams, they send infinite motion jpeg stream | ||
over specific URL. | ||
|
||
The best option to check what is the URL is in the camera manual, or if you | ||
open web UI of the camera and see the stream image then right click on the image | ||
and select Inspect to see the URL for the image - copy that URL. | ||
|
||
You should be able to test the stream locally with `ffplay` command. | ||
|
||
For example, if your camera is reachable over address `192.168.0.20` and port `8000` | ||
under endpoint `/ipcam/mjpeg.cgi` then below command should show the stream: | ||
|
||
```shell | ||
ffplay http://192.168.0.20:8000/ipcam/mjpeg.cgi | ||
|
||
``` | ||
|
||
There may be some user and password in the URL. | ||
|
||
If that works, then configuration should be pretty straightforward: | ||
|
||
- copy `ffmpeg-mjpg-stream.dist` as `.env` | ||
- in copied file `.env` replace `token-change-me` with the value | ||
of the token you copied | ||
- in copied file `.env` replace `fingerprint-change-me` | ||
with some random value, which is alphanumeric and has at least 16 chars | ||
(and max of 40 chars), for example set it to `fingerprint-myprinter4-camera-4` | ||
- in copied file `.env` replace your RTSP device address `raspberry-pi`, | ||
port and stream id in `CAMERA_COMMAND_EXTRA_PARAMS` if needed | ||
- save edited file `.env` | ||
|
||
Next, [test config](./test.config.md). | ||
|
||
## Unverified example | ||
|
||
Beagle Camera stream - if I remember correctly, then camera url to the stream | ||
is something like `http://192.168.2.92/ipcam/mjpeg.cgi` | ||
|
||
Replace `192.168.2.92` with your address in the example below. | ||
|
||
<!-- markdownlint-disable line_length --> | ||
```shell | ||
PRINTER_ADDRESS=127.0.0.1 | ||
PRUSA_CONNECT_CAMERA_TOKEN=token-change-me | ||
PRUSA_CONNECT_CAMERA_FINGERPRINT=fingerprint-change-me | ||
CAMERA_DEVICE=/dev/null | ||
CAMERA_COMMAND=ffmpeg | ||
CAMERA_COMMAND_EXTRA_PARAMS="-y -i 'http://192.168.2.92/ipcam/mjpeg.cgi' -vframes 1 -q:v 1 -f image2 -update 1 " | ||
``` | ||
<!-- markdownlint-enable line_length --> | ||
|
||
But it is better to use a snapshot instead of stream if available, | ||
see [here](./config.for.camera.snapshot.md#beagle-camera). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# RTSP cameras | ||
# Web Cam - RTSP stream | ||
|
||
## Caution | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Web Cam - snapshot | ||
|
||
Some cameras expose single image snapshot under specific URL. | ||
we can use the ultimate power of `curl` command to fetch the image from the camera. | ||
|
||
This is the preferred way to use web cams because right now Prusa Connect do not | ||
support streams, and thus there is no point in wasting CPU on that. | ||
|
||
The best option to check what is the URL is in the camera manual, or if you | ||
open web UI of the camera and see the still image then right click on the image | ||
and select Inspect to see the URL for the image - copy that URL. | ||
|
||
You should be able to test the stream locally with `ffplay` command. | ||
|
||
For example, if your camera is reachable over address `192.168.0.20` and port `8001` | ||
under endpoint `/snap.jpg` then below command should show the image: | ||
|
||
```shell | ||
curl -vvv http://another-cam.local:8081/snap.jpg -o snap.jpg | ||
``` | ||
|
||
then you should see in the output something like `Content-Type: image/jpeg`, | ||
then you are good - see `snap.jpg` in the folder you executed the command. | ||
|
||
## Create config for script | ||
|
||
- copy `snapshot.dist` as `.env` | ||
- in copied file `.env` replace `token-change-me` with the value | ||
of the token you copied | ||
- in copied file `.env` replace `fingerprint-change-me` with some | ||
random value, which is alphanumeric and has at least 16 chars (and max of 40 chars), | ||
for example set it to `fingerprint-myprinter3-camera-3` | ||
- in copied file `.env` replace your esphome device address and port | ||
in `CAMERA_COMMAND_EXTRA_PARAMS` | ||
- save edited file `.env` | ||
|
||
Next, [test config](./test.config.md). | ||
|
||
## Real world example | ||
|
||
### esp32 with esphome | ||
|
||
For more in-depth details see [esphome snapshot](./config.for.camera.esphome.snapshot.md). | ||
|
||
I have esp32-wrover-dev board with camera + esphome + web ui for camera exposing | ||
snapshot frame on port `8081`. | ||
|
||
We can use curl to fetch it. | ||
|
||
```shell | ||
PRINTER_ADDRESS=127.0.0.1 | ||
PRUSA_CONNECT_CAMERA_TOKEN=redacted | ||
PRUSA_CONNECT_CAMERA_FINGERPRINT=06f47777-f179-4025-bd80-9e4cb8db2aed | ||
CAMERA_DEVICE=/dev/null | ||
CAMERA_COMMAND=curl | ||
CAMERA_COMMAND_EXTRA_PARAMS=http://esp32-wrover-0461c8.local:8081/ -o | ||
``` | ||
|
||
### Beagle Camera | ||
|
||
This is not tested, I do not own such camera so hard to tell if this is right. | ||
|
||
Camera URL for snapshot `http://192.168.2.92/images/snapshot0.jpg` so the config | ||
should be like below: | ||
|
||
```shell | ||
PRINTER_ADDRESS=127.0.0.1 | ||
PRUSA_CONNECT_CAMERA_TOKEN=redacted | ||
PRUSA_CONNECT_CAMERA_FINGERPRINT=06f47777-f179-4025-bd80-9e4cb8db2aed | ||
CAMERA_DEVICE=/dev/null | ||
CAMERA_COMMAND=curl | ||
CAMERA_COMMAND_EXTRA_PARAMS=http://192.168.2.92/images/snapshot0.jpg -o | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
# Performance | ||
|
||
- Raspberry Pi Zero W is able to process CSI camera (Rpi Cam v2) and USB 2k camera | ||
- Raspberry Pi Zero W is able to process [CSI camera](./config.for.camera.csi.libcamera.md) | ||
(Rpi Cam v2) and [USB 2k](./config.for.camera.usb.md) camera | ||
but it has load average about 1.4, and CPU is quite well utilized, so you may | ||
need to decrease resolution per camera to see how it goes. | ||
need to [decrease resolution](./configuration.tuning.md) per camera to see how | ||
it goes. | ||
|
||
- ffdshow is usually noticeably slow and cpu intensive if you do more complex operations | ||
- for webcams it is always better to choose [snapshot](./config.for.camera.snapshot.md) | ||
because it requires less computing both on camera and on the host, | ||
otherwise we need to use ffmpeg | ||
|
||
- ffmpeg is usually noticeably slow and cpu intensive, especially if you do more | ||
complex operations |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PRINTER_ADDRESS=127.0.0.1 | ||
PRUSA_CONNECT_CAMERA_TOKEN=token-change-me | ||
PRUSA_CONNECT_CAMERA_FINGERPRINT=fingerprint-change-me | ||
CAMERA_DEVICE=/dev/null | ||
CAMERA_COMMAND=ffmpeg | ||
CAMERA_COMMAND_EXTRA_PARAMS="-y -i 'http://beaglecam-1.local:8080/ipcam/mjpeg.cgi' -vframes 1 -q:v 1 -f image2 -update 1 " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PRINTER_ADDRESS=127.0.0.1 | ||
PRUSA_CONNECT_CAMERA_TOKEN=token-change-me | ||
PRUSA_CONNECT_CAMERA_FINGERPRINT=fingerprint-change-me | ||
CAMERA_DEVICE=/dev/null | ||
CAMERA_COMMAND=curl | ||
CAMERA_COMMAND_EXTRA_PARAMS="--max-time 5 'http://another-cam.local:8081/snap.jpg' -o " |