| View previous topic :: View next topic |
| Author |
Message |
pylorca
Joined: 05 Oct 2005 Posts: 4
|
Posted: Wed Oct 05, 2005 4:30 pm Post subject: dump_video.py example doesn't work |
|
|
Hi, I'm testing pymedia but when I try the dump_video.py example doesn't work
| Code: |
$ ./a.py Video03266.mpg xxx 2
Traceback (most recent call last):
File "./a.py", line 48, in ?
dumpVideo( sys.argv[ 1 ], sys.argv[ 2 ], int( sys.argv[ 3 ] ) )
File "./a.py", line 16, in dumpVideo
raise "There is no video stream in a file %s" % inFile
There is no video stream in a file Video03266.mpg
|
any idea? |
|
| Back to top |
|
 |
jbors Site Admin

Joined: 12 Nov 2004 Posts: 1675
|
Posted: Wed Oct 05, 2005 6:24 pm Post subject: |
|
|
Which pymedia version is that ?
Something wrong either with the file or with the example. Can you share the file ? |
|
| Back to top |
|
 |
pylorca
Joined: 05 Oct 2005 Posts: 4
|
Posted: Wed Oct 05, 2005 7:01 pm Post subject: |
|
|
I'm using pymedia-1.2.2.1
I hasn't installed OGG, VORBIS, FAAD, MP3LAME and VORBISENC
the code:
| Code: |
#! /bin/env python
import sys, os
import pymedia.video.muxer as muxer
import pymedia.video.vcodec as vcodec
import Image
def dumpVideo( inFile, outFilePattern, fmt ):
dm= muxer.Demuxer( inFile.split( '.' )[ -1 ] )
i= 1
f= open( inFile, 'rb' )
s= f.read( 400000 )
r= dm.parse( s )
print
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= Image.fromstring("RGB", dd.data, dd.size)
Image.save(outFilePattern % i, img )
i+= 1
s= f.read( 400000 )
r= dm.parse( s )
print 'Saved %d frames' % i
# ----------------------------------------------------------------------------------
# Dump the whole video file into the regular BMP images in the directory and file name specified
# http://pymedia.org/
if __name__ == "__main__":
if len( sys.argv )!= 4:
print 'Usage: dump_video <file_name> <image_pattern> <format_number>\n<format_number> can be: RGB= 2'+\
'\n<image_patter> should include %d in the name. ex. test_%d.bmp.'+ \
'\nThe resulting image will be in a bmp format'
else:
dumpVideo( sys.argv[ 1 ], sys.argv[ 2 ], int( sys.argv[ 3 ] ) )
|
|
|
| Back to top |
|
 |
jbors Site Admin

Joined: 12 Nov 2004 Posts: 1675
|
Posted: Wed Oct 05, 2005 7:46 pm Post subject: |
|
|
I meant video file
Anyway are you able to play that file via WMP or something ? |
|
| Back to top |
|
 |
pylorca
Joined: 05 Oct 2005 Posts: 4
|
Posted: Thu Oct 06, 2005 6:19 am Post subject: |
|
|
ahhahahaha
I tried with two diferent videos (WMV and MPG) and I can play them with wmp and mplayer
when I get home I will share the two videos |
|
| Back to top |
|
 |
pylorca
Joined: 05 Oct 2005 Posts: 4
|
Posted: Tue Oct 11, 2005 5:08 pm Post subject: |
|
|
| Code: | $ ./a.py /home/musica/The\ Rolling\ Stones\ -\ RubyTuesday\ \(Ed\ Sullivan\ Show\ 1967\).mpg xxx 1
({'index': 0, 'type': 0, 'frame_rate_base': 1, 'height': 0, 'channels': 0, 'width': 0, 'length': 0, 'sample_rate': 0, 'frame_rate': 25, 'bitrate': 800000, 'id': 1},)
Assume video stream at 0 index:
Traceback (most recent call last):
File "./a.py", line 53, in ?
dumpVideo( sys.argv[ 1 ], sys.argv[ 2 ], int( sys.argv[ 3 ] ) )
File "./a.py", line 34, in dumpVideo
dd= d.convert( fmt )
AttributeError: 'VFrame' object has no attribute 'convert' |
with this video I have other problem |
|
| Back to top |
|
 |
|
|
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
|