Skip to content

camera-streamer: "Cannot open device" on first attempt with libcamera (IMX708) #324

@Werner1303

Description

@Werner1303

Description

camera-streamer consistently fails to open the libcamera device on the first connection attempt when started by crowsnest. The --camera-auto_reconnect=1 flag causes it to retry and succeed, so the stream works — but the initial error always appears in the systemd journal.

When camera-streamer is started manually (outside of crowsnest), it opens the device successfully on the first try every time.

Environment

  • SBC: Raspberry Pi 4 Model B Rev 1.4
  • OS: Raspbian GNU/Linux 11 (bullseye)
  • Kernel: Linux 6.1.21-v8+ aarch64
  • Camera: IMX708 (Raspberry Pi Camera Module 3) via CSI
  • crowsnest: v4.1.17-1-g9cc3d4a
  • camera-streamer: f1627aa
  • libcamera: v0.0.5+83-bde9b04f

Configuration

[cam 1]
mode: camera-streamer
enable_rtsp: false
port: 8080
device: /base/soc/i2c0mux/i2c@1/imx708@1a
resolution: 1920x1080
max_fps: 10
custom_flags: --camera-options=AfMode=Manual --camera-options=LensPosition=5.26

Symptoms

Every time crowsnest starts or restarts, the systemd journal shows:

Cannot open device /base/soc/i2c0mux/i2c@1/imx708@1a, exiting.

After auto_reconnect, the device opens successfully and the stream works:

device/libcamera/device.cc: CAMERA: Device path=/base/soc/i2c0mux/i2c@1/imx708@1a opened

Reproduction

  1. sudo systemctl restart crowsnest
  2. journalctl -u crowsnest -n 15 → "Cannot open device" always appears
  3. curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/snapshot → 200 (stream works)

Investigation

Extensive testing was performed:

  • Manual start of camera-streamer with identical parameters: always succeeds on first try
  • Adding delays (3s, 5s) between detection phase and camera-streamer start: no effect
  • Disabling list_picam_controls and list_picam_resolution (which briefly open the camera during detection): no effect
  • Replacing echo | xargs with direct execution: no effect
  • Replacing pipe to log_output with file redirect: error still appears in journal (not in log file), suggesting camera-streamer internally forks and the child process writes to stderr before inheriting the redirect
  • Checking /dev/video* with fuser: no stale processes holding the device
  • Checking libcamera-hello --list-cameras impact: does not lock the camera

The error appears to be specific to camera-streamer being started as a child process of the crowsnest bash script. It does not occur when camera-streamer is started directly from the command line, even with the exact same parameters, working directory, and pipe chain.

Expected behavior

camera-streamer should open the libcamera device on the first attempt without error, or the initial probe failure should not be logged as an error when auto_reconnect is enabled.

Workaround

The stream works reliably thanks to --camera-auto_reconnect=1. The error message is cosmetic only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions