sc4ry

Get Video Resolution from Properties

5 posts in this topic

Dear all,

I already found the UDF "GetExtProperty" with object "GetDetailsOf" which I already enhanced to get 289 property-infos, nervertheless I am missing the bright/height resolution of a video, which I can see when I run properties of a video in the explorer.

How to get this information via AutoIt?

Thanks for your help.

Share this post


Link to post
Share on other sites



I was looking for a solution for this and came across a UDF

But i can't get width and height this way, not sure why.

#include <File.au3> ; only used for the example script, not needed for the UDF
#include <Array.au3> ; only used for the example script, not needed for the UDF
#include <Constants.au3> ; only used for the MsgBox, not needed for the UDF
;$sFolder = FileSelectFolder("Select a folder to scan", "")
;$sFolder &= ""
$aFile = "C:\Users\careca\Desktop\S01E01.mp4"
;For $I = 1 To $aFiles[0]
    Local $aDetails = _FileGetProperty($aFile) ; Returns an array with all properties of the file
    _ArrayDisplay($aDetails)
;Next
Global $sDetails = _FileGetProperty($aFile, "date modified")
MsgBox($MB_SYSTEMMODAL, "Date Modified", $sDetails)
;===============================================================================
; Function Name.....: _FileGetProperty
; Description.......: Returns a property or all properties for a file.
; Version...........: 1.0.2
; Change Date.......: 05-16-2012
; AutoIt Version....: 3.2.12.1+
; Parameter(s)......: $FGP_Path - String containing the file path to return the property from.
;                     $FGP_PROPERTY - [optional] String containing the name of the property to return. (default = "")
;                     $iPropertyCount - [optional] The number of properties to search through for $FGP_PROPERTY, or the number of items
;                                       returned in the array if $FGP_PROPERTY is blank. (default = 300)
; Requirements(s)...: None
; Return Value(s)...: Success: Returns a string containing the property value.
;                     If $FGP_PROPERTY is blank, a two-dimensional array is returned:
;                         $av_array[0][0] = Number of properties.
;                         $av_array[1][0] = 1st property name.
;                         $as_array[1][1] = 1st property value.
;                         $av_array[n][0] = nth property name.
;                         $as_array[n][1] = nth property value.
;                     Failure: Returns an empty string and sets @error to:
;                       1 = The folder $FGP_Path does not exist.
;                       2 = The property $FGP_PROPERTY does not exist or the array could not be created.
;                       3 = Unable to create the "Shell.Application" object $objShell.
; Author(s).........: - Simucal <Simucal@gmail.com>
;                     - Modified by: Sean Hart <autoit@hartmail.ca>
;                     - Modified by: teh_hahn <sPiTsHiT@gmx.de>
;                     - Modified by: BrewManNH
; URL...............: http://www.autoitscript.com/forum/topic/34732-udf-getfileproperty/page__view__findpost__p__557571
; Note(s)...........: Modified the script that teh_hahn posted at the above link to include the properties that
;                     Vista and Win 7 include that Windows XP doesn't. Also removed the ReDims for the $av_ret array and
;                     replaced it with a single ReDim after it has found all the properties, this should speed things up.
;                     I further updated the code so there's a single point of return except for any errors encountered.
;                     $iPropertyCount is now a function parameter instead of being hardcoded in the function itself.
;===============================================================================
Func _FileGetProperty($FGP_Path, $FGP_PROPERTY = "", $iPropertyCount = 300)
    If $FGP_PROPERTY = Default Then $FGP_PROPERTY = ""
    $FGP_Path = StringRegExpReplace($FGP_Path, '["'']', "") ; strip the quotes, if any from the incoming string
    If Not FileExists($FGP_Path) Then Return SetError(1, 0, "") ; path not found
    Local Const $objShell = ObjCreate("Shell.Application")
    If @error Then Return SetError(3, 0, "")
    Local Const $FGP_File = StringTrimLeft($FGP_Path, StringInStr($FGP_Path, "\", 0, -1))
    Local Const $FGP_Dir = StringTrimRight($FGP_Path, StringLen($FGP_File) + 1)
    Local Const $objFolder = $objShell.NameSpace($FGP_Dir)
    Local Const $objFolderItem = $objFolder.Parsename($FGP_File)
    Local $Return = "", $iError = 0
    If $FGP_PROPERTY Then
        For $I = 0 To $iPropertyCount
            If $objFolder.GetDetailsOf($objFolder.Items, $I) = $FGP_PROPERTY Then
                $Return = $objFolder.GetDetailsOf($objFolderItem, $I)
            EndIf
        Next
        If $Return = "" Then
            $iError = 2
        EndIf
    Else
        Local $av_ret[$iPropertyCount + 1][2] = [[0]]
        For $I = 1 To $iPropertyCount
            If $objFolder.GetDetailsOf($objFolder.Items, $I) Then
                $av_ret[$I][0] = $objFolder.GetDetailsOf($objFolder.Items, $I - 1)
                $av_ret[$I][1] = $objFolder.GetDetailsOf($objFolderItem, $I - 1)
                $av_ret[0][0] += 1
            EndIf
        Next
        ReDim $av_ret[$av_ret[0][0] + 1][2]
        If Not $av_ret[1][0] Then
            $iError = 2
            $av_ret = $Return
        Else
            $Return = $av_ret
        EndIf
    EndIf
    Return SetError($iError, 0, $Return)
EndFunc   ;==>_FileGetProperty

 


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

hey,

thanks, but as already mentioned by you, it is also not showing the information I am searching for. In the array it is mentioned but empty.

Share this post


Link to post
Share on other sites

There's new code in the topic, now works for me. This was the code that worked modified by the user argumentum:

#include <File.au3> ; only used for the example script, not needed for the UDF
#include <Array.au3> ; only used for the example script, not needed for the UDF
#include <Constants.au3> ; only used for the MsgBox, not needed for the UDF

example()
Func example()
    Local $n, $t, $aDetails

    For $n = 1 To 10
        $t = TimerInit()
        $aDetails = _FileGetProperty(@ScriptFullPath, 11)
        ConsoleWrite(Round(TimerDiff($t), 3) & @TAB & $aDetails & @CRLF)
    Next
    ConsoleWrite(@CRLF)
    For $n = 1 To 10 ; shows the optimization, repeatedly getting a property by name
        $t = TimerInit()
        $aDetails = _FileGetProperty(@ScriptFullPath, "Owner")
        ConsoleWrite(Round(TimerDiff($t), 3) & @TAB & $aDetails & @CRLF)
    Next
    ConsoleWrite(@CRLF)

    $t = TimerInit()
    $aDetails = _FileGetProperty(StringLeft(@WindowsDir, 2)) ; Returns an array with all properties of the file
    ConsoleWrite(Round(TimerDiff($t), 3) & ' - Drive properties' & @CRLF)
    _ArrayDisplay($aDetails, "Drive properties")

    $t = TimerInit()
    $aDetails = _FileGetProperty(@ScriptFullPath) ; Returns an array with all properties of the file
    ConsoleWrite(Round(TimerDiff($t), 3) & ' - file properties' & @CRLF)
    _ArrayDisplay($aDetails, "file properties")

    $t = TimerInit()
    $aDetails = _FileGetProperty(@ScriptDir) ; Returns an array with all properties of the file
    ConsoleWrite(Round(TimerDiff($t), 3) & ' - folder properties' & @CRLF)
    _ArrayDisplay($aDetails, "folder properties")

    $t = TimerInit()
    $sDetails = _FileGetProperty(@ScriptFullPath, "date modified")
    ConsoleWrite(Round(TimerDiff($t), 3) & " - date modified" & @CRLF)
    MsgBox($MB_SYSTEMMODAL, "Date Modified", $sDetails)

    Exit 0 ;
EndFunc   ;==>example

;===============================================================================
; Function Name.....: _FileGetProperty
; Description.......: Returns a property, or all properties, for a file.
; Version...........: 1.0.4
; Change Date.......: 09-03-2017
; AutoIt Version....: 3.3.14.x (due to the use of Static, but it could be a Global and use 3.2.12.x)
; Parameter(s)......: $FGP_Path - String containing the file path to return the property from.
;                     $FGP_PROPERTY - [optional] String containing the name of the property to return. (default = "")
;                     $iPropertyCount - [optional] The number of properties to search through for $FGP_PROPERTY, or the number of items
;                                       returned in the array if $FGP_PROPERTY is blank. (default = 500)
; Requirements(s)...: None
; Return Value(s)...: Success: Returns a string containing the property value.
;                     If $FGP_PROPERTY is blank, a two-dimensional array is returned:
;                         $av_array[0][0] = Number of properties.
;                         $av_array[1][0] = 1st property name.
;                         $as_array[1][1] = 1st property value.
;                         $av_array[n][0] = nth property name.
;                         $as_array[n][1] = nth property value.
;                     Failure: Returns an empty string and sets @error to:
;                       1 = The folder $FGP_Path does not exist.
;                       2 = The property $FGP_PROPERTY does not exist or the array could not be created.
;                       3 = Unable to create the "Shell.Application" object $objShell.
; Author(s).........: - Simucal <Simucal@gmail.com>
;                     - Modified by: Sean Hart <autoit@hartmail.ca>
;                     - Modified by: teh_hahn <sPiTsHiT@gmx.de>
;                     - Modified by: BrewManNH
;                     - Modified by: argumentum ; added some optimization, fixed Win10 issue
; URL...............: https://www.autoitscript.com/forum/topic/148232-_filegetproperty-retrieves-the-properties-of-a-file/?do=findComment&comment=1364968
; Note(s)...........: Modified the script that teh_hahn posted at the above link to include the properties that
;                     Vista and Win 7 include that Windows XP doesn't. Also removed the ReDims for the $av_ret array and
;                     replaced it with a single ReDim after it has found all the properties, this should speed things up.
;                     I further updated the code so there's a single point of return except for any errors encountered.
;                     $iPropertyCount is now a function parameter instead of being hardcoded in the function itself.
;                     Added the use of $FGP_PROPERTY as Index + 1 ( as is shown the array ), in additon to $FGP_PROPERTY as Verb
;                     Added the array Index to the @extended, as this the optimization is for just te last index used.
;                     Fixed array chop short on ReDim ( Win10 issue )
;===============================================================================
Func _FileGetProperty($FGP_Path, $FGP_PROPERTY = "", $iPropertyCount = 500)
    If $FGP_PROPERTY = Default Then $FGP_PROPERTY = ""
    $FGP_Path = StringRegExpReplace($FGP_Path, '["'']', "") ; strip the quotes, if any from the incoming string
    If Not FileExists($FGP_Path) Then Return SetError(1, 0, "") ; path not found
    Local Const $objShell = ObjCreate("Shell.Application")
    If @error Then Return SetError(3, 0, "")
    Local Const $FGP_File = StringTrimLeft($FGP_Path, StringInStr($FGP_Path, "\", 0, -1))
    Local Const $FGP_Dir = StringTrimRight($FGP_Path, StringLen($FGP_File) + 1)
    Local Const $objFolder = $objShell.NameSpace($FGP_Dir)
    Local Const $objFolderItem = $objFolder.Parsename($FGP_File)
    Local $Return = "", $iError = 0, $iExtended = 0, $iLastValue = 0
    Local Static $FGP_PROPERTY_Text = "", $FGP_PROPERTY_Index = 0
    If $FGP_PROPERTY_Text = $FGP_PROPERTY And $FGP_PROPERTY_Index Then
        If $objFolder.GetDetailsOf($objFolder.Items, $FGP_PROPERTY_Index) = $FGP_PROPERTY Then
            Return SetError(0, $FGP_PROPERTY_Index, $objFolder.GetDetailsOf($objFolderItem, $FGP_PROPERTY_Index))
        EndIf
    EndIf
    If Int($FGP_PROPERTY) Then
        $Return = $objFolder.GetDetailsOf($objFolderItem, $FGP_PROPERTY - 1)
        If $Return = "" Then
            $iError = 2
        EndIf
    ElseIf $FGP_PROPERTY Then
        For $I = 0 To $iPropertyCount
            If $objFolder.GetDetailsOf($objFolder.Items, $I) = $FGP_PROPERTY Then
                $FGP_PROPERTY_Text = $FGP_PROPERTY
                $FGP_PROPERTY_Index = $I
                $iExtended = $I
                $Return = $objFolder.GetDetailsOf($objFolderItem, $I)
            EndIf
        Next
        If $Return = "" Then
            $iError = 2
        EndIf
    Else
        Local $av_ret[$iPropertyCount + 1][2]
        For $I = 1 To $iPropertyCount
            If $objFolder.GetDetailsOf($objFolder.Items, $I) Then
                $av_ret[$I][0] = $objFolder.GetDetailsOf($objFolder.Items, $I - 1)
                $av_ret[$I][1] = $objFolder.GetDetailsOf($objFolderItem, $I - 1)
                If $av_ret[$I][0] Then $iLastValue = $I
            EndIf
        Next
        ReDim $av_ret[$iLastValue + 1][2]
        $av_ret[0][0] = $iLastValue
        If Not $av_ret[1][0] Then
            $iError = 2
            $av_ret = $Return
        Else
            $Return = $av_ret
        EndIf
    EndIf
    Return SetError($iError, $iExtended, $Return)
EndFunc   ;==>_FileGetProperty

 


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

works great, big THX

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