Consuming Media in an External Endpoint(RTP OUT)

I am working on a web application which has the feature of recording where i need to record the videos & audios of the users on the server who joins the multiparty video conference.

I am using mediasoup webrtctransport to carry user streams to server and converting it into plainrtptransport on server. In plainrtptransport.connect() , i’m passing the local ip and remotertpport as params.

Then i am using sdp file which uses the same remotertpport mentioned in the plainrtptransport and spawning a ffmpeg process which uses the sdp file and generates a recording file.

sdp = v=0 o=- 0 0 IN IP4 s=FFmpeg c=IN IP4 t=0 0 m=video ${Video.RtpPort} RTP/AVP 101 a=rtpmap:101 VP8/90000 a=sendonly m=audio ${Audio.RtpPort} RTP/AVP 100 a=rtpmap:100 opus/48000/2 a=sendonly;

NOTE: The remotertpports mentioned above are randomly picked and these ports are checked if they are free before being assigned and the ports are different for audio and video consumers.

FFmpeg command i am using :

ffmpeg -analyzeduration 2147483647 -probesize 2147483647 -hide_banner -loglevel debug -protocol_whitelist pipe,udp,rtp -fflags +genpts -f sdp -i pipe:0 -vcodec copy -acodec copy outputfile.webm

Now my issue is the above code snippet works fine i am getting the user video and audio stream recorded on server and saved as webm format but sometimes i am getting an error in ffmpeg logs stating that

Opening an input file: pipe:0.
[sdp @ 0x62c8540] Opening ‘pipe:0’ for reading
[sdp @ 0x62c8540] video codec set to: vp8
[sdp @ 0x62c8540] audio codec set to: opus
[sdp @ 0x62c8540] audio samplerate set to: 48000
[sdp @ 0x62c8540] audio channels set to: 2
[udp @ 0x62d0f80] end receive buffer size reported is 425984
[udp @ 0x62d0c40] end receive buffer size reported is 425984
[sdp @ 0x62c8540] setting jitter buffer size to 500
[udp @ 0x62ca080] end receive buffer size reported is 425984
[udp @ 0x62d08c0] bind failed: Address already in use
[udp @ 0x62d1480] bind failed: Address already in use
[AVIOContext @ 0x62d1880] Statistics: 265 bytes read, 0 seeks
pipe:0: Invalid data found when processing input

I would really appreciate if you have any idea on how to proceed. Please tell me if more information is needed.

Thanks a lot!