InDashPC.org Forum Index InDashPC.org
In Dash Car PC forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question about sample code

 
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software
View previous topic :: View next topic  
Author Message
dew6



Joined: 11 Aug 2009
Posts: 1

PostPosted: Tue Aug 11, 2009 11:29 pm    Post subject: Question about sample code Reply with quote

Hi, I am new at using python. I am trying to create a control which takes in video and gets the frames from it. I tried using the following code form the example:

Code:

dm = muxer.Demuxer(inFile.split('.')[-1])
      i = 1
      f = open(inFile,'rb')
      s = f.read(400000)
      r = dm.parse(s)
      v = filter(lambda x: x['type']== muxer.CODEC_TYPE_VIDEO, dm.streams)
      if len(v)== 0:
        raise 'There is no video stream in a file %s' % inFile
     
      v_id = v[0][ 'index' ]
      print 'Assume video stream at %d index: ' % v_id
      c = vcodec.Decoder(dm.streams[v_id])
      while len( s )> 0:
        for fr in r:
          if fr[ 0 ]== v_id:
            d= c.decode(fr[1])
            # Save file as RGB BMP

            if d:
              dd= d.convert(fmt)
              img= pygame.image.fromstring( dd.data, dd.size, "RGB" )
              pygame.image.save(img, outFilePattern % i )
              i+= 1
       
        s= f.read( 400000 )
        r= dm.parse( s )
     
      print 'Saved %d frames' % i


and I received the following error when running it...


Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "C:\Python24\Programs\myProgram.py", line 76, in button_loadMovie_click
self.VideoToImage(filename,"JPEG","")
File "C:\Python24\Programs\myProgram.py", line 99, in VideoToImage
v = filter(lambda x: x['type']== muxer.CODEC_TYPE_VIDEO, dm.streams)
File "C:\Python24\Programs\myProgram.py", line 99, in <lambda>
v = filter(lambda x: x['type']== muxer.CODEC_TYPE_VIDEO, dm.streams)
TypeError: unsubscriptable object


Does anyone have any ideas? I am using Tkinter to create a suitable gui, and this is what happens when I try to load my specified avi file...

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group