samirkumardas / jmuxer

jMuxer - a simple javascript mp4 muxer that works in both browser and node environment.
Other
559 stars 114 forks source link

Latency improved by setting duration=0 #99

Closed rhysmorgan134 closed 2 years ago

rhysmorgan134 commented 2 years ago

Hi,

First, thanks for this tool! I hoping it can greatly improve my app I am working on. I am receiving raw h264 from a device, and I am passing it via websocket to a react app that is running jmuxer. I can set the fps of the device, however, as it is a live stream from the device, the frame rate changes around, if I set it to use the matching frame rate, I get buffering of half a second or so every couple of seconds.

I have tried implementing duration logic, however after 30 seconds or so a lag is introduced. Through pure fluke, I managed to set duration to 0, and it seems to be behaving perfectly. Is expected at all? Or have I just got lucky and it is using a default duration, or a default fps?

samirkumardas commented 2 years ago

Did you mean the property flushingTime? It can create a lag sometimes for a large value. It should be set to a little value for live streaming e.g. 100 or even 0. Setting it to 0 will add the buffer to the player without a delay.

rhysmorgan134 commented 2 years ago

Apologies, I meant the duration on the jmuxer feed object.

samirkumardas commented 2 years ago

If set duration to 0, jMuxer plays the video at default fps 30. It is totally coincidental that it got matched your actual frame rate.

rhysmorgan134 commented 2 years ago

You are correct, for some reason, running the app on mac was causing the erratic frame rate, running on a pi I get the solid framerate that is requested from the device. I can now set to what ever frame rate and it all stays in sync. Thanks for the info, and a huge thanks for the package! Thanks to this we have a useable open source (and very rough!) apple carplay implementation!