Giter Club home page Giter Club logo

pyomxsync's Introduction

omxsync

python module to sync playback of several omxplayer instances

Build Status Code Climate

Summary

A tiny python module that syncs omxplayers over the network using sockets and a master/slave configuration. The syncing logic was initialy inspired by the omxplayer-sync implementation, but designed to be easily implementable in your python project (and not as a stand-alone runnable script). It uses python-omxplayer-wrapper to interface with the OMXPlayer process.

Install

First make sure willprice's python-omxplayer-wrapper is installed. Go to https://github.com/willprice/python-omxplayer-wrapper for instructions.

On the slave you might need to change your raspi's configuration to allow incoming broadcast messages (syncing happens over a broadcast channel by default):

echo 0 | sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Finally install the omxsync package

pip install omxsync

Usage - master

from omxplayer import OMXPlayer
from omxsync import Broadcaster

player = OMXPlayer('path/to/video.mp4')
broadcaster = Broadcaster(player, {'verbose': True})
broadcaster.setup()
player.play()

while player.playback_status() != "Stopped":
	broadcaster.update()

Usage - slave

from omxplayer import OMXPlayer
from omxsync import Receiver

player = OMXPlayer('path/to/video.mp4')
receiver = Receiver(player, {'verbose': True})
receiver.setup()
player.play()

while player.playback_status() != "Stopped":
	receiver.update()

Advanced Options

Use a custom network port (the broadcaster and receiver must use the same port)

receiver = Receiver(player, {'port': 3001}) # default: 1666
broadcaster = Broadcaster(player, {'port': 3001}) # default: 1666

Use specific remote IP-adresses (instead of broadcasting).

Using '0.0.0.0' for the receiver will accept both broadcasted data and data send specifically to the receiver. Using '255.255.255.255' on the broadcaster will broadcast the data Alternatively you could send to a specific machine by using the slave's IP address

receiver = Receiver(player, {'host': '127.0.0.1'}) # default: '0.0.0.0'
broadcaster = Broadcaster(player, {'port': '192.168.2.5'}) # default: '255.255.255.255'

Specify a custom broadcast interval (in seconds)

broadcaster = Broadcaster(player, {'interval': '5.0'}) # default: 1.0

Custom slave-syncing parameters

Tolerance is the maximum amount of time that the slave is allowed to be ahead of behind on the master before syncing measures will be taken (specified in seconds).

receiver = Receiver(player, {'tolerance': 0.1}) # default: 0.05

Grace time is the amount of time after a sync-action (pause or jump) that the slave will wait before performing any new syncing actions (specified in seconds).

receiver = Receiver(player, {'grace_time': 1.0}) # default: 3.0

Jump ahead time is the amount of time that the slave will jump AHEAD of the master's playback position when slacking behind (or too far ahead). This gives the slave some time to process the (key-)frames for the new position before having to resume playback. (Specifed in seconds.)

receiver = Receiver(player, {'jump_ahead': 2.5}) # default: 3.0

pyomxsync's People

Contributors

markkorput avatar

Watchers

 avatar

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.