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?