Get raw audio from RTP packet with DirectTransport

Hi!

does anyone have experience manipulating the RTP packets with DirectTransport with rtp.js library? I would like to extract the raw audio of the specific producer to manipulate in Nodejs

        const room = Room.getRoom(roomId);
        const router = room.router;
        const directTransport = await router.createDirectTransport();
        const audioProducer = getProducer(roomId, id, 'audio');
        const consumer = await directTransport.consume({ producerId: audioProducer.id, rtpCapabilities: router.rtpCapabilities });
        consumer.on('rtp', (rtpPacket) => {
             const packet = new rtp.RtpPacket(rtpPacket);
             const payload = packet.getPayload();
        }

Thanks in advance

The answer is yes.

Perfect!

Can you share some examples to understand how to get the raw audio from RTP packet with rtp.js library?

Thank you :slight_smile:

I cannot, sorry. We write API documentation for something.

1 Like

Hi, thanks!

The documentation of the RTP.js API only says that getPayload return a Buffer but I don’t know how to process the audio data from here (RtpPacket | rtp.js - v0.0.1). I only need a little advice about how to do that

Thanks again <3

Me neither. And that’s not something that the library is supposed to help with.

What you want in general is to have RTP jitterbuffer, then depayer that will extract encoded audio from RTP and only then you can decode Opus or whatever codec you decided to use to get raw audio out of it.
This is what tools like libav/ffmpeg and GStreamer are often used for.

1 Like