As far as you mangle the RTP packet so its fields (ssrc, payloadType, etc) matches those you signaled in the Producer rtpParameters… yes. But you are not doing that.
Or you could call directTranspprt.produce() with the consumer.rtpParameters. But for that you should create the Consumer first.
Your code does not make sense because you are creating a Producer, you don’t send any RTP to it and then you are creating a Consumer for it which will not receive any “rtp” event because there is no RTP at all
My goal is to transcode rtp packages with different software and include them in mediasoup again.
mediasoup directTransport.consume -> socket -> c++ -> transcode -> socket -> mediasoup producer -> mediasoup consumers -> client
For transcoding you need to implement a RTP jitter buffer to order packets (that may arrive out of order) and wait for complete video frames in order. Easier if just for audio.
Usually this kind of thing is done with a PlainTransport, not a DirectTransport. It looks like:
plainTransport.consume → RTP → Transcoder (ffmpeg,gsteamer,c++ thing,etc) → RTP → plainTransport.produce
This way, your javascript never has to deal with any audo/video packets directly.