Intelligence and simplicity behind MJPEG video streaming

Today we are speaking with Vadim Voropai, Android Team Lead at Techspire Ltd. Vadim will tell us about MJPEG solution he made together with his colleague, Borisenko Roman.

– Hello, Vadim! Firstly, of course, we are interested in how did the idea come about?

The idea first appeared when our client sent his documentation on the project. The team had to work with mjpeg library format. We’ve searched for existing projects about this specific technology, googled similar projects, and our search showed that there aren’t any solutions at all.

The project was also peculiar – we needed to work a lot with Android runtime and do everything very quickly. Not all of the devices could cope with the load, sometimes there was a freeze up for about a minute or more. We needed to find a completely new solution. Preferably, without any additional modifications.

And, of course, we found it! The solution was found with the help of web technology. As a result, we’ve made a beta version, which works reliably and doesn’t crash at all.

– Can you tell us about the solution?

The library is based on a WebView component. It is a standard Android component, which can view web pages. All Video stream is turned into HTML code – thus, we receive an empty web page with image on it

– Describe the technology process.

There are a base WebView component and an address bar with IP camera, slot, and credentials (if required).This address bar is wrapped into simple HTML tags. Afterward, we put it into WebView. And it is a moment where the magic begins.The decision is simple and elegant, but we haven’t seen anything like that before.

– Okay, is there any additional functionality?

Right now we have only the necessary functionality – picture centering, that means that you can place a picture on the screen anywhere you like. However, WebView standards restrict us in our actions – WebView should be “much parent”, or the picture becomes distorted. Also, WebView doesn’t work correctly, if it doesn’t occupy the entire space.
Instead of editing WebView, we edit the content inside it to let user drag and drop picture where he needs. That’s why to create a page with a hundred mjpeg cameras on it and view them with scrolling isn’t a big deal.

– What are you working on right now, guys?

Right now we are working on mjpeg video streaming. It is like we have made an IP camera out of a smartphone, which can broadcast online, process the information and, in the end, we have a ready mjpeg stream, which is readable by any other device.

– How do you see the practical application of the library?

I truly believe, that our solution will replace all of the existing WebView mjpeg libraries because it exceeds them in stability and work speed.

Also, we can turn on customizable preloaders, spinners, bars and other settings. Every person can tweak library according to personal preferences

– Why did you decide to put the library in the open access instead of using it for your own project?

Because we aren’t greedy. Our team believes, that if you do good, it will come back to you. The idea is great and we don’t mind sharing it. You can view library on GitHub. Also, we are always glad to any feedback and suggestions.

Thanks to Vadim for the interview. Meanwhile, don’t hesitate to ask questions in comments or jump and look at our other projects.