Auflösung von *.wmv, *.avi,... ermitteln

  • Hey Leute

    Ich würde gerne die Auflösung einer Videodatei ermitteln, in der SB wurde ich auf ExtProp.au3 hingewiesen, aber diese gibt mir keine Auflösung(bzw. width/height).

    Hier mal mein Ansatz ;)

    Spoiler anzeigen
    [autoit]

    #include<Array.au3>
    $var = _GetExtProperty("C:\Users\Florian\Videos\Diximan.wmv",-1)
    _ArrayDisplay($var)
    ;===============================================================================
    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]

    Ich hoffe ihr könnt mir helfen

    DFPWare

  • http://msdn.microsoft.com/en-us/library/…v=VS.85%29.aspx
    Hier hab ich mal was ähnliches gefunden!
    Edit:


    Für alle avi's funktionierts mit der auflösung...

    [align=center]Meine Werke mit der Irrlicht Engine
    AutoIt Picture Viewer Dreidimensionaler Bildbetrachter
    Mr Bubble 3D Neue Interpretation des Flashklassikers Bubble trouble

    Einmal editiert, zuletzt von Twodollarbillie (21. Mai 2011 um 13:05)

  • Mit der ExtProp.au3 geht das auch ;).

    Spoiler anzeigen
    [autoit]

    $iWidth = _GetExtProperty(@ScriptDir & "\Test.avi", 277)
    $iHeight = _GetExtProperty(@ScriptDir & "\Test.avi", 275)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite($iWidth & " : " & $iHeight & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]
  • könnt ihr mir mal verraten warum das bei euch funktioniert?

    bei diesem script:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    $iWidth = _GetExtProperty("C:\Users\Florian\Videos\Jackass2.avi", -1)
    _ArrayDisplay($iWidth)
    ;===============================================================================
    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]

    bekomme ich dieses:

    Spoiler anzeigen

    [0]|Jackass2
    [1]|797 MB
    [2]|Videoclip
    [3]|01.01.2010 15:03
    [4]|28.04.2011 17:44
    [5]|21.05.2011 13:07
    [6]|A
    [7]|
    [8]|
    [9]|Video
    [10]|FLORIAN\Florian
    [11]|Video
    [12]|
    [13]|
    [14]|
    [15]|
    [16]|
    [17]|
    [18]|
    [19]|Nicht bewertet
    [20]|
    [21]|
    [22]|
    [23]|
    [24]|
    [25]|
    [26]|
    [27]|01:33:13
    [28]|‎448 kBit/s
    [29]|Nein
    [30]|
    [31]|
    [32]|
    [33]|
    [34]|

    name22 bei deiner Version bekomme ich {5634504D-0000-0010-8000-00AA00389B71} : 0

  • Das ist schon eigenartig... Es könnte Betriebsystemabhängig sein, aber auch mit dem Codec des Videos zusammenhängen. Bei mir enthalten die IDs 277 und 275 die Breite und Höhe des Videos. Versuch es halt mal mit einer der Möglichkeiten aus den anderen Beiträgen ;).

  • oh dann hab ich wohl das falsche gedownloaded ;)

    Danke

    Edit: da blick ich ja sowas von nicht durch ;)

    Ich versteh nix nich viel von dlls, ist das so richtig?

    [autoit]

    DllCall("MediaInfo.dll","int","MediaInfo_Open","str","C:\Users\Florian\Videos\Jackass2.avi")
    DllCall("MediaInfo.dll","wstr","MediaInfo_Inform","int",0)
    $iWidth = DllCall("MediaInfo.dll","wstr","MediaInfo_Get","str","video","str","first","int","width")
    MsgBox(0,"",$iWidth)

    [/autoit]
  • So sollte das korrekt sein:

    Spoiler anzeigen
    [autoit]


    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n ; nur für 32bit Version der DLL notwendig
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    [/autoit] [autoit][/autoit] [autoit]

    ;Loading the DLL
    $DLL=DllOpen("MediaInfo.dll")

    [/autoit] [autoit][/autoit] [autoit]

    ;New MediaInfo handle
    $Handle=DllCall($DLL, "ptr", "MediaInfo_New")

    [/autoit] [autoit][/autoit] [autoit]

    ;Open
    $Open_Result=DllCall($DLL, "int", "MediaInfo_Open", "ptr", $Handle[0], "wstr", "test.avi")

    [/autoit] [autoit][/autoit] [autoit]

    ; Infos ermitteln:
    DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%Width%")
    $Inform=DllCall($DLL, "wstr", "MediaInfo_Inform", "ptr", $Handle[0], "int", 0)
    $breite = $Inform[0]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($DLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%Height%")
    $Inform=DllCall($DLL, "wstr", "MediaInfo_Inform", "ptr", $Handle[0], "int", 0)
    $hoehe= $Inform[0]

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0, "Breite und Höhe", $breite & @CRLF & $hoehe)

    [/autoit] [autoit][/autoit] [autoit]

    ;Delete MediaInfo handle
    $Handle=DllCall($DLL, "none", "MediaInfo_Delete", "ptr", $Handle[0])

    [/autoit] [autoit][/autoit] [autoit]

    ;Close the DLL
    DllClose($dll)

    [/autoit]

    Es gibt glaube ich auch kürzere Wege, hab mich hier jetzt nur mal am Example orientiert. Prinzipiell musst du zunächst ermitteln welche Kategorie du brauchst, also "General", "Video", "Audio" usw. danach schaust du in die Parameterliste der Kategorie und wählst dir den passenden aus. Das ganze wird dann nur noch nach selbem Schema oben eingesetzt:

    Code
    Kategorie;%Parameter%

    Hoffe das hilft dir weiter ;)

  • Die Zeile hier bei dir drin? Bzw. benutzt du nun die 32 oder 64bit dll?

    [autoit]


    #AutoIt3Wrapper_UseX64=n ; für 32bit Version der DLL notwendig
    ; oder
    #AutoIt3Wrapper_UseX64=y ; für 64bit Version der DLL notwendig

    [/autoit]

    2 Mal editiert, zuletzt von misterspeed (21. Mai 2011 um 18:49)

  • also ich benutze glaub ich die 32Bit dll und jetzt hab ich auch das n dur ein y ersetzt, jedoch kommt jetzt nur ne leere messagebox, egal ob ich die [0] weglasse oder nicht

    DFPWare

    Edit: Ja ich hatte die 32Bit dll, aber mit der 64er klappts auch nicht

    Noch ein Edit: Das Beispielskript was dabei war klappt übrigens auch nicht, es kommen nur einige leere MsgBoxen

  • Im Beispielscript muss die dll und die Audiodatei (example.ogg) ja auch im Scriptverzeichnis liegen, ausserdem fehlt im Beispielscript die Codezeile, welche 32 oder 64bit für den Scite Editor erzwingt.

    Wie schaut dein aktuelles Script denn aus? Alle Testdateien und die dll im Scriptverzeichnis? Pfad und/oder Dateiangaben alle korrekt? Auch mal mit einer anderen Datei getestet (könnte ja defekt sein...) und zur Sicherheit darauf geachtet dass Pfade und Dateien keine Leerzeichen und Sonderzeichen enthalten?

    Das Beispiel welches ich oben gepostet habe funktioniert bei mir jedenfalls sowohl mt der 32 als auch der 64bit dll (sofern man oben den richtigen Modus festlegt).

  • aaalso, ne andere Datei hab ich probiert, im scriptdir hab ich die MediaInfo.dll und sonst nix, keine Leer/Sonderzeichen, moment........ mist :pinch: falscher Pfad jaja nenn mich idiot :rolleyes: tut mir leid...

    Danke ;)

    Edit: achso ja wie kann ich das denn jetzt hinbekommen dass das auch auf 32Bit OS's funktioniert?

    Oder muss ich dann einfach nen neues Programm schreiben, bzw die paar zeilen ändern

    DFPWare

  • Naja verwende eben die 32bit DLL und setze oben entsprechend die Zeile auf "#AutoIt3Wrapper_UseX64=n". Das läuft dann auf allen Betriebssystemen ob nun 32 oder 64bit. Eine 64bit Version halte ich derzeit für sinnlos, solange es noch User mit XP/Vista 32bit gibt die dein Programm nutzen sollen. Natürlich kannst du auch immer eine 32 und 64 bit Version compilieren, du solltest dann aber im Scriptverzeichnis beide DLL's vorhalten und diese entsprechend benennen. Macht aber nur unnötig Arbeit, eine reine 32bit Version tuts genauso.

    Solange dein Programm nicht mehr als 2GB Ram verschlingen soll macht 64bit einfach keinen Sinn.