Trigger starting ffmpeg as a signal source when a clients connects to ffserver
The idea is that if you start ffserver to stream feeds generated by ffmpeg, the feeds need to be started independent of anyone is looking at the stream or not. If you're doing transcoding on the fly this could mean a lot of wasted CPU cycles encoding content that nobody watches.
This script is a quick-fix, allowing you to trigger the ffmpeg stream start when a client connects to ffserver. The ffmpeg stream presumably ends after a set period of time (e.g. -t 00:15:00) and will finish on its own even if the client disconnected.
Installation:
- install File::Tail: sudo apt-get install libfile-tail-perl
- copy ffserver-trigger.pl to /usr/local/bin
- edit restartFFMpeg() to fit your needs
- copy ffserver-trigger.service to /etc/systemd/system
- test ffserver-trigger.pl by running it manually until it works as desired (logging goes to syslog)
- enable the ffserver-trigger service: sudo systemctl enable ffserver-trigger
- profit ?