I am looking for a way to play video streams with python. I couldn't find anything nice, so I ended up embedding webkit inside a gtk window, and streaming the video in there. it works well, but feels rather hacky to me.
So, my question(s):
Is there any other way to stream video (youtube, justin tv) using python and gtk?
If not, is there a way to make my code run on Windows? Currently it only runs on Linux, I suspect because of a lack of Flash support for GTK on windows. Are there any efforts being made to fix this?
ALright, I've come up with an answer.
Instead of using webkit, which doesn't seem to have flash support on windows, I'm gonna use the chromium embedded framework. It should let me do what I need to do, which is embed flash in a desktop app, whilst also allowing for the option of a html based interface.
It's open source, and supports flash on windows(and linux, I believe).
Take a look at GStreamer (python package)
http://gstreamer.freedesktop.org/
Its an open source multimedia framework.
There are also articles about RTP streaming using GStreamer in below links
http://gstreamer.freedesktop.org/documentation/rtp.html
http://eetimes.com/design/signal-processing-dsp/4004620/DSP-video-processing-via-open-sourceAPIs
There is also a streaming media server built using GStreamer (with LGPL license).
http://www.flumotion.net/
PS: if you are keen on using Adobe AIR to build a cross platform flash player below mentioned link will be at your rescue.
http://www.artima.com/weblogs/viewpost.jsp?thread=208528
I myself haven't built this app, however had researched it earlier to build one. Hope it would be useful.
Related
I have this question in my head for over a year now. And I guess you guys may have the answer.
In some Python GUI app, I need to display a video stream.
I need to record some part of this stream to reread it later.
Moreover, I need to make this python application multi platform (OSX, GNU, Windows)
I am open to many solutions :
Connect the camera to a stream and read the stream with the python app. (RTP + VLC could do the trick)
Use Phonon to read the camera
Create an abstract class to define differents reader and use Quicktime, Win32 or GStreamer in function of the OS.
What is your experience, what would you use to do that ?
I've looked into this periodically as well, and it seems the complexity of the underlying task is just too high to have a simple shortcut abstraction library for your topic question. I would suggest using pyopencv for the specific task you articulate, however. It has a class for webcam input/capture which works across platforms and has a reasonable user-base, in python, posting examples. The latest is 2.3.1 and quite recent. You can get a windows version of it, compiled for you, on the unbelievably helpful site (not mine, just saying):
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Since you ask for experience with a few libraries, I'd say: gstreamer worked for me on linux but was a huge pain to setup on windows and didn't work for me. This was quite some time ago and perhaps it's working better now. vlc.py is a simple library to test and see whether vlc would work for you. It doesn't work on 64 bit windows platforms at the moment; not sure why, but it seems many have reported similar errors, so it depends on how much cross-platform support you need.
Unfortunately, this is not easy to do. I've written most of a program that does video recording/playback on the 3 major desktop OS's. The state of video playback/recording in a "out-of-the-box" way is still unsolved for cross-platform, other than HTML embedding. This has a lot to do with the fact that:
Codecs are proprietary
OS's don't support common codecs
ffmpeg and similar projects have licenses that require you to release your source code if you include them in certain ways
A lot of the video playback players that exist are each rewritten by hand to handle each frame, buffering, streaming, audio sync'ing, and the like.
So you can go with HTML, or you can suffer through the cross-platform issues with the following coding libaries:
Python mplayer
Python vlc
Python opencv
Python pyaudio
Python pyside/pyqt phonon or qtmultimedia
Once you get it working on one development machine, expect it to break when it comes to installation on the end-user machine (distribute via: pyinstaller / appdmg / apt / chocolatey / Inno Setup )
On OSX, brew still has a lot of issues with this, but macports works better (I still had to do a lot of patching)
Linux is by far the easiest.
Windows is in-between the to as far as difficulty
I'd be eager to hear how iOS / Android / Windows RT / Kindle are
The problem is not unique, as even Netflix has yet to have a cross-platform video app: https://www.quora.com/Is-Netflix-building-an-app-for-the-Mac-App-Store?share=1
The docs I've found on NPAPI plugins explain how to write plugins to be loaded by browsers, but how hard is it to write an application that loads existing NPAPI plugins?
(My ultimate goal here is to find a way to use SWF content inside an application written with Python and wxPython in Linux. I've accomplished this on Windows by using the comtypes module to load the ActiveX Flash player. For Linux, I'm thinking that wrapping the Gnash NPAPI plugin in some C/C++ code and making this a Python extension seems like it would work, albeit a bit convoluted...)
Your best bet (assuming basing your hosting code on open source software isn't an issue for you licensing-wise) is probably to look at the implementation of NPAPI host in WebKit, Chromium, and/or Gecko.
The Mozilla documentation for the browser side of NPAPI will help, but there are a lot of little corner cases where plugins expect certain behavior because some early browser did it, and now everyone who wants to support those plugins has to do the same thing even if it's not part of the standard; the only way to learn about those is to look at existing implementation.
I'm planning on using an embedded browser in my pygtk application and I'm debating between gtkmozembed and pywebkitgtk. Is there any compelling difference between the two? Are there any third options that I don't know about?
It should be noted that I won't be using this to access content on the web. I'm mainly using it for UI purposes.
My priorities are:
It needs to be stable.
It needs to be cross-platform.
It should be easy to use.
It should be actively maintained.
It should be extensible.
It should be fast.
gtkmozembed is not available on Windows, although you can use the gecko embedding interface directly. This would require you to write some C++ code.
As far as I know, the gtk webkit port is not available on Windows yet, and still appears to be undergoing a lot of change.
For an example of a cross-platform gecko embedding solution, check out Miro.
Miro is python, and they've written just a couple of C++ classes to embed gecko on Windows, while using gtkmozembed on linux.
if you judge by the web pages then definitely pywebkitgtk
pygtkmoz from this page
"Note: this project is no longer maintained. Please use gnome-python-extras (http://www.pygtk.org) instead. I apologize for any trouble this might cause, but this is better in the long run. Python bindings for GtkEmbedMozilla."
and pywebkitgtk looks like active project changes
I'm looking for different solutions to playing back SWF files on Windows, OSX and Linux using Python. Ideally I'd like to embed the player inside a wxPython frame/window.
One possibility I'm investigating is the Mozilla XPCOM framework since its used by FireFox to load the Flash plugin within the browser.
Have you considered Adobe AIR?
Bruce Eckel said: Try combining the power of Python with the polish of Adobe Flash to create a desktop application.
Though I don't know how to embed a browser within a wxPython window, the following code might serve in a pinch (and will work cross-platform, assuming you're working in Python 2.5 or above):
import webbrowser
webbrowser.open(your_swf_url)
It might be best to delegate this task to the browser anyway.
I'm interested in making desktop widgets, similar to Apple's Dashboard or what Vista has. I'd like to make them cross-platform, if possible. Opera's widgets are cross-platform but require the user to have Opera installed, so that's a big limitation.
I know most widgets are made with HTML/XML, CSS, and Javascript. Is there a way to create them using Python?
Update: I did find a site talking about Pyjamas. Does anyone have experience with it and, if so, what are its capabilities/limitations?
You should take a look at what the guys at Digsby are doing. Basically, they've written a port of WebKit to wxWidgets, and then use WebKit to render the interface, and wxPython for writing the rest of the app. Pretty neat, but very alpha at the moment.
Take a look at gDesklets. AFAIK they're UNIX only, but mabybe porting them to other platforms make more sense than starting from scratch?
They use python to create widgets (desklets).
Screenlets is designed for this task.
The Screenlets project is both a Python framework to simplify writing Cairo-drawn desktop widgets, similar to those found in the "Dashboard" feature of OS:X.
Widgets can be written entirely in Python. A collection of widgets using the framework have already been developed.
It is designed to work with Linux desktop. But it should be easy to port to other platforms, since Cairo is cross-platform, in my opinion.
Disadvantages
It's not updated frequently. The latest version, 0.1.6, was released on 2012-01-27
Its home page has been down for some time. Launchpad works though.
Only Python 2 is supported.
You can check out PyGTK, which will allow you to create desktop widgets, but they won't be managed by OSX's Dashboard. If you'd like to develop an OSX widget, you'll want to stick with HTML/CSS/JavaScript.
Take a look at pyqt4. It has webkit integration. I was looking into this myself but haven't really had time to dig into the API.