File Frame Height/Width

User avatar
Abraxus
3StarLounger
Posts: 256
Joined: 01 Mar 2010, 17:34
Location: Blue Springs, MO

File Frame Height/Width

Post by Abraxus »

I am trying to see what quality of videos I have on my computer.

Is there anything in VBA that will show me the Frame Height & Frame Width

My ultimate goal is to get a list of folders, file names, and their frame height/width so I can see if any are poor quality.

Thanks!
Morgan

User avatar
HansV
Administrator
Posts: 78783
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: File Frame Height/Width

Post by HansV »

Something to get you started. Set a reference (using Tools > References...) to the Microsoft Shell Controls and Automation library.

Code: Select all

Sub Test()
    Dim strFolder As String
    Dim strFile As String
    Dim arr
    strFolder = "C:\Some Folder\" ' Change to a folder with videos
    strFile = Dir(strFolder & "*.mp4")
    Do While strFile <> ""
        arr = GetHeightAndWidth(strFolder, strFile)
        Debug.Print strFile, arr(0), arr(1)
        strFile = Dir
    Loop
End Sub

Function GetHeightAndWidth(strFolder As String, strFile As String)
    Dim objShell As Shell32.Shell
    Dim objFolder As Shell32.Folder
    Dim objFile As Shell32.FolderItem
    Dim varFrameHeight, varFrameWidth
    Set objShell = New Shell32.Shell
    Set objFolder = objShell.Namespace(strFolder)
    Set objFile = objFolder.ParseName(strFile)
    varFrameHeight = objFolder.GetDetailsOf(objFile, 316)
    varFrameWidth = objFolder.GetDetailsOf(objFile, 314)
    GetHeightAndWidth = Array(varFrameHeight, varFrameWidth)
End Function
Sample output:

PXL_20220407_083700483.mp4 1920 1080
PXL_20220419_125707926.mp4 1920 1080

There are no doubt better ways.
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 593
Joined: 27 Jun 2021, 10:46

Re: File Frame Height/Width

Post by SpeakEasy »

or ... set the same reference as advised by HansV,

but then use:

Code: Select all

Public Sub test()
    Dim objShell As Shell
    Dim objFolder As Folder
        
    Set objShell = New Shell
    Set objFolder = objShell.Namespace("D:\downloads\deletemesoon") 'folder
    
    With objFolder.ParseName("annefrankCh.mp4") 'file
        Debug.Print "Width: " & .ExtendedProperty("System.Video.FrameWidth")
        Debug.Print "Height: " & .ExtendedProperty("System.Video.FrameHeight")
    End With

End Sub
(and perhaps peek at https://eileenslounge.com/viewtopic.php ... 55#p313555 for some background ...)

User avatar
Abraxus
3StarLounger
Posts: 256
Joined: 01 Mar 2010, 17:34
Location: Blue Springs, MO

Re: File Frame Height/Width

Post by Abraxus »

Thank you, works perfectly!
Morgan

User avatar
DocAElstein
5StarLounger
Posts: 639
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: File Frame Height/Width

Post by DocAElstein »

SpeakEasy wrote:
31 Mar 2024, 15:33
(and perhaps peek at https://eileenslounge.com/viewtopic.php ... 55#p313555 for some background ...)
Hi
There is a lot there to get lost in at that Thread. Probably does not do any harm to read it all through. But for just the .Extended Property stuff, these would be the main posts
https://www.eileenslounge.com/viewtopic ... 61#p313961
https://www.eileenslounge.com/viewtopic ... 71#p313971
( https://www.excelfox.com/forum/showthre ... #post23971
https://www.excelfox.com/forum/showthre ... #post23972 )

Alan
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(