Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
VB.NET - Get .AVI file information: duration
smakme7757
post Jun 18 2012, 05:33 PM
Post #1
Atomican
Overlord




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

CODE
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?



--------------------
Blog: https://jackkb.net
Go to the top of the page
 
+Quote Post
SquallStrife
post Jun 19 2012, 10:57 AM
Post #2
Atomican
Guru




http://www.fastgraph.com/help/avi_header_format.html

[number of video frames] x [time delay between frames in microseconds] = Video length in microseconds.



--------------------
KEN SENT ME

[retro swim] | http://www.youtube.com/user/RetroSwim
Go to the top of the page
 
+Quote Post
smakme7757
post Jun 20 2012, 07:05 AM
Post #3
Atomican
Overlord




QUOTE (SquallStrife @ Jun 19 2012, 11:57 AM) *
http://www.fastgraph.com/help/avi_header_format.html

[number of video frames] x [time delay between frames in microseconds] = Video length in microseconds.


Ok thanks for that, i look into it :)


--------------------
Blog: https://jackkb.net
Go to the top of the page
 
+Quote Post
SquallStrife
post Jun 20 2012, 09:02 AM
Post #4
Atomican
Guru




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


--------------------
KEN SENT ME

[retro swim] | http://www.youtube.com/user/RetroSwim
Go to the top of the page
 
+Quote Post
smakme7757
post Jun 20 2012, 05:16 PM
Post #5
Atomican
Overlord




QUOTE (SquallStrife @ Jun 20 2012, 09:02 AM) *
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


--------------------
Blog: https://jackkb.net
Go to the top of the page
 
+Quote Post
SledgY
post Jun 21 2012, 09:21 AM
Post #6
Atomican
Master




QUOTE (smakme7757 @ Jun 20 2012, 05:16 PM) *
QUOTE (SquallStrife @ Jun 20 2012, 09:02 AM) *
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.


--------------------
poweredbypenguins.org - SledgY lives in the cloud...
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 26th May 2013 - 02:22 AM