Files
flexcam/pc/mjpeg_client.py
This-null d52b4b743c FlexCam — phone as a PC webcam over USB or WiFi
Android (Kotlin/CameraX) MJPEG server + Python desktop app (pywebview UI)
feeding OBS Virtual Camera. Hybrid USB/WiFi with auto-connect and failover,
front/back switch, auto-rotate, foreground service, tray, Discord rich
presence, 10 languages, and a prebuilt APK.
2026-08-23 19:53:47 +03:00

29 lines
785 B
Python

class MjpegParser:
SOI = b"\xff\xd8"
EOI = b"\xff\xd9"
def __init__(self):
self._buf = bytearray()
self._ready = []
def feed(self, chunk: bytes) -> None:
self._buf.extend(chunk)
while True:
start = self._buf.find(self.SOI)
if start < 0:
if len(self._buf) > 2:
del self._buf[:-1]
return
end = self._buf.find(self.EOI, start + 2)
if end < 0:
if start > 0:
del self._buf[:start]
return
end += 2
self._ready.append(bytes(self._buf[start:end]))
del self._buf[:end]
def frames(self):
while self._ready:
yield self._ready.pop(0)