Coder Social home page Coder Social logo

hemisphere-project / hplayer2 Goto Github PK

View Code? Open in Web Editor NEW
28.0 11.0 4.0 104.7 MB

Modular Media Player for Raspberry Pi and more...

License: GNU General Public License v3.0

Python 66.82% Shell 2.72% Lua 0.10% C++ 18.18% HTML 2.97% JavaScript 3.02% CSS 0.27% C 5.91%
raspberry-pi mpv osc mediaplayer http gpio nfc

hplayer2's Introduction

HPlayer2

HPlayer2 is a modular media player designed to allow multiple ways of control, over multiple platform.

It is build in a modular way: you can choose the player engine (mpv, vlc, omxplayer, ...),
i/o interfaces (osc, http, rfid, ble, gpio, ...) and patch everything up.

HPlayer2 is focused on Raspberry Pi, but is based on python code wrapping 3rd parties engines and libraries, so as long as those 3rd parties components are supported on other platform, HPlayer2 should run on it !

HPlayer2 is under development, some features might not be fully available or sometimes broken, feel free to ask for help and open issues, i'll do my best to cover it. Pull requests are also welcomed !

Media engine

Hplayer2 abstracts the concept of player (media list, play, pause, stop, volume, position, ...), and then bind to an existing player engine.

On Raspberry Pi, i only managed to use 3 engines with Hardware acceleration on H.264 decoding:

  • omxplayer: the original HPlayer was based on via ofxOMXPlayer, but using OF on Pi was a bit tricky at the time
  • vlc: works great, but was tricky to compile on RPi when i tried it couple years ago
  • mpv: used to have a great build script, works very well and offers ipc interface to communicate with

The goal of HPlayer2 is to offer the choice between those 3 engines, but for now only mpv is fully supported.

Install

HPlayer2 is a python program, with several "modular" dependencies, depending on which component you will be using.
The core component you need to install is of course the media engine. For now, only mpv is supported, so you should install it, but the mpv package in your distro repository might not be compiled with HW video decoding, so it might be necessary to build it yourself with this specific options enabled.

There is two scripts to help you install everything needed:

scripts/install_dependencies.sh that should cover most of the dependencies installation. This script supports arch and xbian (raspbian/debian/ubuntu)
On Raspberry Pi, i recommand using arch since boot up is faster, but it's up to you ! The script might miss some recent dependencies (i sometime forget to update this script for brand new features).

scripts/install_mpv.sh tries to detect if a pre-compiled version of MPV is available for your platform. If not, it tries to re-compile MPV with HW acceleration for RaspberryPi.

Feel free to dive into both scripts and tweak it for your needs. If you want help make install script more universal, please submit PR !

On your freshly configured Raspberry Pi:

cd ~
git clone https://github.com/Hemisphere-Project/HPlayer2.git
cd HPlayer2/scripts
sudo ./install_dependencies.sh
sudo ./install_mpv.sh
cd ..

You should examine those scripts to understand what they do. You could run each part on your own instead of running the whole script blindly,
it will help in case it is broken (it can be !).

Run

Since HPlayer2 is modular, the concept is to run HPlayer2 against a specific profile. This profile links i/o interfaces to the media engine.
There is a default profile provided, and several example based on projects where i use HPlayer2.

To start, go to HPlayer2 directory, and run ./hplayer2 profile
where profile is the name of a file in the profiles subdirectory (without the .py)

for exemple you can run ./hplayer2 bloffique
which will start HPlayer with the profile located in profiles/bloffique.py

if you omit the profile and simply run ./hplayer2
it will use the default profile located in profiles/default.py

To create a custom profile for your project, you can create a new file like profiles/your-project.py To run it: ./hplayer2 your-project

Patch a profile

The idea here is for you to program you own profile !
(or to use an existing one if it feats your needs..)

Start reading the files in profiles/ to see examples on how profiles are made.
It's very simplified and patching oriented: an interface event can be plugged to a player action and vice-versa.

The best starting point is to read the default profile in profiles/default.py

The idea in a profile is:

  • create a player
  • attach interfaces modules (OSC, HTTP, RFID, GPIO, ...)
  • patch events from interfaces to action on the player (NB: some events are already patched automatically)
  • run

Interfaces

A more complete documentation regarding the capabilities and the use of the different interface modules will be provided in the future (PR and help are welcome!).
Interfaces are available without the need of explicit inclusion, from directory core/interfaces/

Please check the profiles examples to see how to use those interfaces.

Available interfaces:

  • GPIO: allows patching RPi gpio event to player action
  • OSC: patching OSC message to player actions to control it from TouchOSC / MaxMSP / etc...
  • HTTP: bootstrap a basic HTTP server to enable network basic API
  • HTTP2: a nice web interface (responsive & websocket enabled) to setup an control HPlayer2
  • Keyboard: usb keyboard, numpad or infrared remotes like this one
  • Keypad: interface LCD+Keypad RPi shield like this one
  • NFC: interface RFID/NFC tag reader based on PN532 like this one

CREDITS

HPlayer2 is developed by Thomas BOHL for Hemisphere and KXKM

HPlayer2 is build on top of MPV player, liblo, Adafruit libs, ZeroMQ and more.. thanks to all those open developers !

hplayer2's People

Contributors

maigre 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hplayer2's Issues

MPV build issue on raspberry 3

After a long long time...

../player/command.c: In function 'mp_property_vo_passes':
../player/command.c:2964:12: warning: missing braces around initializer [-Wmissing-braces]
struct voctrl_performance_data data = {0};
^
../player/command.c:2964:12: warning: (near initialization for 'data.fresh') [-Wmissing-braces]

Waf: Leaving directory `/home/pi/HPlayer2/mpv-build/mpv/build'
Build failed
-> task in 'objects' failed with exit status 1 (run with -v to display more information)

any suggestions?
Paolo

Install script exits at line 43

Very cool project!!!

(scripts/build_debian.sh)
...
cd "$(dirname "$0")"
./select_prebuild
if [ $? -eq 0 ]
then
echo ""
echo "Building MPV for your system..."
else
exit
fi
--------------------------------------->>> Script exits here
so I manually executed the following lines in a terminal.
...

RPi MMAL

if [[ $(uname -m) = armv* ]]; then
echo --enable-mmal > ffmpeg_options
fi

Build

./rebuild -j4
--------------------------------------->>> my PI3 stopped due to overheating. Without the -j4 option it worked
cd ..

Copy bin

mkdir -p bin
cp mpv-build/mpv/build/mpv bin/mpv

Clean

rm -fR mpv-build

using other player possibilities

Would it be possible to use c2play with hplayer2?
could i do/make this my self if someone points met in the right direction?

I'm trying to run this on an odroid C4 but mpv is laggy because there is no hardware acceleration.
the recommend players for odroid are c2play and kplayer

Is it starting or bugging ?

Hello this is what I get when I start HPlayer2 via SSH (RPi3, Raspbian stretch, Openframeworks installed) :

`HPlayer2: loading default profile...

HPlayer2 basepath: /home/mgr/Videos
HPlayer2 settings: /home/mgr/hplayer2.cfg
HPlayer2 IP for eth0 is 192.168.1.24
HPlayer2 started.. Welcome !

OSC -myPlayer- sending to 127.0.0.1 on port 4000
OSC -myPlayer- receiving on port 4000
HTTP -myPlayer- listening on port 8080
MPV -myPlayer- connected to player backend
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/HPlayer2/core/players/mpv.py", line 119, in _mpv_communicate
if 'name' in mpvsays:
UnboundLocalError: local variable 'mpvsays' referenced before assignment`

I don't even know if i works as nothing appear on the HDMI screen and I found no documentation to know what to go from there.

build.sh does not exist

Documentation is out dated. Mentioned to run ./build.sh but there is no such things. Instead, it shows the different scripts.

Expected: documentations should reflect the list of files that should be executed and the order in which they should be done.

ModuleNotFoundError: No module named 'zyre'

Hi There

Running on a RPI3 and Raspbian

I have managed to get through individually installing a number of the modules that have thrown up as missing but have got to "zyre" and not sure what module this is based around as simply doing a pip install of it claims to not find it.

Any help much appreciated!

How do I start HPlayer2 with media?

Hi Thomas, I was able to successfully build HPlayer2.

How do I start playing media? I tried unsuccessfully using the HPlayer example as follows:

# Download Test Media
mkdir ~/media && cd ~/media
wget https://samplemedia.linaro.org/H264/big_buck_bunny_480p_H264_AAC_25fps_1800K.MP4 -O bbb-sample.mp4

# Start hplayer2 
cd ~/HPlayer2
./hplayer2 --start 1

I get this error (leading me to believe HPlayer2 is not started the same way HPlayer is) ...

Player2: loading --start profile...

Traceback (most recent call last):
  File "./hplayer2", line 16, in <module>
    __import__("profiles."+profile)
ImportError: No module named --start

I tried updating profiles/default.py by setting the base path to the directory that contains an .mp4 video file (/home/media/), then I compiled profiles/default.py to update profiles/default.pyc ...

from core.engine import hplayer

# PLAYER
player = hplayer.addplayer('mpv', 'myPlayer')

# Interfaces
player.addInterface('osc', [4000, 4001])
player.addInterface('http', [8080])

# RUN
hplayer.setBasePath("/home/media/")
hplayer.run()

Then, when I start the player as follow, this is what I see in the remote console ...

pi:~/HPlayer2 $ ./hplayer2
HPlayer2: loading default profile...

MPV myPlayer retying socket..
MPV myPlayer retying socket..
MPV myPlayer retying socket..
MPV myPlayer connected to MPV at /tmp/hplayer-myPlayer
OSC MPV myPlayer binded to OSC port 4000
HTTP MPV myPlayer starting HTTP server on port 8080

HPlayer2 started. Welcome !

HPlayer2 Device IP on eth0  is 127.0.0.1
HPlayer2 Device IP on wlan0 is 10.2.10.120

... but that is all I see. I don't see a video playing on the monitor that is connected to the RasPi.

So, I'm not sure how to view the running video, or if it is playing at all.
I am currently running Jessie Lite on my RasPi.
Am I even able to display the video when running Jessie Lite, without the full Raspbian GUI?

As a last attempt (I'm just guessing at this point), I browse to 10.2.10.120:8080, but I get 'connection refused`.

HTTP interface exit

HTTP interface won't exit properly...
Ctrl-c lock up, need Ctrl-z which let the subprocess running and keeps 8037/tcp busy..

AttributeError: 'MpvPlayer' object has no attribute 'addInterface'

Hello,

I might be flogging a dead horse of a project here but every time I try to run the default config on Raspbian I get

AttributeError: 'MpvPlayer' object has no attribute 'addInterface'

I've confirmed all the dependencies are there and I believe I've installed MpvPlayer

Loop default status

On start, LOOP status is true, but internal seems false:
need to match one to the other

RPi fade overlay broken

Hi Thomas,

Thanks for your email. Sorry, it was not crystal clear.

I can play fine my videos, both Jelly Fish you provide and the Bunny extract. Using my own profile or your Looper. OSC is working fine.

That said, I did edit hpod profile to comment the lines 18 and 19. The videos appears, both bunny and jellyfish.
When I un-comment the lines 18 and 19 and play the video, nothing appears, but my terminal says that MPV is playing the video. I can see the fade fading in and out (black to white, white to black).

Maybe something about the Alpha ?

Thank !

Originally posted by @bartloeff in #5 (comment)

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.