Cannot send RTP packet not associated to a Consumer

Greetings!
First of all thanks for awesome project, its crazy.

So, i need some help.
I’m using an mediasoup-demo and trying to record video with fluent-ffmpeg
My idea is to start recording video right after new customer connected. I’m think about getting RTP packets and write with fs.fileWriteStream and than convert them to needed format with ffmpeg

So what it done:

const tempFilePath = path.join(__dirname, '..', 'recording', `${Date.now()}.webm`);
const fileWriteStream = fs.createWriteStream(tempFilePath);

const directTransport = await this._mediasoupRouter.createDirectTransport();

const directProducer = await directTransport.produce({
	kind          : producer.kind,
	rtpParameters : producer.rtpParameters
});

const directConsumer = await directTransport.consume({
	producerId      : directProducer.id,
	rtpCapabilities : this._mediasoupRouter.rtpCapabilities
});

directConsumer.on('rtp', (rtpPacket) =>
{
	logger.info('rtpPacket', rtpPacket);
	const buffer = Buffer.from(rtpPacket.data);

	fileWriteStream.write(buffer);
});

directProducer.on('transportclose', () =>
{
	const ffmpegProcess = ffmpeg()
		.input(tempFilePath)
		.outputOptions([
			'-c:v libx264',
			'-preset ultrafast'
		])
		.output('output.mp4')
		.on('end', () =>
		{
			logger.info('Video conversion finished');
			fs.unlinkSync(tempFilePath);
		})
		.run();
});

But after connection and trying to producing data i have an error

RTC::DirectTransport::SendRtpPacket() | cannot send RTP packet not associated to a Consumer

I read the documentation (which is also great) but cant find any solution with this.
Can anybody help me?
Thanks and have a nice day!

That log only happens when probation RTP packets are sent (which do not have an associated Consumer). And those probation packets are sent because, for whatever happy reason, you are passing rtpCapabilities: this._mediasoupRouter.rtpCapabilities to transport.consume(), which is something that everyone does and honestly I don’t really understand why. You don’t want that mediasoup tests the available bandwidth of your DirectTransport so you should not give RtpCapabilities that include support for “transport-cc” and so on.

1 Like

Thank you for your quick response.
I understand that you may be tired of our stupid questions)))
But I really don’t understand what should I do with “rtpCapabilities”.
I’m not very good at this, but thanks for the direction in solving my mistakes.

No, the question was not stupid at all. I’m just curious about why everybody tries to use router.rtpCapabilities whne they need to call transport.consume() for a device/endpoint different than a browser.

1 Like

Very appreciate for your response.
This helps me with understanding and now my recording process working as should be.
You are the best!!! :pray: