A simple mjpeg streamer for python

I've been working with networking stuffs lately, like XML, parsing and lately streaming. Originally, I wanted to do this for my Android project which is still slightly veiled in secrecy. It will be open sourced completely though, when it matures. So, I wrote this application in an effort to understand the networking behind it and get it to work on Android. Frankly, I am not so good with Java and working with networking stuffs with objects. Everyday I appreciate more of that power though and it's fun to learn new things. I tend to practice with python first and after the proof of concept works there, I do it in Java. It's slightly roundabout way of doing things but it works for me.
What this application does is that it takes snapshots of the jpeg files from the server fast enough for making it seem like it's video.. Well, that's what it is anyways. Let's just say I haven't understood streaming and multi part files properly enough to implement. So, basically, it just sends a GET to the server and pulls the file one by one in a loop. It's really that simple.
The tricky part was to get it to display properly. Tkinter took care of that with Python Image Library. It would be easier if the files aren't jpeg though. That might be for future implementations but for now it's fine for what I'm doing with my Android project.
Anyways, I decided to open source it entirely at

http://code.google.com/p/mjpeg-stream-client/

That might be useful to someone, if nothing but just to learn a new thing or two about python. It' s fairly unpolished even as a basic tool but I hope to improve it to some degree to learn about multimedia streaming and threading concepts in python.

If the application was any bit useful, do drop a comment.

Here are the sources, if you wanted to view them right away

http://code.google.com/p/mjpeg-stream-client/source/browse/trunk/StreamViewer.py

http://code.google.com/p/mjpeg-stream-client/source/browse/trunk/client.py

Here's my picture after I finally got video in Android.. hehe. That program did serve a purpose. Phew!


Cheers!

Comments

Anonymous said…
I was looking for a solution to integrate mjpeg streams from 20+ ip cameras. The application from the supplier sucks and its limited at the no. of simultaneous streams.
Starting from your code, I am working on an application which to display as many streams I want, and to run it on any platform I want. My office runs FreeBSD on workstations, clients offices on windows.
Thank you!
Unknown said…
I need ye simple code for receive image of camera and save it in pc
please help me
just a simple code
nolim said…
Hi, you have some bugs in your code.
The video is blinking because when you are displaying images you need to hold the photoimage in 2 copies.
When you change image the garbage collector starts working and the image disappear and blinks. you can search for it in google.

Also you didn't use mjpeg streaming protocol - there is a simple client code using reactor and python twisted library (called: python-mjpeg-over-http-client).
Sack said…
Nice article
visit
free money
to learn and earn more money.
Anonymous said…
I ADAMS KEVIN, a representative of Aiico Insurance plc, we trust and respect for individual differences in day out a loan. We will provide 2% of the loan's interest rate. If you are interested in this business contact us by e-mail (adams.credi@gmail.com) now transfer their loan documents issued properly. Do you need a loan to set up business or school if you are very welcom to aiico insurance plc.you can also contact us by email(aiicco_insuranceplc@yahoo.com) we first week can request a balance transfer.

व्यक्तिगत व्यवसायका लागि ऋण चाहिन्छ? तपाईं आफ्नो इमेल संपर्क भने उपरोक्त तुरुन्तै आफ्नो ऋण स्थानान्तरण प्रक्रिया गर्न
ठीक।
DFC SEO said…
It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. streamer

Popular posts from this blog

Old Photos

HashMap loop in java

How to make your window Full Screen in gnome?