[FFmpeg-user] FFmpeg CLI - swap RTMP source using ZMQ (zmqsend)

Jess Portnoy jess.portnoy at kaltura.com
Tue Apr 21 15:00:06 EEST 2020


Hello all,

My setup is as follows:

- Nginx with the RTMP module
- Multiple RTMP stream pairs, each one with a primary and backup RTMP endpoint (so streaming to rtmp://localhost/main/$STREAM_NAME and rtmp://localhost/backup/$STREAM_NAME)
- Using the Nginx RTMP module `exec_publish` and `exec_publish_done` hooks, I push either main or backup to an FFmpeg CLI proc that restreams it to a remote RTMP endpoint (Wowza server in this case, though it's not very relevant to my question)

My problem is that currently, if the main stream is stopped, I have to stop the FFmpeg CLI process that restreams to Wowza and start another with a new input source (the backup stream). This often causes issues on the Wowza side so I'm looking for a way to avoid that.

After some research, I found that FFmpeg encapsulated ZMQ support but it seems documentation is somewhat sparse. Is it possible to send a message to the running FFmpeg process to alert it that it must change its source to a different RTMP stream?

I have reviewed https://ffmpeg.org/pipermail/ffmpeg-user/2014-August/022827.html which seems to suggest that perhaps this can be accomplished but requires implementing extra functionality.

I found some examples for using ZMQ to send commands to a running FFmpeg CLI proc, for instance:
https://lists.ffmpeg.org/pipermail/ffmpeg-user/2016-September/033777.html

But no example for what I'm trying to achieve. If it doesn't exist, I am happy to implement it myself as suggested in the first thread I referenced but would appreciate any pointers.

Another alternative, if it's possible and easier, would perhaps be to start the FFmpeg proc with two input sources and somehow toggle between them with a select filter. For my purposes, one doesn't actually have to be an RTMP stream, it can be a media file that I have on the FS. A flow such as:
If the source RTMP stream receives data, restream to Wowza, otherwise, stream the backup media file would also work well for me.

Thanks in advance,

-- 
May the source be with you,

Jess Portnoy


More information about the ffmpeg-user mailing list