What is the best way to manage multiplatform video stream using Python? - python

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

Related

Desktop Overlay for Windows (Python, Tkinter)

I recently stumbled upon an SO question that pointed at using WinRT (discontinued in Python 3.10), that helps handle Windows Runtime APIs. I wanted to use it to develop a basic desktop overlay that shows a list of currently running audio sources (primarily, Spotify). I did accomplish everything else, concering the UI and such, using tkinter.
The main problem is that the support for Python WinRT discontinued for the 3.10 version, (and onwards), and I can not find libraries that might substitute it. The main solutions I find include downgrading to Python 3.9 (or, using a venv, which sounds better), or just using a community fork (PyWinrt), but I'm not really putting these hacks or workarounds at a priority, I might be willing to opt for these if there is no other possible solution.
Is it still possible to develop such an overlay using only Python? Since I'm using Tkinter, all i would need is an image of the current playing track, the application that is running it, progress in the audio (in ms or s), and the name of the track. Keeping it simple, I'm trying to avoid audio control, such as skipping the track, or changing the relative timestamp.
I did try using the Spotify WebAPI to specifically grab info related to the track currently playing, but the work involved with refresh oauth tokens, and creating logins for just looking at the track seems a bit much work, since I believe it would be easier done natively; plus, what I'm trying to aim for, is a general purpose audio source info, rather than just Spotify.
Here, is a picture of Windows' Gamebar, that shows what I'm trying to achieve:
GamebarOverlay.

Equivalent of pywinauto library for debian

I'm looking for an equivalent Python library that will work when I run my script on Raspberry Pi. I'm under the impression that pywinauto only works on windows machine.
I want to control some inputs to a GUI launched by my script, using my script. Apart from pywinauto I have no idea how to do this. I thought about using command line to control the software directly, but if there is a simpler way I would really appreciate knowing about it.
Thanks for your time.
ATSPI is an Linux accessibility technology to obtain GUI text/rectangle properties programmatically. See how to find and run ATSPI registry daemon and how to enable ATSPI for the most popular types of GUI apps. Usually it's
$ /usr/libexec/at-spi-registryd &
There is a Python bindings for ATSPI. See this answer for details:
How to install pyatspi?
The pyatspi package has too many dependencies like pygobject etc. It also requires some compilation during installation steps. We think this is not user friendly so we decided to use libatspi.so directly (without any dependencies). This work status can be tracked here: https://github.com/pywinauto/pywinauto/pull/449
There is no exact deadline for pywinauto 0.7.0 with this feature (it's a hobby project), but I would say this summer sounds realistic.

Python Linux Joystick support?

How can I use an analog joystick in Python on Linux? I come from a C++ background, where I used joystick.h to read events from /dev/input/js[x]. Is there a python wrapper around this I can use, perhaps? I don't really want to have to use a huge library like pyGame or SDL?
This gist worked for me on Ubuntu 15.04 without modification.
There is evdev, It's only for Linux, and it seems to be able to do much more than just handling joystick. I've never tried it, though.
I spent some time looking for a library to only read joystick in a cross-platform way, but didn't find any, and I've ended up with pygame (only initializing joystick and event modules) in my projects.
Now (2016+) there's a new sufficiently multiplatform Python module called "inputs" that you can find on GitHub or install from Pipy
It can read joysticks, controllers, keyboards and mices and seems to offer a good support for all their features, including vibration where available.

Embeding flash in WebKit for pygtk on windows

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.

Playing MP3 files with Python

I'm trying to write my own media player (like Foobar), and I'm having trouble tracking down a Python library that'll play MP3s. I know Pymedia does mp3s, but it looks outdated - the latest installer is for Python version 2.4, and I'm using 2.6. I've never had much success with Pygame, and Pyglet doesn't look like it has too much in the way of documentation. Are there any other alternatives?
There is http://pyglet.org/ and also have you tried http://code.google.com/p/mp3play/? It's also available from PyPi (http://pypi.python.org/pypi/mp3play/) However, I think mp3play is Win32 only for now.
Looking at the updates, there were commits within last couple of months.
I've been using PyMedia in Python 2.6.5 on Windows successfully. Caveats: the documentation is bad and wrong -- many of the tutorials have glaring errors or otherwise don't work -- so I had to do some experimentation and Googling to get my code to work right. Also for whatever reason the maintainers seem to have stopped updating the project site 4 years ago, though they seem to be actively doing something.
I found installers here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
The semi-active forum linked from their website includes some code maintainers who are semi-helpful. I'm jboyd99 if anyone is looking for tips.
For reasons that are beyond me the focus is on car audio systems, despite the fact that it is a fairly fully featured library that does some things no other free Python library does, like read MP3s into raw PCM data. The library has some flaws -- I'll probably use PyAudio or PyAudiere for actual playback for better control of synchrony issues.
Maybe it'd be simpler to write that part of your application in Python 2.4 as a separate "backend". This way you could use PyMedia (http://pymedia.org/) (as you mentioned) for the actual playback. It'd allow you to write your GUI in another Python version (like 2.6), which would also mean more decoupling of program components and parallelism (smoother GUI).
If you target only the Windows platform, then using Media Player via COM might help:
http://www.daniweb.com/code/snippet216465.html

Categories

Resources