Closed balamsoto closed 7 years ago
How long are the videos you are loading in seconds?
Your program seems reasonable and is something that should be supported. I will have a look at replicated this with keypresses instead of GPIO and see whether I can reproduce the issue.
I have already done that (changing the GPIO by keyboardkeys):
Upon Player::load the function Player::_setup_dbus_connection is called to make a new OMXPlayer connection. When the connection to OMXPlayer fails, a self.tries is incremented (up to a max of 50). Now when you do a second/third/etc. time load, the incrementation continues from where the previous load made the connection. So after an amount of loads (which varies depending on how fast the OMXPlayer connection is made) you run into the max value, resulting in the error.
The solution could be to place a self.tries = 0
before the while self.tries < 50)
; start from a refresh count.
Could you provided the modified code as a minimal example?
Thanks for the suggestion, sounds good. I'll make the change and test it fixes.
This is the @balamsoto modified code (using keys in stead of GPIO)
#!/usr/bin/env python2
# Modified balamsoto code by jehutting
# See balamsoto's code at will price python-omxplayer-wrapper issue #85
# Original code uses GPIOs in stead of keyboard keys
import os.path
from time import sleep
import subprocess
import os
from omxplayer import OMXPlayer
vida = 'Videos/testvids/6.mov'
vidb = 'Videos/testvids/3.mov'
vidc = 'Videos/testvids/t2.mp4'
vidd = 'Videos/testvids/t3.mp4'
default = 'Videos/testvids/t1.mp4'
from keyb import KBHit
player = OMXPlayer(default, args=['--no-osd','--blank'],)
try:
# KEYBOARD control
kb = KBHit()
while True:
if kb.kbhit():
c = kb.getch()
print(c)
if c == chr(27) or c == 'q': # ESC or 'q' key to quit
break
elif c == '1':
player.load(default)
player.play()
elif c == '2':
player.load(vida)
player.play()
elif c == '3':
player.load(vidb)
player.play()
elif c == '4':
player.load(vidc)
player.play()
elif c == '5':
player.load(vidd)
player.play()
sleep(1)
except KeyboardInterrupt:
print('KeyboardInterrupt')
# Kill the `omxplayer` process gracefully.
player.quit()
The keyboard KBHit() functionality in keyb.py.zip.
Fix in python-omxplayer-wrapper:: player.py
....
def _setup_dbus_connection(self, Connection, bus_address_finder):
logger.debug('Trying to connect to OMXPlayer via DBus')
self.tries = 0 #fix issue-85
while self.tries < 50:
logger.debug('DBus connect attempt: {}'.format(self.tries))
try:
....
Hi! Just playing around with GPIOs and OMXPlayer. Ran both examples from here. 2 Problems:
Thanks in advance for your help (I' raspberry / python newbie :-)) Chris
Hi, this answer is a little late but rather late then never ;-). Regarding point 1 you could increase the GPU memory and try if the videos can be played with the terminal (omxplayer pathofvideo). For the second point i made a video which you can see here. This also includes how to set the Gpu memory. Hope this helps .
Issue : crashes
Description:
using 3 gpio as input pull up to load movies makes the player crash after few pushbuttons
Problem reproduction
after few gpio are grounded player crashes
code
error
Environment details
lsb_release -a
):python-omxplayer-wrapper
0.1.0
python-dbus
(dpkg -s python-dbus
)1.2.0
python
(python --version
)2.7.9
omxplayer
(omxplayer --version
)6c90c75