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

Lifecycle Hooks #1380

Open JoeHogan opened 3 weeks ago

JoeHogan commented 3 weeks ago

Are there lifecycle hooks in go2rtc? I didn't see anything about this in the docs. I'd like to be able to run a command when a stream connects or disconnects. My use case is that ffmpeg is generating images from my streams every few seconds and putting them in a folder. I'd like to delete the image when the respective stream goes down. I was formerly using MediaMtx to do this, but I have moved to go2rtc to take advantage of hardware acceleration. Here is an example from MediaMtx that may help explain:

pathDefaults:
  runOnReady: ffmpeg -i rtsp://localhost:$RTSP_PORT/$RTSP_PATH -vf fps=1/3 -update 1 -y /img/$MTX_PATH.jpg
  runOnReadyRestart: yes
  runOnNotReady: rm /img/$MTX_PATH.jpg
AlexxIT commented 2 weeks ago

That's a pretty big upgrade. And it's the first time I've ever heard of anyone needing it. Requires significant research into user scenarios.