ESP32 cam with Frigate (Getting MJPEG stream working with Frigate)

I’m trying to get object detection with Frigate (addon) working with an ESP32 camera. Since the ESP32 provides an MJPEG stream, I’ve been struggling to get the Frigate config set up such that ffmpeg can correctly process the ESP32 stream.

Below is my current config. The input_args were set as per the Frigate Documentation. This is running on an RPi 4B.

cameras:
  esp_cam:
    ffmpeg:
      input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg
      inputs:
        - path: http://192.168.1.48/mjpeg/1
          roles:
            - detect
      
    detect:
        width: 1600
        height: 1200
        fps: 5

detectors:
    cpu1:
        type: cpu
    cpu2:
        type: cpu

But I’m getting the following error:

frigate.video                  ERROR   : esp_cam: Unable to read frames from ffmpeg process.
frigate.video                  ERROR   : esp_cam: ffmpeg process is not running. exiting capture thread...
watchdog.esp_cam               ERROR   : Ffmpeg process crashed unexpectedly for esp_cam.
watchdog.esp_cam               ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
ffmpeg.esp_cam.detect          ERROR   : [flv @ 0x55bf69c6b0] Video codec mjpeg not compatible with flv
ffmpeg.esp_cam.detect          ERROR   : Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented
ffmpeg.esp_cam.detect          ERROR   : Error initializing output stream 0:0 -- 

I can confirm that the camera works, I get a video stream when I navigate to http://192.168.1.48/mjpeg/1.

Any advice would be really appreciated.

bump

any help would be appreciated

You need to disable RTMP or use the necessary output args as are described in those same docs you linked

rtmp:
  enabled: false

OR

output_args:
  record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an
  rtmp: -c:v libx264 -an -f flv
1 Like

Hello and sorry if i jump on this here…
My Mjpeg always crashes and i dont have any camera working as soon i try make my mjpeg camera to work.
I have the following config in the go2rtc section:

go2rtc:
  streams:
    mjpeg_table_cam:
      - ffmpeg:"http://192.168.178.85:2112/stream#video=h264#hardware"

and this in the camera section:

  table_cam:
    ffmpeg:
      output_args:
        record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps
          1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a aac

      inputs:
# #      # High Resolution Stream
        - path: rtsp://127.0.0.1:8554/mjpeg_table_cam
          roles:
            - record
   #      # Low Resolution Stream
        - path: rtsp://127.0.0.1:8554/mjpeg_table_cam
          roles:
            - detect

all i am getting with this is that fmpeg is crashing for all cameras, also for the ones that are otherwise working
Hope someone has a hint

this is wrong, your stream is not h265

Wohh…hold your horses…where does that 265 now come into play?
Can u lighten this up for me?

I don’t know where you got that from or why it is there, I am telling you that it should not be in the config. You might as well let it use the default record args

Hello, and thx for your answer.

I checked and cannot tell where I got it from…strange…
Either way, I still cant get anything going.
As soon I add Hardware into the go2rtc section my fmepg process crashes and i loose all cameras.
Without the Hardware i do have all cams but this one
Any idea where I could start?

Thx alot

I got it working:

Blockquote
table_cam:
ffmpeg:
input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1
output_args:
record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an
inputs:
- path: http://192.168.178.85:2112/stream
roles:
- detect
- record