19

I got this code from here Android and MJPEG to download and stream Mjpeg. It looks and works fine for one video.

However when I try to stream multiple MJpeg videos at the same time and display on the screen the performance slows down significantly.

Would Anyone recommend a better way of going about this for multiple streams or any improvements they can see to implement to improve the performance. As of now it is pretty slow and not acceptable.

Community
  • 1
  • 1
Jared
  • 215
  • 2
  • 3
  • Why do you need multiple streams? Android is a platform which runs on devices with very little memory/cpu-power, so you should use them wisely. – Lukas Knuth Jul 05 '11 at 20:57
  • I agree with you however I need multiple streams to display at one time.. which is why I was asking if anyone had any ideas to help. Would putting each stream on a separate thread to display them be an appropriate way to do so? – Jared Jul 05 '11 at 22:29
  • I'm not sure how you want to display them in separate threads, but loading each in a single thread would be the way to go. Although, I thought you already did that. – Lukas Knuth Jul 06 '11 at 12:30
  • thanks Lukas for your help. TO elaborate on this multi threading streaming. I would have a separate thread to load and update each Mjpeg and one main thread only responsible for drawing. SHould I use handlers to send messages between them so the UI thread knows about the changes? iF you could be so nice as to point me or write up a simple example even using pseudo code is fine. – Jared Jul 06 '11 at 22:48
  • Do you want to display them all at once, too? Or just load multiple streams and display one of them? – Lukas Knuth Jul 07 '11 at 10:42
  • I am loading four streams and displaying all of them at once. right now I am using a surfaceView extending surfaceview.callback and have one main UI thread that right now is responsible for updating then drawing. It updates all of them then draws them. I need to get each one updating and drawing simultaneously. I understand it is looked down upon to have multiple threads drawing to the screen but ultimately if one camera does not load none of them will display until it has finished which is not okay. thanks again for sticking with me here. – Jared Jul 07 '11 at 11:40
  • Simple advice: Don't do it. Create a "showStream"-Activity for loading and displaying one steam. This is way better for the memory/cpu usage and the battery-lifetime. – Lukas Knuth Jul 07 '11 at 11:44
  • Lukas, thank you this is exactly what I am looking for which is advice and guidance. However it is important that I have four streams showing in one activity, it makes or breaks the project. Currently I have four streaming on a 2x2 grid and it is updating and drawing rather fast. but I what I need is to separate them out so that each one is independent of the other. Meaning it doesn't wait for it to load and then draw all four but is loading and drawing them at the same time. Any thoughts on how to do this rather than alternatives to what I need? – Jared Jul 07 '11 at 21:20
  • 2
    @Jared I think you were on to something when you asked about using a separate thread. You should never be doing intensive tasks on your main thread. The main thread should be reserved for UI at all times. While I am not too familiar with motion jpeg, it seems that offloading as much as you can from the main thread each into their own thread would be more appropriate. Take a look at this, which is a modified version using asynctask: http://stackoverflow.com/questions/10550139/android-ics-and-mjpeg-using-asynctask – Badams Mar 08 '13 at 23:30

0 Answers0