go2rtc icon indicating copy to clipboard operation
go2rtc copied to clipboard

Ghost ffmpeg-Process

Open cavernerg opened this issue 1 year ago • 4 comments

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:[email protected]:554/livestream/11
    - ffmpeg:[email protected]:554/livestream/12
    - ffmpeg:[email protected]:554/livestream/13
  Einfahrt_mjpeg: 
    - http://[email protected]/livestream/12?action=play&media=mjpeg
  Einfahrt_mjpeg_all: 
    - ffmpeg:http://[email protected]/livestream/11?action=play&media=mjpeg
    - ffmpeg:http://[email protected]/livestream/12?action=play&media=mjpeg
    - ffmpeg:http://[email protected]/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?

cavernerg avatar Oct 10 '24 14:10 cavernerg

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.

AlexxIT avatar Oct 10 '24 18:10 AlexxIT

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

cavernerg avatar Oct 12 '24 19:10 cavernerg

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

AlexxIT avatar Oct 13 '24 04:10 AlexxIT

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

cavernerg avatar Oct 13 '24 09:10 cavernerg