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 

dump_video.py example doesn't work

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



Joined: 05 Oct 2005
Posts: 4

PostPosted: Wed Oct 05, 2005 4:30 pm    Post subject: dump_video.py example doesn't work Reply with quote

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
View user's profile Send private message MSN Messenger
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Wed Oct 05, 2005 6:24 pm    Post subject: Reply with quote

Which pymedia version is that ?
Something wrong either with the file or with the example. Can you share the file ?
Back to top
View user's profile Send private message
pylorca



Joined: 05 Oct 2005
Posts: 4

PostPosted: Wed Oct 05, 2005 7:01 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Wed Oct 05, 2005 7:46 pm    Post subject: Reply with quote

I meant video file Smile
Anyway are you able to play that file via WMP or something ?
Back to top
View user's profile Send private message
pylorca



Joined: 05 Oct 2005
Posts: 4

PostPosted: Thu Oct 06, 2005 6:19 am    Post subject: Reply with quote

ahhahahaha Very Happy

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
View user's profile Send private message MSN Messenger
pylorca



Joined: 05 Oct 2005
Posts: 4

PostPosted: Tue Oct 11, 2005 5:08 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
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