Node-red-contrib-ffmpeg-spawn

That is an interesting test. Everybody here always finds new ways to challenge my mind.

At first glance, I would say that it should not be possible for ffmpeg-spawn to output any differently than exec node, but obviously there is some issue here. Internally, I just add a 'data' listener to the pipe, just as exec node does, and simply send the buffer immediately when receiving it.

Assuming, the following to be true:

  • same exact parameters passed to ffmpeg (exec and ffmpeg-spawn)
  • same exact settings on both ui_mp4frag nodes

Then, output should be the same.

But, I can see a couple possibilities for this without digging into the code:

  • If the ip cam source has more than 1 connection, does it struggle to push out video? Some of my cams will actually reboot if I connect a 2nd or 3rd ffmpeg to consume the video.
  • Does the order on ui make a difference? For example, when both ui_mp4frag nodes are initialized by the dashboard in some sort of order, one will undoubtedly connect before the other, each fighting to connect via socket io. Perhaps it is a first come - first serve situation. But, you didn't say if you are using the socket or hls video playback.

2 ways that I can think to test:

  • Compare 2 exec node to each other (without ffmpeg-spawn)
  • Compare 2 ffmpeg-spawn nodes to each other (without exec)

My assumption (hopefully) is that this issue should occur if you run 2 exec nodes to the same cam or 2 ffmpeg-nodes to the same cam.

I might try to test this myself soon. Seems interesting. Perhaps I am handling the buffer data in a bad way.

Edit.

I just ran an experiment and made 4 simultaneous ffmpeg connections to my new amcrest cam(love the cam so far!). 2 used exec, the other 2 ffmpeg-spawn. They were all pretty close to each other, but slightly not in sync (as to be expect). My new cam is awesome and can output segments of 1 second duration, which allows for better relay.

This made me think then, what is your segment duration. Upon looking more closely as the little info beneath the mp4frag node in your gif, i see you have different segment duration output. Must be a different ffmpeg command or perhaps 1 stream is main and the other is sub.