Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding a video file length, frame width and height properties

608 views
Skip to first unread message

Tony Toews

unread,
Oct 23, 2012, 12:30:40 AM10/23/12
to
Folks

In Windows 7 Windows Explorer if you click on a video file at the
bottom of the screen show some basic information about that file.
Same thing if you right click on a file and view the details. What
I'm interested in is the video file length, frame width and height
properties. And anything else I can locate while I'm there.

Any ideas? I've search a number of ways, including the NEW AND
IMPROVED </sarcasm> Google Groups interface for this newsgroup and am
either getting way too many non relevant hits or not finding any VB6
sample code.

Tony

Tony Toews

unread,
Oct 23, 2012, 12:45:32 AM10/23/12
to
On Mon, 22 Oct 2012 22:30:40 -0600, Tony Toews
<tto...@telusplanet.net> wrote:

>In Windows 7 Windows Explorer if you click on a video file at the
>bottom of the screen show some basic information about that file.
>Same thing if you right click on a file and view the details. What
>I'm interested in is the video file length, frame width and height
>properties. And anything else I can locate while I'm there.

A few minutes later, and to my surprise a search at MSDN, of all
places, showed a possibly useful suggestion from one of MS online
forums for an open source DLL called MediaInfo. A bit of digging at
the website and, finally in the download file, has some sample VB5
code inside the Developers\Contrib folder in the "DLL (without
installer)" 7z file at
http://mediainfo.sourceforge.net/en/Download/Windows. I'll muck with
it a bit.

Tony

Tony Toews

unread,
Oct 23, 2012, 2:12:30 AM10/23/12
to
I got it working just fine in VB6 and I was startled when this worked
in MS Access. I did have to do a
ChDir (CurrentProject.Path)
inside Access before I could use the DLL in the code. The DLL was in
the same folder as the Access MDB.

Tony

Larry Serflaten

unread,
Oct 23, 2012, 4:40:44 AM10/23/12
to


Note to self: Look before you leap!


<eg>

Deanna Earley

unread,
Oct 23, 2012, 5:00:47 AM10/23/12
to
On 23/10/2012 07:12, Tony Toews wrote:
> I did have to do a
> ChDir (CurrentProject.Path)

I hope you removed those brackets or added a "Call" too :)

--
Deanna Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored. Please reply to the
group.)

Mayayana

unread,
Oct 23, 2012, 9:03:15 AM10/23/12
to
You might also look into the Shell object. It could
save you needing the extra dependency. There's
no standard way to store "metadata" in different
file types. One just has to learn the format of a
given file. But Windows deals with a lot of types
and anything Windows knows can probably be accessed
via Shell. Here's a sample snippet in VBS:

Set ShellApp = CreateObject("Shell.Application")
On Error Resume Next

arg = WScript.arguments(0)
ReDim A1(40)
sFil = FSO.GetFileName(arg)
sFol = FSO.GetParentFolderName(arg) '-- get parent folder path.
Set Fol = ShellApp.NameSpace(sFol) '-- get ShellFolder object for folder
path.
Set FIs = Fol.Items '-- get Folder.Items collection.
For i2 = 1 to FIs.Count
If FIs.Item(i2).Name = sFil Then '-- go through folder items until a
match is found.
iCount = -1
For i3 = -1 to 40
s2 = Fol.GetDetailsOf(FIs.Item(i2), i3)
If (len(s2) > 0) Then
iCount = iCount + 1
A1(iCount) = s2
End If
Next
Exit For
End If
Next

GetDetailsOf goes back to Win9x, where it just
got size, date modified, etc. As you probably know,
the odd, limited method list of Shell is simply the
functionality of Explorer windows. With each Windows
version that functionality has expanded. The XP list
is as follows:

-1 tooltip
0 Name
1 Size
2 Type
3 Date Modified
4 Date Created
5 Date Accessed
6 Attributes
7 Status
8 Owner

9 Author
10 Title
11 Subject
12 Category
13 Pages
14 Comments
15 Copyright
16 Artist
17 Album Title
18 Year
19 Track Number
20 Genre
21 Duration
22 Bit Rate
23 Protected
24 Camera Model
25 Date Picture Taken
26 Dimensions
27 Not used
28 Not used
29 Not used

30 Company
31 Description
32 File Version
33 Product Name
34 Product Version

The Win7 version may expand into the 40s. I don't know
whether it will return what you need, but it's easy
enough to check.



Eduardo

unread,
Oct 23, 2012, 9:19:07 AM10/23/12
to

"Deanna Earley" <dee.e...@icode.co.uk> escribió en el mensaje
news:k65mbt$bkp$1...@speranza.aioe.org...
> On 23/10/2012 07:12, Tony Toews wrote:
>> I did have to do a
>> ChDir (CurrentProject.Path)
>
> I hope you removed those brackets or added a "Call" too :)

Why? (with just one parameter there is no error)


Jeff Johnson

unread,
Oct 23, 2012, 11:27:44 AM10/23/12
to
"Deanna Earley" <dee.e...@icode.co.uk> wrote in message
news:k65mbt$bkp$1...@speranza.aioe.org...

> or added a "Call" too :)

BLASPHEMY!!


Jeff Johnson

unread,
Oct 23, 2012, 11:28:27 AM10/23/12
to
"Eduardo" <m...@mm.com> wrote in message
news:k665fr$kpf$1...@speranza.aioe.org...

>>> I did have to do a
>>> ChDir (CurrentProject.Path)
>>
>> I hope you removed those brackets or added a "Call" too :)
>
> Why? (with just one parameter there is no error)

Until there are side effects from evaluating the expression. Ultimately it's
bad coding practice.


Eduardo

unread,
Oct 23, 2012, 1:19:24 PM10/23/12
to

"Jeff Johnson" <i....@enough.spam> escribió en el mensaje
news:k66d2s$rs2$1...@dont-email.me...
I don't remember what the side effects could be (if I have read about it in
the past), besides it will take some more processor clocks for doing that,
is there something else involved?


Tony Toews

unread,
Oct 23, 2012, 2:35:40 PM10/23/12
to
On Tue, 23 Oct 2012 01:40:44 -0700 (PDT), Larry Serflaten
<serf...@gmail.com> wrote:

>Note to self: Look before you leap!

Hey, I spent at least an hour searching for sample or API code
including Planet Source.

Tony

Jeff Johnson

unread,
Oct 23, 2012, 5:41:52 PM10/23/12
to
"Eduardo" <m...@mm.com> wrote in message news:k66jia$gf$1...@speranza.aioe.org...

>>>>> I did have to do a
>>>>> ChDir (CurrentProject.Path)
>>>>
>>>> I hope you removed those brackets or added a "Call" too :)
>>>
>>> Why? (with just one parameter there is no error)
>>
>> Until there are side effects from evaluating the expression. Ultimately
>> it's bad coding practice.
>
> I don't remember what the side effects could be (if I have read about it
> in the past), besides it will take some more processor clocks for doing
> that, is there something else involved?

Consider the following code:

Private Sub DisplayText(ByVal Source As TextBox)
MsgBox Source.Text
End Sub

Call it this way:

DisplayText TextBox1

No problem. Now call it this way:

DisplayText (TextBox1)

Type mismatch.

In the original sample with ChDir, there will never be a problem. But there
CAN be problems. The simple solution is "Don't use parentheses for direct
function calls EVER."


Eduardo

unread,
Oct 23, 2012, 10:43:56 PM10/23/12
to

"Jeff Johnson" <i....@enough.spam> escribi� en el mensaje
news:k672v1$9ug$1...@dont-email.me...
> "Eduardo" <m...@mm.com> wrote in message
> news:k66jia$gf$1...@speranza.aioe.org...
>
>>>>>> I did have to do a
>>>>>> ChDir (CurrentProject.Path)
>>>>>
>>>>> I hope you removed those brackets or added a "Call" too :)
>>>>
>>>> Why? (with just one parameter there is no error)
>>>
>>> Until there are side effects from evaluating the expression. Ultimately
>>> it's bad coding practice.
>>
>> I don't remember what the side effects could be (if I have read about it
>> in the past), besides it will take some more processor clocks for doing
>> that, is there something else involved?
>
> Consider the following code:
>
> Private Sub DisplayText(ByVal Source As TextBox)
> MsgBox Source.Text
> End Sub
>
> Call it this way:
>
> DisplayText TextBox1
>
> No problem. Now call it this way:
>
> DisplayText (TextBox1)
>
> Type mismatch.

I think it's because an expression to evaluate can't have an object, so it
looks for it's default property that is Text in this case, and it's a
string, but the function called needs a textbox object as the parameter and
not a string.

BTW it's strange that "ByVal Source As TextBox" worked, but of course it
worked as ByRef and not ByVal.



Tony Toews

unread,
Oct 23, 2012, 11:16:29 PM10/23/12
to
On Tue, 23 Oct 2012 09:03:15 -0400, "Mayayana"
<maya...@invalid.nospam> wrote:

> You might also look into the Shell object.

This sounds like it's the data available when you right click on a
file in Windows Explorer and poke about.

>The Win7 version may expand into the 40s. I don't know
>whether it will return what you need, but it's easy
>enough to check.

Yes, it does show that data about videos. But I couldn't figure out
how to get to that information programmatically.

Thanks, Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/

Deanna Earley

unread,
Oct 24, 2012, 6:01:17 AM10/24/12
to
No compile error anyway (in that case). It WILL fail if someone blindly
adds another parameter (inside the brackets) or if they do the same when
passing an object.

Deanna Earley

unread,
Oct 24, 2012, 6:11:57 AM10/24/12
to
On 24/10/2012 03:43, Eduardo wrote:
> "Jeff Johnson" <i....@enough.spam> escribió en el mensaje
> news:k672v1$9ug$1...@dont-email.me...
>> Consider the following code:
>>
>> Private Sub DisplayText(ByVal Source As TextBox)
>> MsgBox Source.Text
>> End Sub
>>
>> Call it this way:
>>
>> DisplayText TextBox1
>>
>> No problem. Now call it this way:
>>
>> DisplayText (TextBox1)
>>
>> Type mismatch.
>
> I think it's because an expression to evaluate can't have an object, so it
> looks for it's default property that is Text in this case, and it's a
> string, but the function called needs a textbox object as the parameter and
> not a string.
>
> BTW it's strange that "ByVal Source As TextBox" worked, but of course it
> worked as ByRef and not ByVal.

No it's not strange and no it didn't work as ByRef.

ByRef/ByVal works in exactly the same way for objects as for primitive
types.

ByRef means the function can change what that variable/parameter
contains/refers to.
ByVal means it can't, it's limited to it's own scope.

This has no effect on whether you can change properties or call methods
of a passed object which will always be possible.
VB has no native way to clone objects or pass an object clone.

Consider this:

Sub Frob(ByVal Obj as Widget)
Obj.Frob
Set Obj = Nothing
End Sub

Sub Twiddle(ByRef Obj as Widget)
Obj.Twiddle(3)
Set Obj = Nothing
End Sub

Sub DoWork()
Set Obj = New Widget

Frob Obj
'Obj is still set to an instance

Twiddle Obj
'Oh no, Obj is now Nothing as Twiddle changed my reference!

'And from before...
Frob (Obj) 'Type mismatch
End Sub

Deanna Earley

unread,
Oct 24, 2012, 6:12:34 AM10/24/12
to
Oh, I'm way past that according to some people :p

Eduardo

unread,
Oct 24, 2012, 8:40:57 AM10/24/12
to

"Deanna Earley" <dee.e...@icode.co.uk> escribió en el mensaje
news:k68etb$fgf$1...@speranza.aioe.org...
Yes, I understood, the ByRef or ByVal is the implicit variable to the
object. In the case of a control it makes no difference, I think.


Mayayana

unread,
Oct 24, 2012, 8:53:29 AM10/24/12
to
| Yes, it does show that data about videos. But I couldn't figure out
| how to get to that information programmatically.
|

The property pages are separate. I don't know
offhand what property page you're talking about
and don't have a running copy of Win7 handy, but
maybe the library getting that data is available?)

Either way, the Shell object
I'm talking about returns the info. that shows in
Details view. (In Win9x that's about 5 things. In Win7
you can choose from dozens of data bits.)

Shell is a bit clunky, but it works. It's essentially the
function set that Explorer has been using in the GUI since
Active Desktop. You can access any file or folder as
an item as Explorer sees it. You can also trap selection
events if necessary. (I've done that for an Explorer Bar,
so that the bar can update based on changing folder
item selection.)

The following is a sample of getting file properties. Set
a reference to "Microsoft Shell Controls and Automation".
(Note: There are some parts of Shell that require variants.
I don't remember what offhand. But if you run into any
sort of inexplicable errors at any point, switch to variant
datatypes and Dispatch "as Object" declarations.)

Private Sub Command1_Click()
Dim SH As Shell
Dim SHFol As Folder2
Dim FolItem As FolderItem, FolItems As FolderItems
Dim sFilePath As String, sFile As String, sFol As String
Dim Pt1 As Long, i2 As Long, i3 As Long

sFilePath =
"C:\windows\desktop\Bill_Gates_on_Windows_8_Windows_Phone_8_and_Microsoft_Surface.flv"
Pt1 = InStrRev(sFilePath, "\")
sFol = Left$(sFilePath, Pt1 - 1)
If Len(sFol) = 2 Then sFol = sFol & "\"
sFile = Right$(sFilePath, Len(sFilePath) - Pt1)

Set SH = New Shell
Set SHFol = SH.NameSpace(CVar(sFol))
Set FolItems = SHFol.Items
For i2 = 1 To FolItems.Count
If FolItems.Item(i2).Name = sFile Then
For i3 = -1 To 50
Debug.Print CStr(i3) & " - " &
SHFol.GetDetailsOf(FolItems.Item(i2), i3)
Next
Exit For
End If
Next
Set FolItems = Nothing
Set SHFol = Nothing
Set SH = Nothing
End Sub

Funny side note: The sample file used here is a weird
video of Bill Gates gushing disjointedly for 5 minutes about
how [insert any old superlative here] Windows Tile
Mania is. The video is on technet but it's hosted on
Youtube! ...Somehow that seems deeply inauspicious
to me.



Jeff Johnson

unread,
Oct 24, 2012, 4:11:03 PM10/24/12
to
"Eduardo" <m...@mm.com> wrote in message
news:k67kkr$kdj$1...@speranza.aioe.org...
>
> "Jeff Johnson" <i....@enough.spam> escribió en el mensaje
Yes, that's EXACTLY what I was demonstrating. The point is that putting
parentheses around a single-parameter function call CAN have adverse
effects, and you are best off NEVER DOING IT. That is the point I am trying
to make.

> BTW it's strange that "ByVal Source As TextBox" worked, but of course it
> worked as ByRef and not ByVal.

FYI, nothing "worked." I typed that code out off the top of my head directly
into my reply.


Eduardo

unread,
Oct 24, 2012, 5:27:05 PM10/24/12
to

"Jeff Johnson" <i....@enough.spam> escribió en el mensaje
news:k69i0o$sp2$1...@dont-email.me...

> FYI, nothing "worked." I typed that code out off the top of my head
> directly into my reply.

I said worked because I tested it.


Stuart McCall

unread,
Oct 25, 2012, 2:03:02 PM10/25/12
to


"Tony Toews" <tto...@telusplanet.net> wrote in message
news:pt7c889hk4vmt10mj...@4ax.com...
Hey Tony

Maybe I don't dig as well as you, but I couldn't find the 7z file containing
the vb examples. Do you still have the URL?

TIA
Stuart


Tony Toews

unread,
Oct 25, 2012, 4:28:20 PM10/25/12
to
On Thu, 25 Oct 2012 19:03:02 +0100, "Stuart McCall"
<smc...@myunrealbox.com> wrote:

>Maybe I don't dig as well as you, but I couldn't find the 7z file containing
>the vb examples. Do you still have the URL?

The code samples are inside the "DLL (without
installer" 7z file downloaded from the website. Then look for
Developers >> Contrib >> MSVB5.

The website didn't make it very clear that the sample code is inside
the 7z file.

Stuart McCall

unread,
Oct 25, 2012, 6:33:02 PM10/25/12
to
"Tony Toews" <tto...@telusplanet.net> wrote in message
news:f38j88p0jeh5b57fm...@4ax.com...
The 7z file is what I can't find on their site. All you get on the download
page are .exe installers, none of which install the vb files or any docs. So
where did you find the 7z file? I'm pretty sure I've gone through the whole
site and I couldn't turn it up.


Carlos Rocha

unread,
Oct 25, 2012, 6:44:46 PM10/25/12
to
>
> The 7z file is what I can't find on their site. All you get on the download
>
> page are .exe installers, none of which install the vb files or any docs. So
>
> where did you find the 7z file? I'm pretty sure I've gone through the whole
>
> site and I couldn't turn it up.

I know this one :D

http://mediaarea.net/download/binary/libmediainfo0/0.7.61/MediaInfo_DLL_0.7.61_Windows_i386_WithoutInstaller.7z

Henning

unread,
Oct 25, 2012, 6:51:08 PM10/25/12
to

"Stuart McCall" <smc...@myunrealbox.com> skrev i meddelandet
news:H6jis.74303$Ol2....@fx25.am4...
It is there, look for: (32 bit only without installer)

/Henning



Stuart McCall

unread,
Oct 25, 2012, 8:39:33 PM10/25/12
to
"Carlos Rocha" <jazzd...@gmail.com> wrote in message
news:2a0cf614-4b8d-423c...@googlegroups.com...
Many thanks Carlos. That was the right file ok.


Mayayana

unread,
Oct 26, 2012, 1:23:45 PM10/26/12
to
Update:

In case anyone is curious about this: I tested
Shell object on Win7. It took awhile to find a
video that had length and frame data. As it turned
out, Shell returned the video length but not the
frame data. Explorer had a number of MM libraries
loaded, so I gave up on tracking down the source
of the information.


0 new messages