Off Topic - rtp_forward to FFmpeg - connection timeout for SDP session

Hello community,

This is not related to Janus, but related to ffmpeg. We are doing rtp_forward from Janus AudioBridge to ffmpeg. The FFmpeg is running on different ec2 machine in the same VPC. Through FFmpeg, we are converting the RTP to small mp3 chunks.

Below is the command I am using,

/usr/bin/ffmpeg -protocol_whitelist file,crypto,udp,rtp -acodec opus -i /etc/audio/rtp.sdp -acodec libmp3lame -f segment -segment_atclocktime 1 -segment_time 15 -strftime 1 %s.mp3 -v verbose 2>&1

And the SDP file as below,

v=0
t=0 0
m=audio 5002 RTP/AVP 111
c=IN IP4 127.0.0.1
a=recvonly
a=rtpmap:111 opus/48000/2
a=fmtp:98 stereo=1; sprop-stereo=0; useinbandfec=1

The whole pipeline works fine, with no issues. We can generate small chunks of mp3 and then do further transcribing using another service. But after some time, if no packets are being received, the FFmpeg stops with a timeout error

/etc/audio/rtp.sdp: Connection timed out

And this is an issue for us. We are broadcasting financial news related to the stock market throughout the day, but it is not continuous streaming audio. The broadcaster will broadcast if there is important news. E.g., someone will broadcast continuously for 20 mins, and then for 5 mins he/she will disconnect and then again start broadcasting. Now during those 5 minutes, when no UDP packets are received on that port of SDP, ffmpeg stops. So when the broadcaster resumes after 5 minutes, we need to manually restart the FFmpeg, which is not a feasible solution.

I am looking for a way to keep running FFmpeg throughout the day irrespective of whether RTP packets are being received or not. I looked into FFmpeg dos, but could not find any configuration argument that can help.

If you guys have come across such a situation and know the workaround, please do let me know.

Thanks,
Hemraj

Looks like there’s a -listen_timeout property you can set, but not sure what version of FFmpeg they added it to: