shinyoshiaki / werift-webrtc

WebRTC Implementation for TypeScript (Node.js), includes ICE/DTLS/SCTP/RTP/SRTP/WEBM/MP4
MIT License
476 stars 32 forks source link

Support fragmentation packets for MediaRecorder #149

Open potmat opened 2 years ago

potmat commented 2 years ago

If trying to use MediaRecorder with an H264 stream which contains fragmentation packets, attempts to record will error out with:

    at Function.concat (node:buffer:544:19)
    at basicCodecParser (/Users/me/Source/webrtctest/node_modules/werift/lib/rtp/src/processor/webm.js:119:33)
    at WebmOutput.dePacketizeRtpPackets (/Users/me/Source/webrtctest/node_modules/werift/lib/rtp/src/processor/webm.js:130:24)
    at WebmOutput.onRtpPackets (/Users/me/Source/webrtctest/node_modules/werift/lib/rtp/src/processor/webm.js:93:43)
    at Object.promise (/Users/me/Source/webrtctest/node_modules/werift/lib/rtp/src/processor/webm.js:85:36)
    at PromiseQueue.run (/Users/me/Source/webrtctest/node_modules/werift/lib/common/src/promise.js:18:24)
    at /Users/me/Source/webrtctest/node_modules/werift/lib/common/src/promise.js:11:22
    at new Promise (<anonymous>)
    at PromiseQueue.push (/Users/me/Source/webrtctest/node_modules/werift/lib/common/src/promise.js:8:34)
    at WebmOutput.pushRtpPackets (/Users/me/Source/webrtctest/node_modules/werift/lib/rtp/src/processor/webm.js:85:20)

Seems to be because here https://github.com/shinyoshiaki/werift-webrtc/blob/develop/packages/rtp/src/codec/h264.ts#L77 if the unit type is 28/29 it will return a packet with an undefined payload.

shinyoshiaki commented 2 years ago

Since werift does not support fragmentation mode at the moment, so I think change packetization-mode=1 to packetization-mode=0 in RTCRtpCodecParameters.parameters to make it work.

potmat commented 2 years ago

I found a workaround such that I don't need to use MediaRecorder.

kolserdav commented 1 year ago

I found a workaround such that I don't need to use MediaRecorder.

Can you please give a hint how you do it?