AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.94k stars 397 forks source link

Ghost ffmpeg-Process #1390

Open cavernerg opened 1 week ago

cavernerg commented 1 week ago

I have a weird issue with my USB-Cam-Setup.

This is my config:

streams:
  MK4SESP: http://192.168.2.29:81/cam.mjpeg
  MK4SASeite: ffmpeg:device?video=/dev/video2&input_format=mjpeg&video_size=1600x896
  MK4SHinten: ffmpeg:device?video=/dev/video0&input_format=mjpeg&video_size=1280x720
  MK3SESP: http://192.168.2.80:81/cam.mjpeg
  #esp32cam2: ffmpeg:http://192.168.2.29:81/stream#video=h264#rotate=180
  Einfahrt: 
    - ffmpeg:xxx@192.168.2.100:554/livestream/11
    - ffmpeg:xxx@192.168.2.100:554/livestream/12
    - ffmpeg:xxx@192.168.2.100:554/livestream/13
  Einfahrt_mjpeg: 
    - http://xxx@192.168.2.100/livestream/12?action=play&media=mjpeg
  Einfahrt_mjpeg_all: 
    - ffmpeg:http://xxx@192.168.2.100/livestream/11?action=play&media=mjpeg
    - ffmpeg:http://xxx@192.168.2.100/livestream/12?action=play&media=mjpeg
    - ffmpeg:http://xxx@192.168.2.100/livestream/13?action=play&media=mjpeg

#log:
#  level: info
#  api: info
#  exec: info
#  ngrok: info
#  rtsp: info
#  streams: info
#  webrtc: info

USB-Cam Config ist copy&paste from the "Add"-Page. When I start the server, everything is fine. BUT after some time, a ffmpeg process (Output from ps auxww: "ffmpeg -hide_banner -v error -f v4l2 -video_size 1600x896 -input_format mjpeg -i /dev/video2 -c copy -f mjpeg -") starts and uses 100 % CPU.

I installed go2rtc 2 times. One just through tteck proxmox lxc and the other on my own. Both have the same issue. After a restart, I can use the stream from the cam perfectly fine. As soon as this process is there, go2rtc has no access to the device. When the ghost-process is running and I stop the go2rtc-Service, the process goes down. The Ghost-process starts without any interaction after some time. Even if I don't use any of the streams. go2rtc-Log has no enlightening infos.

any hints for me?

AlexxIT commented 1 week ago

Looks like some problems with FFmpeg and your camera. You can increase log level for exec module to trace and check raw ffmpeg log output.

cavernerg commented 1 week ago

I could trace it down to octoprint. Maybe it is DDOSing go2rtc or something. The integration seems buggy.

At some time this appears in the Log:

21:14:17,429    debug   [exec] run pipe args=ffmpeg,-hide_banner,-v,error,-f,v4l2,-input_format,mjpeg,-video_size,1600x896,-i,/dev/video2,-c,copy,-f,mjpeg,-
21:14:14,416    trace   [exec] kill with signal=9

and then CPU goes on full load. This doesn't happen with octoprint being down.

I have Octoprint configured with webcam-support activated using the multicam-plugin. Shutting octoprint down does not stop the CPU load. Once the process is there, there is no coming back. It even comes back, when the I kill the PID.

//edit: Restarting go2rtc-service ends the process

AlexxIT commented 1 week ago

Interesting. kill with signal=9 should close ffmpeg process. But looks like it not closing and starts consuming 100% CPU.

cavernerg commented 1 week ago

My guess is, that octoprint is spamming requests and go2rtc loses the connection to its own processes somehow. But I'm just wildly guessing ;-)