javascript – Executing FFmpeg recording using in-line SDP

I’m trying to record audio on a webrtc server in NodeJS using FFmpeg.

I am able to record the audio if I explicitly create an input.sdp file and use it with the “-i” flag of FFmpeg.

My question is: How to create a string in the code to dynamically change port numbers for recording different streams at the same time?

I tried doing this:

    const sdpInfo = `data:application/sdp;charset=UTF-8,v=0no=- 0 0 IN IP4 ${ipAddr}ns=-nc=IN IP4 ${ipAddr}nt=0 0nm=audio ${port} RTP/AVPF 111na=rtcp:${port+1}na=rtpmap:111 opus/48000/2na=fmtp:111 minptime=10;useinbandfec=1`

However, if I give it as input with “-i” flag, I get the following error:

data:application/sdp;charset=UTF-8,v=0: Invalid data found when processing input

Can someone please help?

Read more here: Source link