Solved - Recording audio from RTP - decoding errors every 5 seconds

I’m trying to decode an audio RTP stream server-side using the same technique as described in my successful thread here Solved - Can't convince FFMPEG to understand mediasoup's RTP - #5 by neilyoung

This btw meanwhile works perfectly for H.264 and VP8 video only recording.

While trying to use the same approach for audio, I noticed glitches in the recording process raised by ffmpeg. Pretty much exactly every 5 seconds:

stderr:     Last message repeated 1 times
size=     768kB time=00:00:05.14 bitrate=1224.0kbits/s speed=   1x    
stderr: Error while decoding stream #0:0: Invalid argument

stderr: size=    1024kB time=00:00:05.68 bitrate=1476.9kbits/s speed=1.01x    
stderr: size=    1024kB time=00:00:06.20 bitrate=1353.0kbits/s speed=1.01x    
stderr: size=    1024kB time=00:00:06.72 bitrate=1248.3kbits/s speed=1.01x    
stderr: size=    1280kB time=00:00:07.22 bitrate=1452.3kbits/s speed=1.01x    
stderr: size=    1280kB time=00:00:07.74 bitrate=1354.7kbits/s speed=1.01x    
stderr: size=    1536kB time=00:00:08.24 bitrate=1527.1kbits/s speed=   1x    
stderr: size=    1536kB time=00:00:08.76 bitrate=1436.4kbits/s speed=   1x    
stderr: size=    1536kB time=00:00:09.26 bitrate=1358.8kbits/s speed=   1x    
stderr: size=    1792kB time=00:00:09.78 bitrate=1501.0kbits/s speed=   1x    
stderr: Error while decoding stream #0:0: Invalid argument

stderr:     Last message repeated 2 times
size=    1792kB time=00:00:10.28 bitrate=1428.0kbits/s speed=   1x    
stderr: size=    1792kB time=00:00:10.80 bitrate=1359.3kbits/s speed=   1x    
stderr: size=    2048kB time=00:00:11.32 bitrate=1482.1kbits/s speed=   1x    
stderr: size=    2048kB time=00:00:11.82 bitrate=1419.4kbits/s speed=   1x    
stderr: size=    2304kB time=00:00:12.34 bitrate=1529.5kbits/s speed=   1x    
stderr: size=    2304kB time=00:00:12.84 bitrate=1470.0kbits/s speed=   1x    
stderr: size=    2304kB time=00:00:13.36 bitrate=1412.8kbits/s speed=   1x    
stderr: size=    2560kB time=00:00:13.86 bitrate=1513.1kbits/s speed=   1x    
stderr: size=    2560kB time=00:00:14.38 bitrate=1458.4kbits/s speed=   1x    
stderr: size=    2560kB time=00:00:14.88 bitrate=1409.4kbits/s speed=   1x    
stderr: Error while decoding stream #0:0: Invalid argument

stderr:     Last message repeated 2 times
size=    2816kB time=00:00:15.38 bitrate=1499.9kbits/s speed=   1x    
stderr: size=    2816kB time=00:00:15.90 bitrate=1450.9kbits/s speed=   1x    
stderr: size=    3072kB time=00:00:16.40 bitrate=1534.5kbits/s speed=   1x    
stderr: size=    3072kB time=00:00:16.92 bitrate=1487.3kbits/s speed=   1x    
stderr: size=    3072kB time=00:00:17.44 bitrate=1443.0kbits/s speed=   1x    
stderr: size=    3328kB time=00:00:17.96 bitrate=1518.0kbits/s speed=   1x    
stderr: size=    3328kB time=00:00:18.48 bitrate=1475.3kbits/s speed=   1x    
stderr: size=    3328kB time=00:00:18.98 bitrate=1436.4kbits/s speed=   1x    
stderr: size=    3584kB time=00:00:19.48 bitrate=1507.2kbits/s speed=   1x    
stderr: size=    3584kB time=00:00:19.98 bitrate=1469.5kbits/s speed=   1x    
stderr: Error while decoding stream #0:0: Invalid argument

stderr:     Last message repeated 2 times
size=    3840kB time=00:00:20.50 bitrate=1534.5kbits/s speed=   1x    
stderr: size=    3840kB time=00:00:21.00 bitrate=1498.0kbits/s speed=   1x    
stderr: size=    3840kB time=00:00:21.52 bitrate=1461.8kbits/s speed=   1x    
stderr: size=    4096kB time=00:00:22.04 bitrate=1522.4kbits/s speed=   1x    
stderr: size=    4096kB time=00:00:22.56 bitrate=1487.3kbits/s speed=   1x    

I can exclude that the communication line is a problem, since it is all localhost. I’m also a bit astonished about the high bitrate, which looks like nonsense to me.

Any idea what could cause this problem?

The glitches are pretty much NOT audible in the output audio of a WebRTC consumer and also not in the played back audio file later… At least not obvious.

My SDP (parameters derived at runtime from rtpConsumer.rtpParameters.codec[0]):

v=0
o=- 0 0 IN IP4 127.0.0.1
s=Recorder
c=IN IP4 127.0.0.1
t=0 0
m=audio 62000 RTP/AVP 100
a=rtpmap:100 opus/48000/2

The ffmpeg command line as simple as this:

ffmpeg -loglevel debug -protocol_whitelist file,crypto,udp,rtp -i /var/folders/7l/rc18f0m564qgtmjlzn6b_n5m0000gn/T/tmp-42490-N9B4eSMOtKST -c:a pcm_s16le -y /some/path/to/file.wav

Pointers welcome

OK, these decoder errors seem to come from “padding-only” RTP packets, which make ffmpeg stumble.

Here an example of such a sequence: Valid audio payload followed by padding only

I suppose this will only have an impact to ffmpeg, not to the decoded output.

I have the same issue. These are rtp probation packets. I get around it by skipping packets where pkt->size == 0. This only works if you’re using the C api interface to ffmpeg. I’m not sure if there’s a way around this if you’re using the commandline.

I couldn’t find it so for. But it doesn’t disturb, obviously, it just prints an error (IMHO)