Coder Social home page Coder Social logo

pyomxplayer's Introduction

pyomxplayer

Python wrapper module around OMXPlayer for the Raspberry Pi.

Unlike other implementations, this module does not rely on any external scripts and FIFOs, but uses the pexpect module for communication with the OMXPlayer process.

CPU overhead is rather low (~3% for the Python process on my development RPi) and the object-oriented design makes it easy to re-use in other projects.

Installation:

git clone https://github.com/jbaiter/pyomxplayer.git
python pyomxplayer/setup.py install

Example:

>>> from pyomxplayer import OMXPlayer
>>> from pprint import pprint
>>> omx = OMXPlayer('/tmp/video.mp4')
>>> pprint(omx.__dict__)
{'_position_thread': <Thread(Thread-5, started 1089234032)>,
'_process': <pexpect.spawn object at 0x1a435d0>,
'audio': {'bps': 16,
        'channels': 2,
        'decoder': 'mp3',
        'rate': 48000,
        'streams': 1},
'chapters': 0,
'current_audio_stream': 1,
'current_volume': 0.0,
'paused': True,
'position': 0.0,
'subtitles': 0,
'subtitles_visible': False,
'video': {'decoder': 'omx-mpeg4',
        'dimensions': (640, 272),
        'fps': 23.976025,
        'profile': 15,
        'streams': 1}}
>>> omx.toggle_pause()
>>> omx.position
9.43
>>> omx.stop()

pyomxplayer's People

Contributors

jbaiter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyomxplayer's Issues

error when execute my python file

this is error when i write in console: python videoplayer.py

File "videoplayer.py", line 3, in
omx = OMXPlayer('/home/pi/Desktop/condivisa/basagliasx/menu.mp4')
File "/home/pi/Desktop/condivisa/pyomxplayer-2/pyomxplayer.py", line 35, in init
video_props = self._VIDEOPROP_REXP.match(self._process.readline()).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Can't install on Raspbian nor Occidentalis

Hi, I've been trying to install it on the latest Raspbian and Occidentalis, but so far no such luck.

I installed the pexpect module and followed pyomxplayer's instructions:

pi@raspberrypi ~ $ sudo git clone https://github.com/jbaiter/pyomxplayer.git
Cloning into 'pyomxplayer'...
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 8 (delta 1), reused 8 (delta 1)
Unpacking objects: 100% (8/8), done.

pi@raspberrypi ~$ sudo python pyomxplayer/setup.py install
running install
running build
running build_py
package init file 'init.py' not found (or not a regular file)
package init file 'init.py' not found (or not a regular file)
running install_lib
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/pyomxplayer-0.0.0.egg-info

pi@raspberrypi ~ $ python
Python 2.7.3rc2 (default, May 6 2012, 20:02:25)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from pyomxplayer import OMXPlayer
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named pyomxplayer

What am I missing? Cheers

Add build automation

Once a commit is pushed to master a tool like travis could be used to run tests and push the code to PyPi to make it easier for users to install. I'd be happy to set this up, but I'd need commit access to this repository.

Odd behavior with version fix

Can anyone give me any tips on how to fix this please? I'm replacing some existing code that used gtkmozembed with pyomxplayer as it now needs to play videos instead of show webpages. The screen is divided up using gtk. I'm a little new to python still so bear with me :)

The code originally initialised gtkmozembed with:

 self.moz=gtkmozembed()

Then loaded the URL further down the code. However if I try this with pyomxplayer, e.g.:

self.omx=OMXPlayer()

I get the .groups() error that I fixed by following the suggestion here: #3

I can get it to work by shoving all the arguments and file name into the initialization string, but I can't figure out how to then refresh it with a new file when playback has finished, if that makes sense?

Just looking for any guidance on usage etc - if anyone's got an example script which plays multiple videos in succession by passing filenames to it, that would be amazing :)

how to get the current position

Hi! I try to get the current position like this:
print omx._get_position()
but nothing appears
could you help me on that? thanks in advance

Error - 'NoneType' object has no attribute 'groups'

Hello,

I got below error messages when I was running python in terminal. It is similar to #issue 1.

from pyomxplayer import OMXPlayer
from pprint import pprint
omx = OMXPlayer('/home/pi/1.mp3')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/pyomxplayer.py", line 32, in init
file_props = self._FILEPROP_REXP.match(self._process.readline()).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Hope you guys fix this issue. Thanks.

Multiple instances

Is it possible to run multiple instances of the OMXPlayer stating some kind of id or similar? I would like to have 2 instances I can switch between to achive video playback without any buffering.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.