pyomxplayer icon indicating copy to clipboard operation
pyomxplayer copied to clipboard

error when execute my python file

Open viniciolindo opened this issue 12 years ago • 9 comments

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'

viniciolindo avatar Dec 13 '12 16:12 viniciolindo

i tried sudo python "your_script_name.py" may work

fishkingsin avatar Dec 31 '12 03:12 fishkingsin

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

NSMyself avatar Jan 02 '13 17:01 NSMyself

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

jbaiter avatar Jan 03 '13 22:01 jbaiter

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()

intramigo avatar Jan 05 '13 01:01 intramigo

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.]+).")

jstampe avatar Feb 11 '13 23:02 jstampe

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.

ljy396 avatar Jun 11 '13 17:06 ljy396

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

Dhafar avatar Jun 14 '13 19:06 Dhafar

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 [email protected]

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/jbaiter/pyomxplayer/issues/1#issuecomment-19477069 .

ljy396 avatar Jun 26 '13 16:06 ljy396

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

andyjagoe avatar Jul 05 '13 23:07 andyjagoe