Skip to content

Commit 046ca36

Browse files
committed
fix: Creality K1 series camera over MJPEG on :8080 (#38) — K1 SE/K1/K1C/K1 Max go straight to mjpg-streamer, other models fall back to it when WebRTC on :8000 fails; optional camera address in Creality printer settings
1 parent 1461f76 commit 046ca36

19 files changed

Lines changed: 203 additions & 7 deletions

File tree

‎renderer/cam/cam.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ async function startCrePeer(camId, ip) {
261261
} catch (err) {
262262
console.warn(`[cam-detach] Creality WebRTC failed for ${ip}:`, err.message);
263263
stopCrePeer(camId);
264+
// No WebRTC service (K1 series) → mjpg-streamer on :8080 (issue #38).
265+
const img = document.createElement('img');
266+
img.className = 'cam-frame mjpeg-img';
267+
img.alt = 'camera';
268+
img.draggable = false;
269+
img.referrerPolicy = 'no-referrer';
270+
img.onload = img.onerror = () => img.closest('.cam-card-body')?.querySelector('.cam-loading-overlay')?.remove();
271+
img.src = `http://${ip}:8080/?action=stream`;
272+
videoEl.replaceWith(img);
264273
}
265274
}
266275

‎renderer/css/40-printers.css‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,7 @@ details[open] .pba-step-chev { transform: rotate(90deg); }
29362936
.cam-wall-card .pp-cam-full,
29372937
.cam-wall-card .snap-camera-frame,
29382938
.cam-wall-card .cre-cam-video,
2939+
.cam-wall-card .cre-cam-mjpeg,
29392940
.cam-wall-card img[src*="8898"] { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
29402941

29412942
/* ½× compact — spans 1 sub-column (half of a normal card) */
@@ -3145,10 +3146,12 @@ details[open] .pba-step-chev { transform: rotate(90deg); }
31453146
.cam-card-body .pp-cam-full,
31463147
.cam-card-body .snap-camera-frame,
31473148
.cam-card-body .cre-cam-video,
3149+
.cam-card-body .cre-cam-mjpeg,
31483150
.cam-card-body img[src*="8898"],
31493151
.printer-card-thumb .pp-cam-full,
31503152
.printer-card-thumb .snap-camera-frame,
31513153
.printer-card-thumb .cre-cam-video,
3154+
.printer-card-thumb .cre-cam-mjpeg,
31523155
.printer-card-thumb img[src*="8898"] { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
31533156
/* A feed FILLS its box; the box alone decides the shape. Needed because the
31543157
photo area sizes any image to its intrinsic size (`width/height: auto`,

‎renderer/css/55-creality.css‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
object-fit:contain keeps the full camera frame visible with letterbox
1313
bars rather than cropping. Use "cover" if you prefer edge-to-edge fill
1414
at the cost of slight cropping on non-16:9 streams. */
15-
.cre-cam-video {
15+
.cre-cam-video,
16+
.cre-cam-mjpeg {
1617
position: absolute;
1718
top: 0;
1819
left: 0;

‎renderer/inventory.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import {
8787
acuLight, acuMove, acuHome, acuMotorsOff, acuFan, acuSetSpeedMode,
8888
} from './printers/anycubic/index.js';
8989
import { renderAcuCamBanner } from './printers/anycubic/widget_camera.js';
90-
import { renderCreCamBanner, startCreCam, stopCreCam, reAttachCreCamConsumers, addCreCamConsumer, removeCreCamConsumer } from './printers/creality/widget_camera.js';
90+
import { renderCreCamBanner, startCreCam, stopCreCam, reAttachCreCamConsumers, addCreCamConsumer, removeCreCamConsumer, creCamMjpegUrl } from './printers/creality/widget_camera.js';
9191
import {
9292
snapKey, snapGetConn, snapIsOnline,
9393
snapPingPrinter,
@@ -24529,6 +24529,9 @@ import { jobBar, jobBarFill } from './printers/job-bar.js';
2452924529
if (p.brand === "creality") {
2453024530
const conn = creGetConn(creKey(p));
2453124531
if (!conn || conn.status !== "connected" || !conn.ip) return [];
24532+
// K1 series / custom address → the MJPEG stream (issue #38).
24533+
const mjpeg = creCamMjpegUrl(conn.ip);
24534+
if (mjpeg) return [{ brand: "creality", id: p.id, name, camType: "mjpeg", url: mjpeg, bblKey: null, ip: null }];
2453224535
return [{ brand: "creality", id: p.id, name, camType: "webrtc",
2453324536
ip: conn.ip, url: null, bblKey: null }];
2453424537
}

‎renderer/locales/de.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@
768768
"printerHintCrealityIP": "Lokale Netzwerk-IP.",
769769
"printerHintCrealityAccount": "Immer 'Root' bei Creality K-Serie.",
770770
"printerHintCrealityPassword": "Klipper / Moonraker Zugangspasswort.",
771+
"printerLblCameraUrl": "Kamera-Adresse",
772+
"printerHintCrealityCameraUrl": "Optional — die Kamera wird meist von selbst gefunden. Nur für ein eigenes Setup: die Adresse ihres Videostreams.",
771773
"printerHintElegooIP": "Lokale Netzwerk-IP.",
772774
"printerHintElegooSerial": "Seriennummer vom Über-Bildschirm.",
773775
"printerHintElegooMqtt": "Zugangscode aus den Netzwerkeinstellungen des Druckers (Standard: 123456).",

‎renderer/locales/en.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@
768768
"printerHintCrealityIP": "Local network IP.",
769769
"printerHintCrealityAccount": "Always 'Root' on Creality K-series.",
770770
"printerHintCrealityPassword": "Klipper / Moonraker access password.",
771+
"printerLblCameraUrl": "Camera address",
772+
"printerHintCrealityCameraUrl": "Optional — the camera is usually found on its own. Only for a custom setup: the address of its video stream.",
771773
"printerHintElegooIP": "Local network IP.",
772774
"printerHintElegooSerial": "Serial number from the printer's About screen.",
773775
"printerHintElegooMqtt": "Access code from the printer's network settings (default: 123456).",

‎renderer/locales/es.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@
768768
"printerHintCrealityIP": "IP de la red local.",
769769
"printerHintCrealityAccount": "Siempre 'Root' en la serie K de Creality.",
770770
"printerHintCrealityPassword": "Contraseña de acceso Klipper / Moonraker.",
771+
"printerLblCameraUrl": "Dirección de la cámara",
772+
"printerHintCrealityCameraUrl": "Opcional — la cámara suele encontrarse sola. Solo para una configuración propia: la dirección de su vídeo.",
771773
"printerHintElegooIP": "IP de la red local.",
772774
"printerHintElegooSerial": "Número de serie en la pantalla Acerca de.",
773775
"printerHintElegooMqtt": "Código de acceso desde la configuración de red de la impresora (por defecto: 123456).",

‎renderer/locales/fr.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@
768768
"printerHintCrealityIP": "IP locale du réseau.",
769769
"printerHintCrealityAccount": "Toujours 'Root' sur les Creality K-series.",
770770
"printerHintCrealityPassword": "Mot de passe d'accès Klipper / Moonraker.",
771+
"printerLblCameraUrl": "Adresse de la caméra",
772+
"printerHintCrealityCameraUrl": "Facultatif — la caméra est d'habitude trouvée toute seule. Seulement pour une config perso : l'adresse de son flux vidéo.",
771773
"printerHintElegooIP": "IP locale du réseau.",
772774
"printerHintElegooSerial": "Numéro de série affiché dans l'écran À propos.",
773775
"printerHintElegooMqtt": "Code d'accès depuis les réglages réseau de l'imprimante (par défaut : 123456).",

‎renderer/locales/it.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@
768768
"printerHintCrealityIP": "IP della rete locale.",
769769
"printerHintCrealityAccount": "Sempre 'Root' sulle Creality serie K.",
770770
"printerHintCrealityPassword": "Password di accesso Klipper / Moonraker.",
771+
"printerLblCameraUrl": "Indirizzo della videocamera",
772+
"printerHintCrealityCameraUrl": "Facoltativo — di solito la videocamera si trova da sola. Solo per una configurazione personalizzata: l'indirizzo del suo flusso video.",
771773
"printerHintElegooIP": "IP della rete locale.",
772774
"printerHintElegooSerial": "Numero di serie nella schermata Informazioni.",
773775
"printerHintElegooMqtt": "Codice di accesso dalle impostazioni di rete della stampante (predefinito: 123456).",

‎renderer/locales/nl.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,8 @@
768768
"printerHintCrealityIP": "Lokaal netwerk-IP.",
769769
"printerHintCrealityAccount": "Altijd 'Root' op Creality K-serie.",
770770
"printerHintCrealityPassword": "Klipper-/Moonraker-toegangswachtwoord.",
771+
"printerLblCameraUrl": "Camera-adres",
772+
"printerHintCrealityCameraUrl": "Optioneel — de camera wordt meestal vanzelf gevonden. Alleen voor een eigen opstelling: het adres van de videostream.",
771773
"printerHintElegooIP": "Lokaal netwerk-IP.",
772774
"printerHintElegooSerial": "Serienummer van het Over-scherm van de printer.",
773775
"printerHintElegooMqtt": "Toegangscode uit de netwerkinstellingen van de printer (standaard: 123456).",

0 commit comments

Comments
 (0)