Jump to content
Sign in to follow this  
smakme7757

VB.NET - Get .AVI file information: duration

Recommended Posts

Hi all,

 

I'm making a piece of software to pluck out number plate numbers from vehicles in a pre-recorded video. I'm using an SDK provided by the uni and everything has gone quite well. But i'm having a few problems.

 

The major one (although not directly related to the functionality of the software) is getting the duration of the AVI file that is loaded so i can have a timer there (that counts up until the video is finished). At the moment i get the information from the windows properties of the file which works well, but in some cases a video file might not have a duration registered. In that case i've just made the count up timer display ??:??:??. However there must be some library or tool available to extract this information from an AVI file. I've search high and low on the internet to no avail.

 

So far this is the method i'm using. I found this buried in the interwebs so it's not my own work:

Source http://forums.codeguru.com/showpost.php?p=...amp;postcount=4 so it's not my own work

 

Private Function GetDuration(ByVal movieFullPath As String) As String 'Finn ut hvor lang videon er: Credit http://forums.codeguru.com/showpost.php?p=1958421&postcount=4
		If File.Exists(movieFullPath) Then
			Dim objShell As Object = CreateObject("Shell.Application")
			Dim objFolder As Object = _
			   objShell.Namespace(Path.GetDirectoryName(movieFullPath))
			For Each strFileName In objFolder.Items
				If strFileName.Name = Path.GetFileName(movieFullPath) Then
					Return objFolder.GetDetailsOf(strFileName, 27).ToString
				End If
			Next
			Return ""
		Else
			Return ""
		End If
	End Function

Then i came across this piece of info:

http://www.c-sharpcorner.com/UploadFile/mg...5e-758f96525409

 

However it seems the old Direct X libraries are not supported in .NET 4 and it throws an error.

 

The solution above work, but i would feel safer using something that can get the raw data out of the file if possible.

 

Any ideas?

Share this post


Link to post
Share on other sites

You'll want to use BinaryReader, so you can seek directly to the locations of those values.

 

You may need to do some experimentation, to find out the endianness.

 

http://www.dotnetperls.com/binaryreader-vbnet

Yea, i'll have to have a play with that tonight. I've never heard about that to be honest so it will be fun to have a play with it.

 

Additionally: I've done a massive fuck up though which means i have to redo yesterdays work again today.

 

Programming FAIL. lol

Share this post


Link to post
Share on other sites

You'll want to use BinaryReader, so you can seek directly to the locations of those values.

 

You may need to do some experimentation, to find out the endianness.

 

http://www.dotnetperls.com/binaryreader-vbnet

Yea, i'll have to have a play with that tonight. I've never heard about that to be honest so it will be fun to have a play with it.

 

Additionally: I've done a massive fuck up though which means i have to redo yesterdays work again today.

 

Programming FAIL. lol

 

Use source control. ;)

 

There are visual studio plugins for both GIT and Mercurial. I personally also use BitBucket (they have unlimited private repositories) for my little projects, then I not only have source control but remote backups as well.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×