Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when execute my python file #1

Open
viniciolindo opened this issue Dec 13, 2012 · 9 comments
Open

error when execute my python file #1

viniciolindo opened this issue Dec 13, 2012 · 9 comments

Comments

@viniciolindo
Copy link

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'

@fishkingsin
Copy link

i tried sudo python "your_script_name.py" may work

@NSMyself
Copy link

NSMyself commented Jan 2, 2013

I'm experiencing the exact same error and I can confirm using sudo did not solve the issue.

@jbaiter
Copy link
Owner

jbaiter commented Jan 3, 2013

Can you attach your omxplayer.log?
What is the output of omxplayer when you run it from the commandline with the exact same file?

@intramigo
Copy link

I had the same issue. I wrote about a really quick fix at http://www.raspberrypi.org/phpBB3/viewtopic.php?p=240543&sid=02f907f63638cfff6abd91b18a3fc363#p240543.

The pyomxplayer code expects certain lines to contain certain properties, but omxplayer may have changed what properties it prints and in what order since pyomxplayer was written. So for the video thing -- the build of omxplayer I'm using right now actually prints aspect properties, not video properties on the second line, so as a quick fix I added

aspect_props = self._process.readline()

before the line

video_props = self._VIDEOPROP_REXP.match(self._process.readline()).groups()

@jstampe
Copy link

jstampe commented Feb 11, 2013

The same error can occur when omxplayer reports the profile of the video as a negative number. I fixed this by changing the regular expression for the video info slightly.

Instead of

_VIDEOPROP_REXP = re.compile(r".Video codec ([\w-]+) width (\d+) height (\d+) profile (\d+) fps ([\d.]+).")

I now have

_VIDEOPROP_REXP = re.compile(r".Video codec ([\w-]+) width (\d+) height (\d+) profile ([\d-]+) fps ([\d.]+).")

@ljy396
Copy link

ljy396 commented Jun 11, 2013

Hello,

I got below error messages when I was running python in terminal.

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.

@Dhafar
Copy link

Dhafar commented Jun 14, 2013

Hi there,
I had the same problem and I fixed it today. I guess the problem is that the code "jbaiter" provided expects file properties (line 1) followed by video properties(line 2) and finally audio properties(line 3) in this order, but the omxplayer probably changed the way it lists these items. It is video then audio properties and finaly some file properties. You can see it if play a video from the Terminal with "omxplayer filename"

What I did is:

  1. Take the code from https://github.com/jbaiter/pyomxplayer/blob/master/pyomxplayer.py
  2. cut the code from line 35 (#Get video properties) till line 46.
  3. paste after line 30 (self.audio= dict() ). This way video and audio properties are read in the correct order
  4. comment file properties section (from line 31 to line 34) and (47, 48 ,49) note that these are the line numbers in
    the original file
  5. in (line 54) you have to remove the "not" otherwise the video will be paused right after it starts, because
    "start_playback" is false by default.

That is it, I hope it will help you. Don't forget to reinstall the python module after you edit code

sudo python setup.py install

regards,
Dhafar

@ljy396
Copy link

ljy396 commented Jun 26, 2013

Hello Dhafar,

I followed your steps, but still get error.

from pyomxplayer import OMXPlayer
from pprint import pprint
omx = OMXPlayer('/home/pi/1.mp3')
Traceback (most recent call last):
File "", line 1, in
File "pyomxplayer.py", line 32, in init
video_props =
self._VIDEOPROP_REXP.match(self._process.readline()).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

modified file below

    self.video = dict()
    self.audio = dict()
    # Get video properties
    video_props =

self._VIDEOPROP_REXP.match(self._process.readline()).groups()
self.video['decoder'] = video_props[0]
self.video['dimensions'] = tuple(int(x) for x in video_props[1:3])
self.video['profile'] = int(video_props[3])
self.video['fps'] = float(video_props[4])
# Get audio properties
audio_props =
self._AUDIOPROP_REXP.match(self._process.readline()).groups()
self.audio['decoder'] = audio_props[0](self.audio['channels'], self.audio['rate'],
self.audio['bps']) = [int(x) for x in audio_props[1:]]
# Get file properties
#file_props =
self._FILEPROP_REXP.match(self._process.readline()).groups()
#(self.audio['streams'], self.video['streams'],
# self.chapters, self.subtitles) = [int(x) for x in file_props]

    #if self.audio['streams'] > 0:
    #    self.current_audio_stream = 1
    #    self.current_volume = 0.0

    self._position_thread = Thread(target=self._get_position)
    self._position_thread.start()

    if start_playback:
        self.toggle_pause()
    self.toggle_subtitles()

BR
Kevin

2013/6/15 Dhafar notifications@github.com

Hi there,
I had the same problem and I fixed it today. I guess the problem is that
the code "jbaiter" provided expects file properties (line 1) followed by
video properties(line 2) and finally audio properties(line 3) in this
order, but the omxplayer probably changed the way it lists these items. It
is video then audio properties and finaly some file properties. You can see
it if play a video from the Terminal with "omxplayer filename"

What I did is:

  1. Take the code from
    https://github.com/jbaiter/pyomxplayer/blob/master/pyomxplayer.py
  2. cut the code from line 35 (#Get video properties) till line 46.
  3. paste after line 30 (self.audio= dict() ). This way video and audio
    properties are read in the correct order
  4. comment file properties section (from line 31 to line 34) and (47, 48
    ,49) note that these are the line numbers in
    the original file
  5. in (line 54) you have to remove the "not" otherwise the video will be
    paused right after it starts, because
    "start_playback" is false by default.

That is it, I hope it will help you. Don't forget to reinstall the python
module after you edit code

sudo python setup.py install

regards,
Dhafar


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-19477069
.

@andyjagoe
Copy link

If you're still having trouble, I've forked and it's working for me using 2013-05-25-wheezy-raspbian (not exactly sure which version of omxplayer this is using--it doesn't print version info). I also added a finished property to make it easier to check whether a file played to completion.

https://github.com/andyjagoe/pyomxplayer/blob/master/pyomxplayer.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants