Tvern Posted September 24, 2009 Share Posted September 24, 2009 (edited) hi, I am trying to make a simple video converter using mencoder, but I can't find a way to detect what resolution, or aspect ratio the video has. The resolution and aspect ratio are usually available from the details tab in file info, but I can't find the right function to read this information. thanks in advance Tom Edited September 25, 2009 by Tvern Link to comment Share on other sites More sharing options...
GEOSoft Posted September 24, 2009 Share Posted September 24, 2009 I have a couple of functions that may help. What file type are you working with? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Tvern Posted September 24, 2009 Author Share Posted September 24, 2009 I have a couple of functions that may help. What file type are you working with?Nearly all the video's are *.avi if that's what you mean. I'm using the exe version of memcoder.I've discovered a way to get the resolution (not the ratio) of a file using the stdout of ffmpeg.exe, but it's not a very nice method, so I'd be very happy with any alternative I can experiment with. Link to comment Share on other sites More sharing options...
GEOSoft Posted September 24, 2009 Share Posted September 24, 2009 Here is something that works fine for me. expandcollapse popup$sVid = "D:\Docs\My Videos\VHS_Convert\Love Jones.avi" $aDims = _Dimensions($sVid) If Not @error Then $aRatio = _Ratio($aDims[0], $aDims[1]) MsgBox(0, "Ratio", $aRatio[0] & ":" & $aRatio[1]) EndIf Func _Ratio($n1, $n2) ;; Thanks to monoceres $n1 = Number($n1) $n2 = Number($n2) $ratio = $n1 / $n2 For $i = 2 To $n1 / 2 $r1 = $i * $ratio If Round($r1) = $r1 Then Local $ret[2] = [$r1, $r1 / $ratio] Return $ret EndIf Next Local $ret[2] = [$n1, $n2] Return $ret ; If no good match was found EndFunc ;==>_Ratio Func _Dimensions($sFile) Local $sPath = StringRegExpReplace($sFile, "(.+)\\.+\..+", "$1") Local $sFileName = StringRegExpReplace($sFile, ".+\\(.+)", "$1") $sRegEx = "\s*(\d+)\s*x\s*(\d+)" Local $oShell = ObjCreate("Shell.Application") Local $objFolder = $oShell.Namespace($sPath) For $sFileName In $objFolder.Items $sStr = $objFolder.GetDetailsOf($sFileName, 26) If Not StringInStr($sStr, "x") Then Return SetError(1, 1) ;; Invalid Dimension Local $aRtn = StringRegExp($sStr, $sRegEx, 1) If Not @error Then If Ubound($aRtn) <> 2 Then Return SetError(1, 2) ;; SRE could not get the proper values Return $aRtn EndIf Return SetError(1, 2) ;; SRE could not get the proper values Next EndFunc ;==>_Dimensions George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Tvern Posted September 25, 2009 Author Share Posted September 25, 2009 Here is something that works fine for me. expandcollapse popup$sVid = "D:\Docs\My Videos\VHS_Convert\Love Jones.avi" $aDims = _Dimensions($sVid) If Not @error Then $aRatio = _Ratio($aDims[0], $aDims[1]) MsgBox(0, "Ratio", $aRatio[0] & ":" & $aRatio[1]) EndIf Func _Ratio($n1, $n2) ;; Thanks to monoceres $n1 = Number($n1) $n2 = Number($n2) $ratio = $n1 / $n2 For $i = 2 To $n1 / 2 $r1 = $i * $ratio If Round($r1) = $r1 Then Local $ret[2] = [$r1, $r1 / $ratio] Return $ret EndIf Next Local $ret[2] = [$n1, $n2] Return $ret ; If no good match was found EndFunc ;==>_Ratio Func _Dimensions($sFile) Local $sPath = StringRegExpReplace($sFile, "(.+)\\.+\..+", "$1") Local $sFileName = StringRegExpReplace($sFile, ".+\\(.+)", "$1") $sRegEx = "\s*(\d+)\s*x\s*(\d+)" Local $oShell = ObjCreate("Shell.Application") Local $objFolder = $oShell.Namespace($sPath) For $sFileName In $objFolder.Items $sStr = $objFolder.GetDetailsOf($sFileName, 26) If Not StringInStr($sStr, "x") Then Return SetError(1, 1) ;; Invalid Dimension Local $aRtn = StringRegExp($sStr, $sRegEx, 1) If Not @error Then If Ubound($aRtn) <> 2 Then Return SetError(1, 2) ;; SRE could not get the proper values Return $aRtn EndIf Return SetError(1, 2) ;; SRE could not get the proper values Next EndFunc ;==>_Dimensions That looks like it does exactly what I need and it might prove a good way to learn a bit more about ObjCreate() as that's like black magic to me at the moment. Thanks allot. Link to comment Share on other sites More sharing options...
GEOSoft Posted September 25, 2009 Share Posted September 25, 2009 Glad to hear it. If you want to study Obj*() functions make sure to study this page http://dundats.mvps.org/help/html/intro/ComRef.htm To find it in the help file, go to Function Reference and click on Obj/COM Reference. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now