954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

module to get video file dimensions

Is their a python module that can get the dimensions of a video file?

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

What video file format are you talking about?

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

mainly mpeg4, this can vary from divx, to xvid, and other mpeg4 formats. I want a simple program to help he write a config file that is passed to mplayer(avi player). To have the config file automatically written, I need the original WxH. I have found a program that runs on linux that would work, but would still be insterested in using a python module

this is the linux command line program called avitype

shane@mainbox shane $ avitype movies/collateral2/collateral.avi | grep WxH
 InitialFrames=0 Streams=2 SuggestedBufferSize=0 WxH=650x366

I am specifiacally looking for this data 650,366

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

using the linux program avitype, I have written this function. It still would be nice to find an all python way of doing it

# this python function gets the dimensions of a video file and returns them as a tuple (width,height)
# it uses the linux video program avitype (I think this is part of the transcode package)

# getdimensions.py

def getdimensions(video_file):

    import commands
    avitype_command= "/usr/bin/avitype %s | grep WxH" % video_file
    dimensions = commands.getoutput(avitype_command)
    width = dimensions[-7:-4]
    height = dimensions[-3:]
    WxH = (width,height)
    return WxH
shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

I have never managed to get my hands on a linux box, this sounds interesting. I have done some work with the Windows avi player in my C++ days mostly through shared COM.

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You