mediamtx icon indicating copy to clipboard operation
mediamtx copied to clipboard

encoder_encode(): ioctl(VIDIOC_QBUF) failed

Open mwolfeu opened this issue 1 year ago • 2 comments

Which version are you using?

v1.2.0

Which operating system are you using?

  • [ ] Linux amd64 standard
  • [ ] Linux amd64 Docker
  • [ ] Linux arm64 standard
  • [ ] Linux arm64 Docker
  • [ ] Linux arm7 standard
  • [ ] Linux arm7 Docker
  • [x] Linux arm6 standard
  • [ ] Linux arm6 Docker
  • [ ] Windows amd64 standard
  • [ ] Windows amd64 Docker (WSL backend)
  • [ ] macOS amd64 standard
  • [ ] macOS amd64 Docker
  • [ ] Other (please describe)

Describe the issue

Ioctl errors occur at low rpiCameraBitrates (100000) with rapid video changes.
Currently my camera is immobilized to prevent the cable jiggling. The 3mo old RPi 4 is on a solid platform without vibration. I have tested 5 different cameras (4 were just unboxed yesterday). All exhibit the same issue. rpiCameraBitrate: 700000 seems stable.

I wrote a script to restart mediamtx whenever the ioctl problem prints to the logs. The camera has always (thus far) come back without issue.

Describe how to replicate the issue

  1. set rpiCameraBitrates to something low (I used 1/10th the default value)
  2. start the server with the rpi mipi camera configured
  3. rapidly/repeatedly change the full frame of the video. I pointed it at a white wall and quickly waved my hands in front of it blocking the lens with my hand, and pulling my hand away. This never took more than 1min to break it.

Did you attach the server logs?

no

Did you attach a network dump?

no

mwolfeu avatar Oct 27 '23 11:10 mwolfeu

I'm having the same issue but wasn't able to nail down a root cause:

  • Raspberry Pi OS (Bookworm) 32 bit on a Raspberry Pi Zero 2W with Camera Module 3
  • mediamtx v1.8.1 against libcamera v0.2.0 (via symlink-hack)
  • resolution/fps: 1920x1080 10 fps (iirc)
  • 1-3 clients on an RTSP stream

The stream works flawlessly for a couple of hours but then it suddenly starts to endlessly report the mentioned error:

…
2024/05/13 12:07:47 INF [RTSP] [conn 10.9.9.127:34234] opened
2024/05/13 12:07:47 INF [RTSP] [session eaa5d52c] created by 10.9.9.127:34234
2024/05/13 12:07:47 INF [RTSP] [session eaa5d52c] is reading from path 'cam', with TCP, 1 track (H264)
encoder_encode(): ioctl(VIDIOC_QBUF) failed
encoder_encode(): ioctl(VIDIOC_QBUF) failed
encoder_encode(): ioctl(VIDIOC_QBUF) failed
encoder_encode(): ioctl(VIDIOC_QBUF) failed
encoder_encode(): ioctl(VIDIOC_QBUF) failed
encoder_encode(): ioctl(VIDIOC_QBUF) failed
…

I cannot tell the time difference between the last timestamped log line and the encoder_encode error.

In between the error lines there was some attempt to resume something (the camera?) and the connected clients were endlessly switching between a still image and a short video sequence which was likely the recently buffered frames in some kind of ringbuffer.

Sorry for the vague description. I'm still not able to reliably reproduce the issue. Turning down the bitrate as suggested and swinging the camera around didn't trigger it for me.

Before coming across this issue I assumed the symlink-hack was the causing this instability. I have a second setup using a freshly compiled version if mediamtx against libcamera 0.2.0 which I will try next. But without a reliable way to reproduce this issue it will be hard to tell whether things improved.

I report back as soon as I know more.

@mwolfeu Did you ever find a solution other than restarting the service?

kawogi avatar May 13 '24 23:05 kawogi

I am also having this issue.

  • MediaMTX 1.8.3
  • Raspberry Pi 4 running 64bit Bookworm
  • Arducam OV5647

I had been running motioneye on this hardware setup for years without issue, but wanted to incorporate this camera into Frigate with an RTSP stream. I kept getting this error so I replaced the cable but that didn't fix it. Mine seems to be completely random, as sometimes it fails immediately, even before clients connect to the stream, and other times not. The longest I have had it run before dying was around 10 minutes.

jknigga avatar Jul 10 '24 15:07 jknigga