get video duration of MXF file with MediaInfo

Get help with using AutoHotkey and its commands and hotkeys
sbrady19
Posts: 145
Joined: 12 Apr 2018, 05:22
Location: Virginia Beach

get video duration of MXF file with MediaInfo

14 Feb 2019, 07:39

I installed the 32bit version of MediaInfo.
Here is some code I found but I dont see a MsgBox.
Can anyone help me get the file duration.

Code: Select all

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

PathToMediaInfoDLL := "C:\Program Files (x86)\MediaInfo.dll\MediaInfo_InfoTip.dll"
PathToAVIFile := "C:\Users\Audio1\Desktop\QCLoudness\SUV52 Michele Rigby Assad AM v1.mxf"

hModule := DllCall("LoadLibrary", "str", PathToMediaInfoDLL)  ; Avoids the need for subsequent DllCalls to load the library


MediaInfo_New() {
 Return DllCall( "mediainfo\MediaInfo" ( A_IsUnicode ? "" : "A" ) "_New" )
}


MediaInfo_Open( hnd, MediaFile ) {
 Return DllCall( "mediainfo.dll\MediaInfo" ( A_IsUnicode ? "" : "A" ) "_Open", UInt,hnd
               , Str,MediaFile, UInt )
}


MediaInfo_Get( hnd, StrK=0, StrN=0, Comm="", InfK=0, Srch=0 ) {
 Return DllCall( "mediainfo.dll\MediaInfo" ( A_IsUnicode ? "" : "A" ) "_Get", UInt,hnd
               , Int,StrK, Int,StrN, Str,Comm, Int,InfK, Int,Sech, Str )
}


MediaInfo_Close( hnd ) {
 Return DllCall( "mediainfo\MediaInfo" ( A_IsUnicode ? "" : "A" ) "_Close", UInt,hnd )
}



sbrady19
Posts: 145
Joined: 12 Apr 2018, 05:22
Location: Virginia Beach

Re: get video duration of MXF file with MediaInfo

14 Feb 2019, 07:51

here is another bit of code I found, cant get the duration parameter to show up.

Code: Select all

#SingleInstance FORCE
SetWorkingDir, "C:\Users\Audio1\Desktop"

DllCall("LoadLibrary", Str, "MediaInfo_InfoTip.dll")

G := MediaInfo_DumpInfo("C:\Users\Audio1\Desktop\QCLoudness\SUV52 Michele Rigby Assad AM v1.mxf")
MsgBox, %G% ; General

       Loop, parse, G, `n,
         {
         If A_LoopField contains Duration
            {
            StringSplit, d, A_LoopField, `:
		MsgBox %d2%
            ;Break
            }
         }

;t := "50mn 30s"
t := d2
RegExMatch(t, "O)(?<min>\d+)mn (?<sec>\d+)s", t)
MsgBox % t.min * 60000 + t.sec * 1000
t := t.min * 60000 + t.sec * 1000
MsgBox %t%
t := t/60000
MsgBox %t%

ExitApp
Return
sbrady19
Posts: 145
Joined: 12 Apr 2018, 05:22
Location: Virginia Beach

Re: get video duration of MXF file with MediaInfo

14 Feb 2019, 09:00

here is a 3rd try at getting the duration of a video file. Still cant get the duration data.

Code: Select all

#SingleInstance, Force
DllCall( "LoadLibrary", Str,"C:\Users\Audio1\Desktop\MediaInfo_InfoTip.Dll" )


Loop, C:\Users\Audio1\Desktop\QCLoudness\*.mxf
{
video := A_LoopFilename
stringtrimright, filename, video, 4
fileext := A_LoopFileext


hnd := MediaInfo_New()
MediaInfo_Open( hnd, video )
resolution=% MediaInfo_Get( hnd, 1,0, "Width", 1  ) "x" MediaInfo_Get( hnd, 1,0, "Height", 1 )
duration=% MediaInfo_Get( hnd, 1,0, "Duration/String3", 1 )
stringtrimright, durationshort1, duration, 4
stringtrimleft, durationshort2, durationshort1, 1
StringReplace, durationshort3, durationshort2, :,·,all

MsgBox %durationshort3% 111
}
return




MediaInfo_New() {
 Return DllCall( "mediainfo.dll\MediaInfo_InfoTip.Dll" ( A_IsUnicode ? "" : "A" ) "_New" )
}

MediaInfo_Open( hnd, MediaFile ) {
 Return DllCall( "mediainfo.dll\MediaInfo_InfoTip.Dll" ( A_IsUnicode ? "" : "A" ) "_Open", UInt,hnd
               , Str,MediaFile, UInt )
}

MediaInfo_Get( hnd, StrK=0, StrN=0, Comm="", InfK=0, Srch=0 ) {
 Return DllCall( "mediainfo.dll\MediaInfo_InfoTip.Dll" ( A_IsUnicode ? "" : "A" ) "_Get", UInt,hnd
               , Int,StrK, Int,StrN, Str,Comm, Int,InfK, Int,Sech, Str )
}

MediaInfo_Close( hnd ) {
 Return DllCall( "mediainfo\MediaInfo_InfoTip.Dll" ( A_IsUnicode ? "" : "A" ) "_Close", UInt,hnd )
}


Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot] and 46 guests