dew6
Joined: 11 Aug 2009 Posts: 1
|
Posted: Tue Aug 11, 2009 11:29 pm Post subject: Question about sample code |
|
|
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. |
|