mkuf / prind

print in docker - Deploy a containerized Klipper Stack for your 3D Printer
GNU General Public License v3.0
321 stars 82 forks source link

Slow webcam #156

Closed d-graz closed 3 months ago

d-graz commented 3 months ago

On my Fedora 40 server edition:

ustreamer --host=0.0.0.0 --port=8080 --device=/dev/video2 --resolution=1280x720 --format=MJPEG --desired-fps 30

works great (ustreamer installed locally using dnf). I get around ~20-30 fps With this docker-compose.override.yaml

## Ustreamer base Service
x-ustreamer-svc: &ustreamer-svc
  image: mkuf/ustreamer:latest
  restart: unless-stopped
  command: >
    --host=0.0.0.0
    --port=8080
    --device=/dev/webcam
    --resolution=1280x720
    --format=MJPEG
    --desired-fps=30

## Add your personal config here
services:
  webcam:
    <<: *ustreamer-svc
    devices:
      - /dev/video2:/dev/webcam
    labels:
      org.prind.service: webcam
      traefik.enable: true
      traefik.http.services.webcam.loadbalancer.server.port: 8080
      traefik.http.routers.webcam.rule: PathPrefix(`/webcam`)
      traefik.http.routers.webcam.entrypoints: web
      traefik.http.middlewares.webcam.stripprefix.prefixes: /webcam
      traefik.http.routers.webcam.middlewares: webcam

i can only get 1-5 fps from the stream What i have already tried out:

Currently I'm a bit lost since i do not see any reasonable cause for this to happen. I have also check log container of prind-webcam-1

-- INFO  [24048.818          ] -- Starting PiKVM uStreamer 6.11 ...
-- INFO  [24048.822          ] -- HTTP: Listening HTTP on [0.0.0.0]:8080
-- INFO  [24048.822          ] -- HTTP: Starting eventloop ...
-- INFO  [24048.917          ] -- Using V4L2 device: /dev/webcam
-- INFO  [24048.917          ] -- CAP: Using capture type: single-planar
-- INFO  [24048.917          ] -- CAP: Using input channel: 0
-- INFO  [24048.918          ] -- CAP: Using resolution: 1280x720
-- INFO  [24048.918          ] -- CAP: Using format: MJPEG
-- INFO  [24048.918          ] -- CAP: Using HW FPS: 30
-- ERROR [24048.918          ] -- CAP: Device doesn't support setting of HW encoding quality parameters
-- INFO  [24048.918          ] -- CAP: Using IO method: MMAP
-- INFO  [24048.919          ] -- CAP: Requested 5 device buffers, got 5
-- INFO  [24048.920          ] -- CAP: Capturing started
-- INFO  [24048.920          ] -- Switching to HW encoder: the input is (M)JPEG ...
-- INFO  [24048.920          ] -- Using JPEG quality: encoder default
-- INFO  [24048.920          ] -- Creating pool JPEG with 1 workers ...
-- INFO  [24048.921          ] -- Capturing ...

which is no different from the ustreamer locally installed

-- INFO  [24783.271      main] -- Starting PiKVM uStreamer 5.41 ...
-- INFO  [24783.271      main] -- Using internal blank placeholder
-- INFO  [24783.272      main] -- Listening HTTP on [0.0.0.0]:8080
-- INFO  [24783.272    stream] -- Using V4L2 device: /dev/video2
-- INFO  [24783.272    stream] -- Using desired FPS: 30
-- INFO  [24783.272      http] -- Starting HTTP eventloop ...
================================================================================
-- INFO  [24783.368    stream] -- Device fd=8 opened
-- INFO  [24783.368    stream] -- Using input channel: 0
-- INFO  [24783.369    stream] -- Using resolution: 1280x720
-- INFO  [24783.369    stream] -- Using format: MJPEG
-- INFO  [24783.369    stream] -- Using HW FPS: 30
-- ERROR [24783.369    stream] -- Device doesn't support setting of HW encoding quality parameters
-- INFO  [24783.369    stream] -- Using IO method: MMAP
-- INFO  [24783.370    stream] -- Requested 5 device buffers, got 5
-- INFO  [24783.371    stream] -- Capturing started
-- INFO  [24783.371    stream] -- Switching to HW encoder: the input is (M)JPEG ...
-- INFO  [24783.371    stream] -- Using JPEG quality: encoder default
-- INFO  [24783.371    stream] -- Creating pool JPEG with 1 workers ...
-- INFO  [24783.371    stream] -- Capturing ...

I do not know if it's a specific problem with the uStreamer application or it could be something else.

Once again thank you for the help.

d-graz commented 3 months ago

Found out in fact was a problem of uStreamer itself. Downgrading from :lastest to :v5.41 (the same version of packed in the Fedora repository) did solve the issue