Freelancer77

Is there a method for extracting the native aspect(width/height) ratio value from a video file (.swf, .avi, .mov)

General file info doesn't include this attribute.



Re: Visual Basic Express Edition Video file attributes?

JohnWein

You could use the VideoControl or WindowsMediaPlayer to get the attributes of the video.



Re: Visual Basic Express Edition Video file attributes?

Freelancer77

Thanks for the reply.

I should have been slightly more specific. Is there a way for visual basic 2005 to acquire these attributes Opening a mediaplayer instance inside my application wouldn't be a viable option. I was hoping for something as easy as picking up the native dimensions of a picture file.





Re: Visual Basic Express Edition Video file attributes?

JohnWein

How to get the native dimensions of a picture file without opening it in VB



Re: Visual Basic Express Edition Video file attributes?

Freelancer77

'Filespec is the complete path and filename of the image file

dim image1 as new bitmap(filespec)

dim img_x, img_y as integer

img_x = image1.width

img_y = image1.height

The bitmap class specification turns the image file into a one-dimentional array of pixel strings. The width and height properties are effectively the string length and array element count.

I would love for someone to show me the equivalent for a video file, if it exists.





Re: Visual Basic Express Edition Video file attributes?

JohnWein

Dim MP as new MediaPlayer

Dim vid_x, vid_y as integer

MP.Open(URI)

vid_x = MP.NaturalVideoWidth

vid_x = MP.NaturalVideoHeight





Re: Visual Basic Express Edition Video file attributes?

Freelancer77

Thank you for continuing to reply. I normally don't like being handheld through a learning process, and you have been patient.

What all must I import/inherit into my form's class in order to expose the MediaPlayer I can't find anything in the help system for Visual Basic 2005, and it is currently undefined.





Re: Visual Basic Express Edition Video file attributes?

JohnWein

You need to update your VB2005 installation.



Re: Visual Basic Express Edition Video file attributes?

Freelancer77

Any chance you could point me to where there's an update for VB2005 that includes anything related to WMP MSUpdate doesn't think my VB2005 needs anything added, and no search I've tried on MSDN turns up a thing related to VB2005 and WMP that could be called an update.



Re: Visual Basic Express Edition Video file attributes?

JohnWein

You should have SP1, .Net 3.0. and the Vista extensions.

http://msdn2.microsoft.com/en-us/vstudio/aa973758.aspx

If I just wanted the dimensions of the video I would use the ActiveMovie control type library, but only because I am familiar with it.

Code Snippet

Imports QuartzTypeLib

Imports System.Runtime.InteropServices

Public Class Form1

Dim FGM As FilgraphManager

Dim Vid As IBasicVideo2

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

OpenFileDialog1.ShowDialog()

FGM = New FilgraphManager

FGM.RenderFile(OpenFileDialog1.FileName)

Vid = FGM

Label1.Text = Vid.SourceWidth

Label2.Text = Vid.VideoHeight

Marshal.ReleaseComObject(FGM)

End Sub

End Class