Reputation: 809
I want two merge two mp3 input rtp streams together and save them as mp3 file, with the following command:
ffmpeg -i rtp://127.0.0.1:5004?listen -i rtp://127.0.0.1:5005?listen -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame q:a 4 output.mp3
Which returned the error bind failed: Error number -10048 occured rtp://127.0.0.1:5005?listen: I/O error
Before I tried this, I first tried to merge two mp3 file together with the following, working, command:
ffmpeg -i input01.mp3 -i input02.mp3 -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame -q:a 4 output.mp3
I have also tried to grab each rtp stream individually and create a .wav file output. This also worked with the following command:
ffmpeg -i rtp://127.0.0.1:5004?listen output.wav
With udp i can merge to streams together and create a mp3 output:
ffmpeg -i udp://127.0.0.1:5004?listen -i udp://127.0.0.1:5005 -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame -q:a 4 output.mp3
Does anyone know how two rtp streams can be grabed, merged and written to an mp3 file in ffmpeg? Or is this still only one rtp stream supported like in 2012?
Upvotes: 1
Views: 5691
Reputation: 809
A problem of the command above is the port numbers. If you receive rtp on a port (usually on an even port bigger than 1024), the next bigger port is used for the rtcp.
The command works if you use a port for the second stream, which isn't already in use from something other (like rtcp).
ffmpeg -i rtp://127.0.0.1:5004?listen -i rtp://127.0.0.1:5006?listen -filter_complex amerge -ac 2 -c 2 -c:a libmp3lame -q:a 4 output.mp3
If you want to do the same with raw audio, it's possible you get an error like:
Unable to receive RTP payload type 96 without an SDP file describing it.
To solve this you have to create sdp files with the rtp payload type, codec and sampling rate and use these as ffmpeg input.
SDP example:
v=0
c=IN IP4 127.0.0.1
m=audio 2002 RTP/AVP 96
a=rtpmap:96 L16/16000
Use sdp files as input in FFmpeg:
ffmpeg -i a.sdp -i b.sdp -filter_complex ...
Upvotes: 2