Hello MediaSoupers,
I am trying to use DirectTransport to save RTP packets to a file for later processing.
Here is the relevant code (I am on Mediasoup 3.10.6) . I am still confused as to what to use on the directTransport.consume as far as rtpCapabilities. If I use the producer’s RTP parameters, the .consume command fails with “invalid ext.kind”. if I use router.rtpCapabilities, it succeeds, but I see the following error on the console over and over. What am I doing wrong???
async localRecToFile(filename,type, producerId,rtpParams){
//create a direct transport from the router
this.logger.info(`localRectToFile recname: ${filename}. type: ${type}. producerId: ${producerId} rtpParams: ${JSON.stringify(rtpParams)}`);
let directTransport = await this.presenterRouter.createDirectTransport();
let consumer = await directTransport.consume({producerId: producerId, rtpCapabilities: this.presenterRouter.rtpCapabilities, paused: true });
//create raw file and sdp file
let sdpString=createSdpText(rtpParams);
let sdpFile=fs.writeFileSync(filename+'_'+type+'.sdp',sdpString);
this.logger.info("localRectToFile sdp:",sdpString);
//create raw file for writting packets
let rawFile=fs.createWriteStream(filename+'_'+type+'.raw');
consumer.on('rtp', (rtpPacket)=>{
const packet = new rtp.RtpPacket(rtpPacket);
rawFile.write(packet.getPayload());
});
consumer.on("producerclose", () =>
{
this.logger.info("localRecToFile consumer closed, finshing raw file...");
rawFile.end();
});
//unpause
consumer.resume();
//hash this to stop them on recStop
this.recRawConsumers.set(consumer.id,consumer);
}
with this code in the console I see:
+4ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected end of JSON input +0ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected token � in JSON at position 0 +1ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected end of JSON input +19ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected token � in JSON at position 0 +0ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected end of JSON input +20ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected token � in JSON at position 0 +0ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected end of JSON input +20ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError: Unexpected token � in JSON at position 0 +0ms
mediasoup:ERROR:PayloadChannel received invalid data from the worker process: SyntaxError:
If I use the priducer’s RTP params, I get “invalid ext.kind”
PTRMediaServer:INFO:Room-5ac778ab1eb3e2287a511ff7 localRectToFile recname: 5ac778ab1eb3e2287a511ff7-06-15-2023__03.09.975_PM-audio__0. type: audio. producerId: 0060acf2-7f27-492f-a60e-66a1c432f2f9 rtpParams: {"codecs":[{"mimeType":"audio/opus","payloadType":111,"clockRate":48000,"channels":2,"parameters":{"minptime":10,"useinbandfec":0,"sprop-stereo":0,"usedtx":0},"rtcpFeedback":[{"type":"transport-cc","parameter":""}]}],"headerExtensions":[{"uri":"urn:ietf:params:rtp-hdrext:sdes:mid","id":4,"encrypt":false,"parameters":{}},{"uri":"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time","id":2,"encrypt":false,"parameters":{}},{"uri":"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01","id":3,"encrypt":false,"parameters":{}},{"uri":"urn:ietf:params:rtp-hdrext:ssrc-audio-level","id":1,"encrypt":false,"parameters":{}}],"encodings":[{"ssrc":1935285331,"dtx":false}],"rtcp":{"cname":"qE5x0el0W0jjuqAM","reducedSize":true},"mid":"0"} +1ms
(node:96227) UnhandledPromiseRejectionWarning: TypeError: invalid ext.kind
at validateRtpHeaderExtension (/Users/srep/Documents/Development/BSConf/ptr_sc_angular/ptr_media_server/node_modules/mediasoup/node/lib/ortc.js:122:15)
at Object.validateRtpCapabilities (/Users/srep/Documents/Development/BSConf/ptr_sc_angular/ptr_media_server/node_modules/mediasoup/node/lib/ortc.js:36:9)
at DirectTransport.consume (/Users/srep/Documents/Development/BSConf/ptr_sc_angular/ptr_media_server/node_modules/mediasoup/node/lib/Transport.js:367:14)
at Room.localRecToFile (/Users/srep/Documents/Development/BSConf/ptr_sc_angular/ptr_media_server/lib/PTRRoom.js:1414:42)