I’m experiencing unusually high videos stream packet loss: pretty much every single packet is lost save for a few small chunks spread far apart. Here are some graphs from chrome://webrtc-internals:
I’m not sure what the source of the problem is exactly. These options seem to work perfectly fine when simply outputing to a file. Is there some detail I’m missing?
We cannot provide support about proper ffmpeg usage. Said that, you are just looking at ffmpeg and receiver browser side.
mediasoup provides lot of stats in server side you can check. For instance producer.getStats() which will tell you how good the RTP transmission from ffmpeg to mediasoup is.
BTW fmpeg has nice problems sending RTP over UDP. I’ve seen that it looses LOT of RTP packets due to its own buffers. I hope ffmpeg’s output tells you something, but right now your topic has zero info about mediasoup itself.
Yeah, I wasn’t too sure exactly what kind of information to post here. If you want some other information I’ll post it here. I pretty much followed the guide to the T, except for the ffmpeg stuff, which is a little different. But looks like producer.getStats() is a good starting point to troubleshoot this issue. I’ll let you know if I find something, thanks
Check the packetLost in producer.getStats() and take into account that, if any packet is lost between ffmpeg and mediasoup, mediasouop will send a NACK to ffmpeg (if enabled in the producer rtpParameters), however ffmpeg does NOT support NACK as far as I know, so ti won’t retransmit the packet, producing the packet lost in the receiving browser and frozen video until ffmpeg sends a video key frame (which may happen every 2 seconds or more, depending on ffmpeg command line settings).
I would use gstreamer instead. AFAIK it properly supports NACK and so on.
Actually I think I accidentally forgot to include the -tune zerolatency option I’m using in my post, which I have now edited to add. It essentially tells x264 to make every frame a keyframe to avoid the need to retransmit, since the very next frame would make up for the lost frames, so I actually don’t mind a packet being lost even now and then. What I don’t understand is if you see the graph, pretty much >90% of the packets are being dropped, which baffles me. Of course that is in the browser after going through mediasoup. Once I test with producer.getStats() I’ll let you know the details.
Hey @ibc, thanks a lot for showing me the light! I have ditched ffmpeg in favour of gstreamer (which is wayy better with support for NACK), and after some tweaking around using output from producer.getStats() like you suggested, things are looking pretty awesome, I have ~40 clients streaming simultaneously with hardly any dropped packets. And of course, thanks for this amazing piece of software!
BTW this is a common question. It would be great if you could contribute to mediasoup by writing your gstreamer usage as we do with ffmpeg here. You may directly create a PR in the mediasoup-website project by adding a new section " Example: Inject Audio and Video using GStreamer".
For me the producer stats (ffmpeg => mediasoup) is fine but there are lots of packet loss in the consumer stats. This is while consuming webcam or shared screen is fine too. What do you think?
What I saw in the past is that ffmpeg does not loose RTP packets but video frames while encoding or buffering, so at RTP level everything seems to be good (no packet lost in the Producer) but those continuous RTP packets do not contain continuous video frames. I cannot help much more on the ffmpeg side.
Hey @mkh so sorry, the command is quite hairy and would need quite a bit of explanation so people understand what’s going on, so I didn’t yet get the chance to create a PR that I was happy with. But here’s the gist, I set up the server like so:
However I could not get it to work with H264 since mediasoup complains about unsupported codec while I’m passing H264 as mediaCodecs argument when creating the router:
No magic response for that. H264 profile level matching is SUPER hard. In mediasoup and mediasoup-client we use this lib to properly match profile-level-id values.