Streaming using JpegVideoSource for Playback is very slow. Any way to improve the speed?

We are trying to get a playback Jpeg video source (Component Integration), but it’s taking more time to get the image from the device.

C# Console application helps to get the stream and pass that to the browser via a WebSocket connection.

Queue jpegQueue = new Queue();

JPEGData jData = _jpegVideoSource.Get(_currentShownTime) as JPEGData;

while (!_stop)

{

jData = _jpegVideoSource.GetNext() as JPEGData;

if (jpegQueue != null && jData != null)

    {

            jpegQueue.Enqueue(jData);

    }

}

And above jpegQueue is sent to browsers using WebSocket in a separate thread. In the above code, it’s taking more time to get the image from the source.

Every second has 25 images, and retrieving 25 images is taking more than 1 second. In effect, streaming is very slow. Any way to improve this?

Also, we tried to set the following properties to improve the retrieval speed.

JPEGData jData = _jpegVideoSource.Get(_currentShownTime) as JPEGData;

if (jData.Height > 1000)

{

      \_jpegVideoSource.Width = (int)(jData.Width / 3.5);

      \_jpegVideoSource.Height = (int)(jData.Height / 3.5);

}

else if (jData.Height >= 540)

{

      \_jpegVideoSource.Width = (int)(jData.Width / 2.5);

      \_jpegVideoSource.Height = (int)(jData.Height / 2.5);

}

_jpegVideoSource.AllowUpscaling = false;

_jpegVideoSource.Compression = 10;

_jpegVideoSource.Init();

while (!_stop)

{

jData = _jpegVideoSource.GetNext() as JPEGData;

if (jpegQueue != null && jData != null)

    {

            jpegQueue.Enqueue(jData);

    }

}

But it did not help as expected. Still, it is slower and unable to play the stream in the browser. Are we missing anything here? Is there a way to inform the device to send fewer frames per second for playback?

Is there any other option available to show playback streams on our custom website?

Using JpegVideoSource the video data is retrieved and transcoded client side, the stronger the client PC the faster it can decode and re-encode in Jpeg. The JpegVideoSource can utilize hardware acceleration so adding an appropriate graphics card to the client PC will greatly speed up the transcoding.

Two alternative approaches:

When you use JPEGVideoSource and then send the Jpegs to be rendered in some other program the Jpegs the speed is also very dependent on this other rendering and presentation, even if you can get the Jpegs fast enough it might break when doing this rendering. In comparison if you use the ImageViewerControl, the control does the decoding and the rendering, and this happens all in the GPU (if the graphics card is one that Milestone support in hardware acceleration).

Another alternative is the use of Mobile Server. Using this the Mobile Server will provide the JPEG already transcoded and in the appropriate size. You will have to add a server hardware but the solution will work with very thin client.

-

About hardware acceleration (used in the same way in MIP SDK as in Smart Client): https://doc.milestonesys.com/latest/en-US/standard_features/sf_sc/sf_hardwareaccelerateddecoding/sc_enablinghardwareaccel.htm?TocPath=XProtect%20Smart%20Client|XProtect%20Smart%20Client%20user%20manual|Optimization|_____1