Link to home
Start Free TrialLog in
Avatar of Jaume Gelabert
Jaume Gelabert

asked on

Get MPG, AVI, MOV,... properties

Hi!
I need a function to get the properties of a Video file: MPG, AVI, MOV,...
The properties I need to get are:
  - duration of the video,
  - dimensions (width x height),
  - sound / no sound
  - ...
Thanks in advance!
Avatar of pjknibbs
pjknibbs

If you load the relevant movie into an ActiveMovie control, I think you can get at these properties via properties of the ActiveMovie control...certainly it has properties Duration, ImageSourceHeight and ImageSourceWidth.
Add the Windows Media Player to your project by right-clicking the toolbox and selecting "Components..." then select "Windows Media Player" (MSDXM.OCX) from the list.

Add the media Player to your form.

Then set the following properties:

   MediaPlayer1.AutoStart = False
   MediaPlayer1.FileName = "whatever_your_movie_is.mpg"


Then, you can do the following:

    Dim lDuration As Double
    Dim lHeight As Long
    Dim lWidth As Long
    Dim lStreams As Long
   
    'GET MOVIE DURATION IN SECONDS
    lDuration = MediaPlayer1.Duration
    'GET MOVIE HEIGHT
    lHeight = MediaPlayer1.ImageSourceHeight
    'GET MOVIE WIDTH
    lWidth = MediaPlayer1.ImageSourceWidth
    'GET NUMBER OF STREAMS IN MOVIE, IF 0, NO AUDIO
    lStreams = MediaPlayer1.StreamCount


Make sure you're using the latest MediaPlayer... You can download version 6.4 from here:  http://www.microsoft.com/windows/mediaplayer/en/default.asp?RLD=58


Cheers!


Avatar of Jaume Gelabert

ASKER

Well! The Media Player OCX is a possible solution, but I don't want to depend of a OCX. For the moment I've found the way to get the info or an AVI file, using API functions. I'm interested in the same but for the MPG, MOV,... files.
thanks!
The problem is, there's no support in Windows for MPG or MOV movies other than through the Windows Media Player, so you can't get the information you want using APIs.
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The URL mentioned is dead.