Skip to content

sherwinterunez/python-omxplayer-wrapper

 
 

Repository files navigation

Python OMXPlayer wrapper

PyPI Version PyPI Python versions PyPI License Documentation Status Build Status Code Coverage

Control OMXPlayer from Python on the Raspberry Pi.

Install

Make sure dbus is installed:

$ sudo apt-get install python-dbus

For someone who just wants to use the package:

$ python setup.py install

If you're feeling helpful, and decide to help develop the package:

$ python setup.py develop

There's also an Ansible playbook in devenv which will set up a raspberry pi with omxplayer-wrapper in develop mode (located at /usr/src/omxplayer-wrapper) which can be used by running ./devenv/deploy.sh

This will install via symlinks so that you can continue to work on it locally but import it from other python packages

Hello world

from omxplayer import OMXPlayer
from time import sleep

file_path_or_url = 'path/to/file.mp4'

# This will start an `omxplayer` process, this might
# fail the first time you run it, currently in the
# process of fixing this though.
player = OMXPlayer(file_path_or_url)

# The player will initially be paused

player.play()
sleep(5)
player.pause()

# Kill the `omxplayer` process gracefully.
player.quit()

Playing a stream from a URL (e.g. a live RTMP or RTSP stream) works the same as with a file path, just change the "source" string parameter given to OMXPlayer to a URL instead of a file path.

from omxplayer import OMXPlayer
from time import sleep

file_path_or_url = 'rtmp://192.168.0.1/live/test'

player = OMXPlayer(file_path_or_url)

# The player will initially be paused

player.play()
sleep(5)
player.pause()

# Kill the `omxplayer` process gracefully.
player.quit()

Usage patterns

Choppy streaming over a slow connection? If you're connection isn't good enough to support streaming, checkout urllib2 to download the file locally prior to playing.

Docs

You can read the docs here: python-omxplayer-wrapper.rtfd.org

About

A wrapper written in python for OMXPlayer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.7%
  • Other 1.3%