'***************************************************************************** ' ' Microsoft Windows Media ' Copyright (C) Microsoft Corporation. All rights reserved. ' ' FileName: WMCMD.VBS ' ' Abstract: Windows Media Encoder Command Line Script Utility ' Use Cscript.exe wmcmd.vbs /? for Help ' ' Last Update: October 11, 2007 ' ' Visit http://www.citizeninsomniac.com/WMV for latest (unofficial) updates. '***************************************************************************** Option Explicit ' Check to see if script is run within cscript host. if instr( LCase(WScript.Fullname),"cscript.exe" ) = 0 then dim WshShell set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Popup "This script must be run using cscript.exe from a command window." , 0 , "Windows Media Encoder Command Line Script Utility" , 64 WScript.Quit() end if ' These variables are part of encoder idl. However vbs cannot use them directly. So these are redefined dim WMENC_ENCODER_STARTING dim WMENC_ENCODER_RUNNING dim WMENC_ENCODER_PAUSED dim WMENC_ENCODER_STOPPING dim WMENC_ENCODER_STOPPED dim WMENC_ENCODER_END_PREPROCESS dim WMENC_ARCHIVE_LOCAL dim WMENC_ARCHIVE_RUNNING dim WMENC_ARCHIVE_PAUSED dim WMENC_ARCHIVE_STOPPED dim WMENC_AUDIO dim WMENC_VIDEO dim WMENC_SCRIPT dim WMENC_FILETRANSFER dim WMENC_SOURCE_START dim WMENC_SOURCE_STOP dim WMENC_SOURCE_PREPARE dim WMENC_SOURCE_UNPREPARE dim WMENC_START_FILETRANSFER dim WMENC_STOP_FILETRANSFER dim WMENC_PROTOCOL_HTTP dim WMENC_PROTOCOL_PUSH_DISTRIBUTION dim WMENC_PVM_NONE dim WMENC_PVM_PEAK dim WMENC_PVM_UNCONSTRAINED dim WMENC_PVM_BITRATE_BASED dim WMASTD_FOURCC dim WMAPRO_FOURCC dim WMALSL_FOURCC dim WMSPEECH_FOURCC dim PCM_FOURCC dim WMV7_FOURCC dim WMV8_FOURCC dim WMV9_FOURCC dim WVC1_FOURCC dim WMS9_FOURCC dim MP41_FOURCC dim UNCOMP_FOURCC dim WMASTD dim WMAPRO dim WMALSL dim WMSPEECH dim PCM dim WMV7 dim WMV8 dim WMV9 dim WVC1 dim WMS9 dim MP41 dim UNCOMP dim WMENC_CONTENT_ONE_AUDIO dim WMENC_CONTENT_ONE_VIDEO dim WMENC_CONTENT_ONE_AUDIO_ONE_VIDEO dim WMENC_VIDEO_STANDARD dim WMENC_VIDEO_DEINTERLACE dim WMENC_VIDEO_INVERSETELECINE dim WMENC_VIDEO_PROCESS_INTERLACED dim WMENC_VIDEO_TELECINE_AUTO dim WMENC_VIDEO_TELECINE_AA_TOP dim WMENC_VIDEO_TELECINE_BB_TOP dim WMENC_VIDEO_TELECINE_BC_TOP dim WMENC_VIDEO_TELECINE_CD_TOP dim WMENC_VIDEO_TELECINE_DD_TOP dim WMENC_VIDEO_TELECINE_AA_BOTTOM dim WMENC_VIDEO_TELECINE_BB_BOTTOM dim WMENC_VIDEO_TELECINE_BC_BOTTOM dim WMENC_VIDEO_TELECINE_CD_BOTTOM dim WMENC_VIDEO_TELECINE_DD_BOTTOM dim WMENC_VIDEO_INTERLACED_AUTO dim WMENC_VIDEO_INTERLACED_TOP_FIRST dim WMENC_VIDEO_INTERLACED_BOTTOM_FIRST dim WMENC_PIXELFORMAT_IYUV dim WMENC_PIXELFORMAT_I420 dim WMENC_PIXELFORMAT_YV12 dim WMENC_PIXELFORMAT_YUY2 dim WMENC_PIXELFORMAT_UYVY dim WMENC_PIXELFORMAT_YVYU dim WMENC_PIXELFORMAT_YVU9 dim WMENC_PIXELFORMAT_RGB24 dim WMENC_PIXELFORMAT_RGB32 dim WMENC_PIXELFORMAT_RGB555 dim WMENC_PIXELFORMAT_RGB565 dim WMENC_PIXELFORMAT_RGB8 WMENC_ENCODER_STARTING = 1 WMENC_ENCODER_RUNNING = 2 WMENC_ENCODER_PAUSED = 3 WMENC_ENCODER_STOPPING = 4 WMENC_ENCODER_STOPPED = 5 WMENC_ENCODER_END_PREPROCESS = 6 WMENC_ARCHIVE_LOCAL = 1 WMENC_ARCHIVE_RUNNING = 1 WMENC_ARCHIVE_PAUSED = 2 WMENC_ARCHIVE_STOPPED = 3 WMENC_AUDIO = 1 WMENC_VIDEO = 2 WMENC_SCRIPT = 4 WMENC_FILETRANSFER = 8 WMENC_SOURCE_START = 1 WMENC_SOURCE_STOP = 2 WMENC_SOURCE_PREPARE = 3 WMENC_SOURCE_UNPREPARE = 4 WMENC_START_FILETRANSFER = 5 WMENC_STOP_FILETRANSFER = 6 WMENC_PROTOCOL_HTTP = 1 WMENC_PROTOCOL_PUSH_DISTRIBUTION = 2 WMENC_PVM_NONE = 1 WMENC_PVM_PEAK = 2 WMENC_PVM_UNCONSTRAINED = 3 WMENC_PVM_BITRATE_BASED = 4 WMASTD_FOURCC = 353 WMAPRO_FOURCC = 354 WMALSL_FOURCC = 355 WMSPEECH_FOURCC = 10 PCM_FOURCC = 0 WMV7_FOURCC = 827739479 WMV8_FOURCC = 844516695 WMV9_FOURCC = 861293911 WVC1_FOURCC = 826496599 WMS9_FOURCC = 844321613 MP41_FOURCC = 1395937357 UNCOMP_FOURCC = 0 WMASTD = "WMASTD" WMAPRO = "WMAPRO" WMALSL = "WMALSL" WMSPEECH = "WMSP" PCM = "PCM" WMV7 = "WMV7" WMV8 = "WMV8" WMV9 = "WMV9" WVC1 = "WVC1" WMS9 = "WMS9" MP41 = "MP41" UNCOMP = "UNCOMP" WMENC_CONTENT_ONE_AUDIO = 1 WMENC_CONTENT_ONE_VIDEO = 16 WMENC_CONTENT_ONE_AUDIO_ONE_VIDEO = 17 WMENC_VIDEO_STANDARD = 1 WMENC_VIDEO_DEINTERLACE = 2 WMENC_VIDEO_INVERSETELECINE = 3 WMENC_VIDEO_PROCESS_INTERLACED = 4 WMENC_VIDEO_TELECINE_AA_TOP = &H23 WMENC_VIDEO_TELECINE_BB_TOP = &H33 WMENC_VIDEO_TELECINE_BC_TOP = &H43 WMENC_VIDEO_TELECINE_CD_TOP = &H53 WMENC_VIDEO_TELECINE_DD_TOP = &H63 WMENC_VIDEO_TELECINE_AA_BOTTOM = &H73 WMENC_VIDEO_TELECINE_BB_BOTTOM = &H83 WMENC_VIDEO_TELECINE_BC_BOTTOM = &H93 WMENC_VIDEO_TELECINE_CD_BOTTOM = &HA3 WMENC_VIDEO_TELECINE_DD_BOTTOM = &HB3 WMENC_VIDEO_INTERLACED_AUTO = 4 WMENC_VIDEO_INTERLACED_TOP_FIRST = &H2004 WMENC_VIDEO_INTERLACED_BOTTOM_FIRST = &H3004 WMENC_PIXELFORMAT_IYUV = &H56555949 WMENC_PIXELFORMAT_I420 = &H30323449 WMENC_PIXELFORMAT_YV12 = &H32315659 WMENC_PIXELFORMAT_YUY2 = &H32595559 WMENC_PIXELFORMAT_UYVY = &H59565955 WMENC_PIXELFORMAT_YVYU = &H55595659 WMENC_PIXELFORMAT_YVU9 = &H39555659 WMENC_PIXELFORMAT_RGB24 = &HE436EB7D WMENC_PIXELFORMAT_RGB32 = &HE436EB7E WMENC_PIXELFORMAT_RGB555 = &HE436EB7C WMENC_PIXELFORMAT_RGB565 = &HE436EB7B WMENC_PIXELFORMAT_RGB8 = &HE436EB7A dim g_strProductName dim g_strProductCopyright dim g_strInput dim g_strAudioInput dim g_strOutput dim g_strOutputString dim g_intSessionType dim g_strProfile dim g_strTitle dim g_strAlbum dim g_strGenre dim g_intTrackNo dim g_strYear dim g_strAuthor dim g_strCopyright dim g_strDescription dim g_strRating dim g_strWMEFile dim g_strProfileSave dim g_strProfileLoad dim g_strVideoEncoderRegistryKey dim g_strLogFile dim g_intAudioDevice dim g_intVideoDevice dim g_intProfile dim g_intBroadcast dim g_strPushServer dim g_strPublishingPoint dim g_strPushTemplate dim g_intMarkInTime dim g_intMarkOutTime dim g_intDuration dim g_intVerbose dim g_intAudioSourceDuration dim g_intVideoSourceDuration dim g_objEncoder dim g_objSourceGroup dim g_objAudioSource dim g_objVideoSource dim g_objProfile dim g_objFileSystem dim g_objWshShell dim g_objLogFile dim g_blnEncoderStarted dim g_blnEndPreProcess dim g_blnEncoderStopped dim g_intErrorCode dim g_intRunningSource dim g_blnDevice dim g_blnAudioOnly dim g_blnVideoOnly dim g_blnSilent dim g_blnDurationError dim g_blnLogOutput dim g_intAudioVBRMode dim g_strAudioCodec dim g_strAudioSetting dim g_intAudioPeakBitrate dim g_intAudioPeakBuffer dim g_intAudioSpeechContent dim g_strAudioSpeechEdl dim g_intAudioSurroundMix dim g_intAudioCenterMix dim g_intAudioLEFMix dim g_strAudioCodecName dim g_intVideoVBRMode dim g_strVideoCodec dim g_intVideoBitrate dim g_intVideoWidth dim g_intVideoHeight dim g_intVideoFramerate dim g_intVideoKeydist dim g_intVideoBuffer dim g_intVideoQuality dim g_intVideoQP dim g_intVideoPeakBitrate dim g_intVideoPeakBuffer dim g_intVideoPreprocess dim g_strPixelFormat dim g_intPixelAspectRatioX dim g_intPixelAspectRatioY dim g_intVideoPerformance dim g_strVideoCodecName dim g_strVideoDevConf dim g_intMaxPacketSize dim g_intMinPacketSize dim g_intVideoCompOpt dim g_intVideoDenoise dim g_intVideoDquantOption dim g_intVideoDquantStrength dim g_intVideoBDeltaQP dim g_intVideoLoopfilter dim g_intVideoMedian dim g_intVideoEdgeRemoval dim g_intVideoNumThreads dim g_intVideoRangeRedux dim g_intVideoOverlap dim g_intVideoScaling dim g_intVideoLookahead dim g_intVideoLookaheadRC dim g_intVideoMBModeCost dim g_intVideoMMatch dim g_intVideoMSLevel dim g_intVideoMSRange dim g_intVideoMVCoding dim g_intVideoMVCost dim g_intVideoBFrameDist dim g_intVideoPercOpt dim g_intVideoType dim g_intVideoCodedWidth dim g_intVideoCodedHeight dim g_strVideoPreset dim g_intVideoThreadAffinity dim g_EncoderRegSettings(30, 1) dim i dim j dim g_blnCreateCustomProfile dim g_tStartTime dim g_tStopTime dim g_intClipLeft dim g_intClipRight dim g_intClipTop dim g_intClipBottom g_objLogFile = Null g_strProductName = "Microsoft (R) Windows Media Encoder Command Line Script Utility" g_strProductCopyright = "Copyright (C) Microsoft Corporation. All rights reserved." g_strInput = "" g_strAudioInput = "" g_strOutput = "" g_strOutputString = "" g_intSessionType = WMENC_CONTENT_ONE_AUDIO g_strProfile = "" g_strTitle = "" g_strAuthor = "" g_strAlbum = "" g_intTrackNo = "" g_strYear = "" g_strGenre = "" g_strCopyright = "" g_strDescription = "" g_strRating = "" g_strWMEFile = "" g_strProfileSave = "" g_strProfileLoad = "" g_strProfile = "" g_strVideoEncoderRegistryKey = "HKCU\Software\Microsoft\Scrunch\WMVideo" g_intAudioDevice = -1 g_intVideoDevice = -1 g_intProfile = -1 g_intBroadcast = -1 g_strPushServer = "" g_strPublishingPoint = "" g_strPushTemplate = "" g_intMarkInTime = -1 g_intMarkOutTime = -1 g_intDuration = -1 g_intVerbose = 2 g_intAudioSourceDuration = -1 g_intVideoSourceDuration = -1 g_blnEncoderStarted = false g_blnEncoderStopped = false g_blnEndPreProcess = false g_blnDevice = false g_intErrorCode = 0 g_intRunningSource = 0 g_blnAudioOnly = false g_blnVideoOnly = false g_blnDurationError = false g_blnLogOutput = false g_intAudioVBRMode = -1 g_strAudioCodec = "" g_strAudioSetting = "" g_intAudioPeakBitrate = -1 g_intAudioPeakBuffer = -1 g_intAudioSpeechContent = -1 g_strAudioSpeechEdl = "" g_intAudioSurroundMix = -1 g_intAudioCenterMix = -1 g_intAudioLEFMix = -1 g_strAudioCodecName = "" g_intVideoVBRMode = -1 g_strVideoCodec = "" g_intVideoBitrate = -1 g_intVideoWidth = -1 g_intVideoHeight = -1 g_intVideoFramerate = -1 g_intVideoKeydist = -1 g_intVideoBuffer = -1 g_intVideoQuality = -1 g_intVideoQP = -1 g_intVideoPeakBitrate = -1 g_intVideoPeakBuffer = -1 g_intVideoPreprocess = -1 g_strPixelFormat = "" g_intPixelAspectRatioX = -1 g_intPixelAspectRatioY = -1 g_intVideoPerformance = -1 g_strVideoCodecName = "" g_strVideoDevConf = "" g_intMaxPacketSize = -1 g_intMinPacketSize = -1 g_intVideoCompOpt = -128 g_intVideoDenoise = -128 g_intVideoDquantOption = -128 g_intVideoDquantStrength = -128 g_intVideoBDeltaQP = -128 g_intVideoLoopfilter = -128 g_intVideoMedian = -128 g_intVideoEdgeRemoval = -128 g_intVideoNumThreads = -128 g_intVideoRangeRedux = -128 g_intVideoOverlap = -128 g_intVideoScaling = -128 g_intVideoLookahead = -128 g_intVideoLookaheadRC = -128 g_intVideoMBModeCost = -128 g_intVideoMMatch = -128 g_intVideoMSLevel = -128 g_intVideoMSRange = -128 g_intVideoMVCoding = -128 g_intVideoMVCost = -128 g_intVideoBFrameDist = -128 g_intVideoPercOpt = -128 g_intVideoType = -128 g_intVideoCodedWidth = -128 g_intVideoCodedHeight = -128 g_strVideoPreset = "" g_intVideoThreadAffinity = -128 for i = 0 to 30 g_EncoderRegSettings(i,0) = "" g_EncoderRegSettings(i,1) = -128 next g_intClipLeft = -1 g_intClipRight = -1 g_intClipTop = -1 g_intClipBottom = -1 g_blnCreateCustomProfile = true ' Create an encoder object. on error resume next set g_objEncoder = WScript.CreateObject( "WMEncEng.WMEncoder" ) if not isObject(g_objEncoder) then OutputInfo "Error: Cannot initialize Windows Media Encoder object. Please verify that" OutputInfo "Windows Media Encoder 9 Series is correctly installed on your system." OutputInfo "If running 64-bit Windows, make sure that the version of cscript.exe used" OutputInfo "corresponds to the version (x86/x64) of WME9 installed on your system." WScript.Quit() end if On Error Goto 0 WScript.ConnectObject g_objEncoder, "Encoder_" ' Setup call back events set g_objFileSystem = WScript.CreateObject( "Scripting.FileSystemObject" ) set g_objWshShell = WScript.CreateObject("WScript.Shell") g_objSourceGroup = Null g_objAudioSource = Null g_objVideoSource = Null g_objProfile = NULL ' Read a integer value from the paramters list. ' args is the paramters list to be read. ' intIndex1 is the position of the parameter name. ' intIndex2 is the position of the parameter value. ' It will return the integer if it can read a integer value from the parameter list ' It will return -1 if it can not get a integer value from the paramters list. function ReadInteger( args, intIndex1, intIndex2 ) on error resume next dim strTypeName ' Check the range of index. if intIndex2 > UBound(args) or Left( args(intIndex2), 1 ) = "-" then OutputInfo "Invalid format for parameter " & args(intIndex1) ReadInteger = -1 exit function end if strTypeName = typename( eval( args(intIndex2) ) ) ' Convert it to an integer value. ReadInteger = CLng( args(intIndex2) ) ' The value is not in integer fommat. if err.number <> 0 or ( strTypeName <> "Integer" and strTypeName <> "Long" ) then OutputInfo "Expect integer value for parameter " & args(intIndex1) ReadInteger = -1 err.Clear end if end function ' Read a float value from the paramters list. ' args is the paramters list to be read. ' intIndex1 is the position of the parameter name. ' intIndex2 is the position of the parameter value. ' It will return the float if it can read a float value from the parameter list ' It will return -1 if it can not get a float value from the paramters list. function ReadFloat( args, intIndex1, intIndex2 ) on error resume next dim strTypeName ' Check the range of index. if intIndex2 > UBound(args) or Left( args(intIndex2), 1 ) = "-" then OutputInfo "Invalid format for parameter " & args(intIndex1) ReadFloat = -1 exit function end if strTypeName = typename( eval( args(intIndex2) ) ) ' Convert it to an integer value. ReadFloat = CSng( args(intIndex2) ) ' The value is not in integer fommat. if err.number <> 0 or ( strTypeName <> "Integer" and strTypeName <> "Long" and strTypeName <> "Single" and strTypeName <> "Double" ) then OutputInfo "Expect float value for parameter " & args(intIndex1) ReadFloat = -1 err.Clear end if end function ' Read a var value from the paramters list. ' args is the paramters list to be read. ' intIndex1 is the position of the parameter name. ' intIndex2 is the position of the parameter value. ' It will return the var if it can not get a var value from the paramters list. ' It will return "" if it can not get a var value from the paramters list. function ReadString( args, intIndex1, intIndex2 ) ' Check the range of index. if intIndex2 > UBound(args) or Left( args(intIndex2), 1 ) = "-" then OutputInfo "Invalid format for parameter " & args(intIndex1) ReadString = "" exit function end if ReadString = args(intIndex2) end function function ConvertStringToInteger( strInput ) on error resume next dim strTypeName strTypeName = typename( eval( strInput ) ) ' Convert it to an integer value. ConvertStringToInteger = CLng( strInput ) ' The value is not in integer fommat. if err.number <> 0 or ( strTypeName <> "Integer" and strTypeName <> "Long" ) then OutputInfo "Invalid format " & strInput & " expecting integer value" ConvertStringToInteger = -1 err.Clear end if end function ' Parse parameters. if wscript.arguments.Length = 0 then ShowHelp() wscript.quit() end if dim colStrArgs() reDim colStrArgs( wscript.arguments.Length-1 ) for i = 0 to wscript.arguments.Length-1 colStrArgs(i) = wscript.arguments(i) next if ParseParameters( colStrArgs ) then ' Do different things depending on whether input is wme, directory encoding or file encoding if g_strInput <> "" and g_objFileSystem.FolderExists(g_strInput) then DoDirectoryModeEncoding() elseif SetupEncoder() then ' Transcode and show statistics information if Transcode() and not g_blnSilent then ShowStatistics() end if end if else OutputInfo "Command-line parsing completed." end if if not IsNull(g_objLogFile) then g_objLogFile.Close end if ' Some input sources are known to cause the script engine to hang ' Forcefully terminate this script TerminateEncoderProcess() WScript.Quit() ' Output information function OutputInfo( strInfo ) WScript.Echo( strInfo ) if g_blnLogOutput then g_objLogFile.WriteLine( strInfo ) end if end function ' Event handler for encoder state function Encoder_OnStateChange( enumState ) dim strState ' Translate encoder state select case enumState case WMENC_ENCODER_STARTING strState = "Starting" case WMENC_ENCODER_RUNNING strState = "Running" g_blnEncoderStarted = true case WMENC_ENCODER_PAUSED strState = "Paused" case WMENC_ENCODER_STOPPING strState = "Stopping" case WMENC_ENCODER_STOPPED g_tStopTime = Now() strState = "Stopped" g_blnEncoderStopped = true case WMENC_ENCODER_END_PREPROCESS strState = "End Preprorocess" g_blnEndPreProcess = true case else strState = "Unknown State" end select Encoder_OnStateChange = 1 end function ' Event handler for encoder error function Encoder_OnError( intResult ) g_intErrorCode = intResult Encoder_OnError = 0 end function function IsEncoderRegistryDirty() On Error Resume Next dim bDirtyFlag dim regDirtyFlag bDirtyFlag = false regDirtyFlag = g_objWshShell.RegRead(g_strVideoEncoderRegistryKey & "\WMCmdDirtyFlag") if err <> 0 then bDirtyFlag = false else if regDirtyFlag = 1 then bDirtyFlag = true else bDirtyFlag = false end if end if IsEncoderRegistryDirty = bDirtyFlag end function function SaveEncoderRegistrySettings() On Error Resume Next g_EncoderRegSettings(0,0) = "\Compression Optimization Type" g_EncoderRegSettings(1,0) = "\DenoiseOption" g_EncoderRegSettings(2,0) = "\Dquant Option" g_EncoderRegSettings(3,0) = "\Dquant Strength" g_EncoderRegSettings(4,0) = "\Force B Frame Delta QP" g_EncoderRegSettings(5,0) = "\Force Encoding Width" g_EncoderRegSettings(6,0) = "\Force Encoding Height" g_EncoderRegSettings(7,0) = "\Force LoopFilter" g_EncoderRegSettings(8,0) = "\Force Median" g_EncoderRegSettings(9,0) = "\Force NoiseEdgeRemoval" g_EncoderRegSettings(10,0) = "\Force NumThreads" g_EncoderRegSettings(11,0) = "\Force Range Reduction" g_EncoderRegSettings(12,0) = "\Force Overlap" g_EncoderRegSettings(13,0) = "\Force Video Scaling" g_EncoderRegSettings(14,0) = "\Lookahead" g_EncoderRegSettings(15,0) = "\Lookahead Ratecontrol" g_EncoderRegSettings(16,0) = "\Macroblock Mode Cost Method" g_EncoderRegSettings(17,0) = "\Motion Match Method" g_EncoderRegSettings(18,0) = "\Motion Search Level" g_EncoderRegSettings(19,0) = "\Motion Search Range" g_EncoderRegSettings(20,0) = "\Motion Vector Coding Method" g_EncoderRegSettings(21,0) = "\Motion Vector Cost Method" g_EncoderRegSettings(22,0) = "\NumBFrames" g_EncoderRegSettings(23,0) = "\Perceptual Option" g_EncoderRegSettings(24,0) = "\VideoType" g_EncoderRegSettings(25,0) = "\Encoder Thread Affinity" for i = 0 to 25 g_EncoderRegSettings(i,1) = g_objWshShell.RegRead(g_strVideoEncoderRegistryKey & g_EncoderRegSettings(i,0)) next On Error Goto 0 end function function RestoreEncoderRegistrySettings() On Error Resume Next for i = 0 to 30 if (g_EncoderRegSettings(i,0) <> "") and (g_EncoderRegSettings(i,1) <> -128) then g_objWshShell.RegWrite g_strVideoEncoderRegistryKey & g_EncoderRegSettings(i,0), g_EncoderRegSettings(i,1), "REG_DWORD" end if next On Error Goto 0 end function ' Deletes WVC1 encoder parameters from the registry function ClearEncoderRegistrySettings() On Error Resume Next g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Compression Optimization Type" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\DenoiseOption" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Dquant Option" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Dquant Strength" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force B Frame Delta QP" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force Encoding Width" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force Encoding Height" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force LoopFilter" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force Median" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force NoiseEdgeRemoval" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force NumThreads" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force Range Reduction" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force Overlap" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Force Video Scaling" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Lookahead" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Lookahead Ratecontrol" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Macroblock Mode Cost Method" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Motion Match Method" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Motion Search Level" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Motion Search Range" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Motion Vector Coding Method" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Motion Vector Cost Method" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\NumBFrames" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Perceptual Option" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\VideoType" g_objWshShell.RegDelete g_strVideoEncoderRegistryKey & "\Encoder Thread Affinity" On Error Goto 0 end function ' Parse the parameters of this program. function ParseParameters( args ) dim reParser dim colMatches dim strMarkOutTime dim strArguments, strArgumentsQuoted dim strSaveToCfgFile dim strLoadFromCfgFile dim strCfgFileArguments dim colStrConfigArgs dim objTextFile dim intVideoRangeReduxYR, intVideoRangeReduxYE, intVideoRangeReduxCR, intVideoRangeReduxCE dim intArgIndex ' First traverse of the arguments just checks for config saving and loading args for intArgIndex=0 to UBound(args) if args(intArgIndex) = "-s_config" then intArgIndex = intArgIndex + 1 else if InStr(args(intArgIndex)," ") > 0 then strArgumentsQuoted = strArgumentsQuoted & Chr(34) & args(intArgIndex) & Chr(34) & " " else strArgumentsQuoted = strArgumentsQuoted & args(intArgIndex) & " " end if strArguments = strArguments & args(intArgIndex) & " " end if if args(intArgIndex) = "-config" then strLoadFromCfgFile = ReadString( args, intArgIndex, intArgIndex+1 ) if strLoadFromCfgFile = "" then ParseParameters = false exit function end if intArgIndex = intArgIndex + 1 strLoadFromCfgFile = g_objFileSystem.GetAbsolutePathName( strLoadFromCfgFile ) set objTextFile = g_objFileSystem.OpenTextFile( strLoadFromCfgFile, 1 ) strCfgFileArguments = objTextFile.ReadLine objTextFile.Close strCfgFileArguments = Trim( strCfgFileArguments ) if strCfgFileArguments = "" then OutputInfo "Configuration file " & strLoadFromCfgFile & " is empty." ParseParameters = false exit function end if ' Splits the argument string into an array using space as separator but respecting quotes set reParser = New RegExp reParser.Pattern = "\s*(" & Chr(34) & "([^" & Chr(34) & "]*)" & Chr(34) & "|([^" & " " & "]+))\s*" reParser.Global = true set colMatches = reParser.Execute(strCfgFileArguments) ReDim colStrConfigArgs(colMatches.Count - 1) for j=0 to colMatches.Count - 1 colStrConfigArgs(j) = Replace(Trim(colMatches(j).Value), Chr(34), "") next set reParser = nothing set colMatches = nothing if ParseParameters( colStrConfigArgs ) = false then ParseParameters = false exit function end if end if next 'OutputInfo "Args = " & strArguments 'OutputInfo "ArgsQuoted = " & strArgumentsQuoted if UBound(args) = 0 then ' If it has only has one parameter, check the content of this parameter. select case LCase( args(0) ) case "-devices": ' List all audio and video devices. ListDevices() ParseParameters = false exit function case "-a_codecs": ' List all audio codecs. ListAudioCodecs() ParseParameters = false exit function case "-a_formats" ' List audio formats ListAudioFormats() ParseParameters = false exit function case "-v_codecs": ' List all video codecs. ListVideoCodecs() ParseParameters = false exit function case "-help": ' Show help information. ShowHelp() ParseParameters = false exit function case "-?": ' Show help information. ShowHelp() ParseParameters = false exit function case "-all?": ' Show help information. ShowHelp() ParseParameters = false exit function case "/?": ' Show help information. ShowHelp() ParseParameters = false exit function end select end if if UBound(args) = 1 then select case LCase( args(0) ) case "-input" ' Print out info about file specified g_strInput = ReadString( args, 0, 1 ) if g_strInput = "" then ParseParameters = false exit function end if PrintFileInfo() ParseParameters = false exit function case "-log" ' Print all output to log file OutputInfo "Log file can only be used with a valid encoding session." ParseParameters = false exit function end select end if ' Check all parameters. for i=0 to UBound(args) select case LCase( args(i) ) ' Parse all input related stuff case "-wme" ' Get the WME file name to be load. g_strWMEFile = ReadString( args, i, i+1 ) if g_strWMEFile = "" then ParseParameters = false exit function end if i = i + 1 case "-input" ' Get input source file name. g_strInput = ReadString( args, i, i+1 ) if g_strInput = "" then ParseParameters = false exit function end if i = i + 1 case "-audioonly" g_blnAudioOnly = true case "-videoonly" g_blnVideoOnly = true case "-adevice" g_blnDevice = true ' Get audio device index. if i+1 <= UBound(args) and Left( args(i+1), 1 ) <> "-" then g_intAudioDevice = ReadInteger( args, i, i+1 ) if g_intAudioDevice = -1 then ParseParameters = false exit function end if i = i + 1 else g_intAudioDevice = 0 ' default audio device end if case "-vdevice" g_blnDevice = true ' Get video device index. if i+1 <= UBound(args) and Left( args(i+1), 1 ) <> "-" then g_intVideoDevice = ReadInteger( args, i, i+1 ) if g_intVideoDevice = -1 then ParseParameters = false exit function end if i = i + 1 else g_intVideoDevice = 0 ' default video device end if ' Parse all profile related stuff case "-profile" ' Get input source file name. g_strProfile = ReadString( args, i, i+1 ) if g_strProfile = "" then ParseParameters = false exit function end if i = i + 1 ' Parse audio related stuff case "-a_input" ' Get alternate audio input source file name. g_strAudioInput = ReadString( args, i, i+1 ) if g_strAudioInput = "" then ParseParameters = false exit function end if i = i + 1 case "-a_mode" g_intAudioVBRMode = ReadInteger( args, i, i+1 ) if g_intAudioVBRMode = -1 then ParseParameters = false exit function end if i = i + 1 case "-a_codec" 'Get audio codec name g_strAudioCodec = ReadString( args, i, i+1 ) g_strAudioCodec = UCase( g_strAudioCodec ) if g_strAudioCodec = "WMA9STD" then g_strAudioCodec = "WMASTD" if g_strAudioCodec = "WMA9PRO" then g_strAudioCodec = "WMAPRO" if g_strAudioCodec = "WMA9LSL" then g_strAudioCodec = "WMALSL" if g_strAudioCodec = "WMSP9" then g_strAudioCodec = "WMSP9" if g_strAudioCodec <> WMASTD and g_strAudioCodec <> WMAPRO and g_strAudioCodec <> WMALSL and g_strAudioCodec <> WMSPEECH and g_strAudioCodec <> PCM then OutputInfo "Please enter correct audio codec index only" ParseParameters = false exit function end if if g_strAudioCodec = "" then ParseParameters = false exit function end if i = i + 1 case "-a_setting" 'Get audio setting g_strAudioSetting = ReadString( args, i, i+1 ) if g_strAudioSetting = "" then ParseParameters = false exit function end if i = i + 1 case "-a_peakbitrate" 'Get audio peakbitrate size g_intAudioPeakBitrate = ReadInteger( args, i, i+1 ) if g_intAudioPeakBitrate = -1 then ParseParameters = false exit function end if i = i + 1 case "-a_peakbuffer" 'Get audio peakbuffer size g_intAudioPeakBuffer = ReadInteger( args, i, i+1 ) if g_intAudioPeakBuffer = -1 then ParseParameters = false exit function end if i = i + 1 case "-a_content" 'Get content type for speech g_intAudioSpeechContent = ReadInteger( args, i, i+1 ) if g_intAudioSpeechContent = -1 then ParseParameters = false exit function elseif g_intAudioSpeechContent < 0 or g_intAudioSpeechContent > 2 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-a_contentedl" 'Get EDL file for speech content g_strAudioSpeechEdl = ReadString( args, i, i+1 ) if g_strAudioSpeechEdl = "" then ParseParameters = false exit function end if i = i + 1 case "-a_folddown6to2" 'Get EDL file for speech content g_intAudioSurroundMix = ReadInteger( args, i, i+1 ) if g_intAudioSurroundMix = -1 then ParseParameters = false exit function end if g_intAudioCenterMix = ReadInteger( args, i, i+2 ) if g_intAudioCenterMix = -1 then ParseParameters = false exit function end if g_intAudioLEFMix = ReadInteger( args, i, i+3 ) if g_intAudioLEFMix = -1 then ParseParameters = false exit function end if i = i + 3 ' Parse video related stuff case "-v_mode" g_intVideoVBRMode = ReadInteger( args, i, i+1 ) if g_intVideoVBRMode = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_codec" 'Get video codec name g_strVideoCodec = ReadString( args, i, i+1 ) g_strVideoCodec = UCase( g_strVideoCodec ) if g_strVideoCodec <> WMV7 and g_strVideoCodec <> WMV8 and g_strVideoCodec <> WMV9 and g_strVideoCodec <> WVC1 and g_strVideoCodec <> WMS9 and g_strVideoCodec <> UNCOMP and g_strVideoCodec <> MP41 then OutputInfo "Please enter correct video codec index only" ParseParameters = false exit function end if if g_strVideoCodec = "" then ParseParameters = false exit function end if i = i + 1 case "-v_bitrate" 'Get video bitrate g_intVideoBitrate = ReadInteger( args, i, i+1 ) if g_intVideoBitrate = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_buffer" 'Get video buffer g_intVideoBuffer = ReadInteger( args, i, i+1 ) if g_intVideoBuffer = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_width" 'Get video width g_intVideoWidth = ReadInteger( args, i, i+1 ) if g_intVideoWidth = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_height" 'Get video height g_intVideoHeight = ReadInteger( args, i, i+1 ) if g_intVideoHeight = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_framerate" 'Get video framerate g_intVideoFramerate = ReadFloat( args, i, i+1 ) if g_intVideoFramerate = -1 then ParseParameters = false exit function end if g_intVideoFramerate = 1000 * g_intVideoFramerate i = i + 1 case "-v_keydist" 'Get video keyframe distance g_intVideoKeydist = ReadFloat( args, i, i+1 ) if g_intVideoKeydist = -1 then ParseParameters = false exit function end if g_intVideoKeydist = 1000 * g_intVideoKeydist i = i + 1 case "-v_quality" 'Get video crispness (CBR) or quality (VBR) g_intVideoQuality = ReadInteger( args, i, i+1 ) if g_intVideoQuality = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_qp" 'Get video quantizer parameter (VBR) g_intVideoQP = ReadFloat( args, i, i+1 ) if g_intVideoQP = -1 then ParseParameters = false exit function end if g_intVideoQP = Round(g_intVideoQP*2)/2 if g_intVideoQP < 1.0 or g_intVideoQP > 31.0 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_peakbitrate" 'Get video peakbitrate size g_intVideoPeakBitrate = ReadInteger( args, i, i+1 ) if g_intVideoPeakBitrate = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_peakbuffer" 'Get video peakbuffer size g_intVideoPeakBuffer = ReadInteger( args, i, i+1 ) if g_intVideoPeakBuffer = -1 then ParseParameters = false exit function end if i = i + 1 case "-v_complexity" 'Get video complexity setting on codec 0-5 scale, but give v_performance priority if (g_intVideoPerformance = -1) then g_intVideoPerformance = ReadInteger( args, i, i+1 ) * 20 if g_intVideoPerformance <> 0 and g_intVideoPerformance <> 20 and g_intVideoPerformance <> 40 and g_intVideoPerformance <> 60 and g_intVideoPerformance <> 80 and g_intVideoPerformance <> 100 then ParseParameters = false exit function end if end if i = i + 1 case "-v_performance" 'Get video complexity setting on WME9 0-100 scale g_intVideoPerformance = ReadInteger( args, i, i+1 ) if g_intVideoPerformance <> 0 and g_intVideoPerformance <> 20 and g_intVideoPerformance <> 40 and g_intVideoPerformance <> 60 and g_intVideoPerformance <> 80 and g_intVideoPerformance <> 100 then ParseParameters = false exit function end if i = i + 1 case "-v_preproc" 'Get video preprocess setting g_intVideoPreprocess = ReadInteger( args, i, i+1 ) if g_intVideoPreprocess = -1 or g_intVideoPreprocess > 18 then OutputInfo "Invalid preproc value: " & args(i+1) ParseParameters = false exit function end if i = i + 1 case "-pixelformat" ' Get pixelformat. g_strPixelFormat = ReadString( args, i, i+1 ) if g_strPixelFormat = "" then ParseParameters = false exit function end if i = i + 1 case "-pixelratio" ' Get pixelformat. g_intPixelAspectRatioX = ReadInteger( args, i, i+1 ) g_intPixelAspectRatioY = ReadInteger( args, i, i+2 ) if g_intPixelAspectRatioX = -1 or g_intPixelAspectRatioY = -1 then ParseParameters = false exit function end if i = i + 2 case "-v_clip" ' Get clipping values. g_intClipLeft = ReadInteger( args, i, i+1 ) g_intClipTop = ReadInteger( args, i, i+2 ) g_intClipRight = ReadInteger( args, i, i+3 ) g_intClipBottom = ReadInteger( args, i, i+4 ) if g_intClipLeft = -1 or g_intClipTop = -1 or g_intClipRight = -1 or g_intClipBottom = -1 then ParseParameters = false exit function end if i = i + 4 case "-v_profile" ' Get video device conformance value g_strVideoDevConf = ReadString( args, i, i+1 ) g_strVideoDevConf = UCase( g_strVideoDevConf ) if g_strVideoDevConf = "SIMPLE" then g_strVideoDevConf = "SP" if g_strVideoDevConf = "MAIN" then g_strVideoDevConf = "MP" if g_strVideoDevConf = "ADVANCED" then g_strVideoDevConf = "AP" ' Translate old pre-VC1 Complex Profile to Advanced Profile if g_strVideoDevConf = "CP" then g_strVideoDevConf = "AP" if g_strVideoDevConf = "" then ParseParameters = false exit function end if i = i + 1 ' Parse advanced WMV settings case "-v_compopt" g_intVideoCompOpt = ReadInteger( args, i, i+1 ) if g_intVideoCompOpt < 0 or g_intVideoCompOpt > 2 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_denoise" g_intVideoDenoise = ReadInteger( args, i, i+1 ) if g_intVideoDenoise < 0 or g_intVideoDenoise > 5 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_dquantoption" g_intVideoDquantOption = ReadInteger( args, i, i+1 ) if g_intVideoDquantOption < 0 or g_intVideoDquantOption > 3 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_dquantstrength" g_intVideoDquantStrength = ReadInteger( args, i, i+1 ) if g_intVideoDquantStrength < 0 or g_intVideoDquantStrength > 4 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_bdeltaqp" g_intVideoBDeltaQP = ReadInteger( args, i, i+1 ) if g_intVideoBDeltaQP < 0 or g_intVideoBDeltaQP > 31 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_loopfilter" g_intVideoLoopfilter = ReadInteger( args, i, i+1 ) if g_intVideoLoopfilter < 0 or g_intVideoLoopfilter > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_median" g_intVideoMedian = ReadInteger( args, i, i+1 ) if g_intVideoMedian < 0 or g_intVideoMedian > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_edgeremoval" g_intVideoEdgeRemoval = ReadInteger( args, i, i+1 ) if g_intVideoEdgeRemoval < 0 or g_intVideoEdgeRemoval > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_threadaffinity" g_intVideoThreadAffinity = ReadInteger( args, i, i+1 ) if g_intVideoThreadAffinity < 0 or g_intVideoThreadAffinity > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_numthreads" g_intVideoNumThreads = ReadInteger( args, i, i+1 ) if g_intVideoNumThreads <> 1 and g_intVideoNumThreads <> 2 and g_intVideoNumThreads <> 4 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_rangeredux" intVideoRangeReduxYR = ReadInteger( args, i, i+1 ) intVideoRangeReduxYE = ReadInteger( args, i, i+2 ) intVideoRangeReduxCR = ReadInteger( args, i, i+3 ) intVideoRangeReduxCE = ReadInteger( args, i, i+4 ) if intVideoRangeReduxYR < 0 or intVideoRangeReduxYR > 8 or intVideoRangeReduxYE < 0 or intVideoRangeReduxYE > 8 or intVideoRangeReduxCR < 0 or intVideoRangeReduxCR > 8 or intVideoRangeReduxCE < 0 or intVideoRangeReduxCE > 8 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if 'Convert into hexadecimal 0x0Y0y0C0c format g_intVideoRangeRedux = intVideoRangeReduxYR * 16777216 + intVideoRangeReduxYE * 65536 + intVideoRangeReduxCR * 256 + intVideoRangeReduxCE i = i + 4 case "-v_overlap" g_intVideoOverlap = ReadInteger( args, i, i+1 ) if g_intVideoOverlap < 0 or g_intVideoOverlap > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_scaling" g_intVideoScaling = ReadInteger( args, i, i+1 ) if g_intVideoScaling < 0 or g_intVideoScaling > 2 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_lookahead" g_intVideoLookahead = ReadInteger( args, i, i+1 ) if g_intVideoLookahead < 0 or g_intVideoLookahead > 16 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_lrc" g_intVideoLookaheadRC = ReadInteger( args, i, i+1 ) if g_intVideoLookaheadRC < 0 or g_intVideoLookaheadRC > 150 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_mbmodecost" g_intVideoMBModeCost = ReadInteger( args, i, i+1 ) if g_intVideoMBModeCost < 0 or g_intVideoMBModeCost > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_mmatch" g_intVideoMMatch = ReadInteger( args, i, i+1 ) if g_intVideoMMatch < 0 or g_intVideoMMatch > 2 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if g_intVideoMMatch = g_intVideoMMatch - 1 i = i + 1 case "-v_mslevel" g_intVideoMSLevel = ReadInteger( args, i, i+1 ) if g_intVideoMSLevel < 0 or g_intVideoMSLevel > 4 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_msrange" g_intVideoMSRange = ReadInteger( args, i, i+1 ) if g_intVideoMSRange < 0 or g_intVideoMSRange > 4 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if g_intVideoMSRange = g_intVideoMSRange - 1 i = i + 1 case "-v_mvcoding" g_intVideoMVCoding = ReadInteger( args, i, i+1 ) if g_intVideoMVCoding < 0 or g_intVideoMVCoding > 3 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_mvcost" g_intVideoMVCost = ReadInteger( args, i, i+1 ) if g_intVideoMVCost < 0 or g_intVideoMVCost > 1 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_bframedist" g_intVideoBFrameDist = ReadInteger( args, i, i+1 ) if g_intVideoBFrameDist < 0 or g_intVideoBFrameDist > 7 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_percopt" g_intVideoPercOpt = ReadInteger( args, i, i+1 ) if g_intVideoPercOpt < 0 or g_intVideoPercOpt > 23 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if ' Disallow usage of old dquant which might create illegal bitstreams if g_intVideoPercOpt = 1 then g_intVideoPercOpt = 4 end if OutputInfo "Warning: -v_percopt option has been deprecated and replaced with -v_adz." OutputInfo " See help listing for more details." i = i + 1 case "-v_adz" if g_intVideoPercOpt = -128 then g_intVideoPercOpt = ReadInteger( args, i, i+1 ) if g_intVideoPercOpt < 0 or g_intVideoPercOpt > 20 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if if g_intVideoPercOpt > 0 then g_intVideoPercOpt = g_intVideoPercOpt + 3 end if end if i = i + 1 case "-v_type" g_intVideoType = ReadInteger( args, i, i+1 ) if g_intVideoType < 0 or g_intVideoType > 4 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_codedwidth" g_intVideoCodedWidth = ReadInteger( args, i, i+1 ) if g_intVideoCodedWidth < 32 or g_intVideoCodedWidth > 8192 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_codedheight" g_intVideoCodedHeight = ReadInteger( args, i, i+1 ) if g_intVideoCodedHeight < 32 or g_intVideoCodedHeight > 8192 then OutputInfo "Invalid range for parameter " & args(i) ParseParameters = false exit function end if i = i + 1 case "-v_preset" ' Get video preset g_strVideoPreset = ReadString( args, i, i+1 ) g_strVideoPreset = LCase( g_strVideoPreset ) if g_strVideoPreset = "" or ( g_strVideoPreset <> "fast" and g_strVideoPreset <> "good" and g_strVideoPreset <> "better" and g_strVideoPreset <> "best" and g_strVideoPreset <> "insane" ) then OutputInfo "Invalid preset name used. Available presets are: fast, good, better, best, insane." ParseParameters = false exit function end if select case g_strVideoPreset case "fast" ' Complexity = 2 / Lookahead = 16 / Loopfilter = On / Overlap = On / B frames = 1 if g_intVideoPerformance = -1 then g_intVideoPerformance = 40 if g_intVideoLookahead = -128 then g_intVideoLookahead = 16 if g_intVideoLoopfilter = -128 then g_intVideoLoopfilter = 1 if g_intVideoOverlap = -128 then g_intVideoOverlap = 1 if g_intVideoBFrameDist = -128 then g_intVideoBFrameDist = 1 case "good" ' Complexity = 3 / Lookahead = 16 / Loopfilter = On / B frames = 1 if g_intVideoPerformance = -1 then g_intVideoPerformance = 60 if g_intVideoLookahead = -128 then g_intVideoLookahead = 16 if g_intVideoLoopfilter = -128 then g_intVideoLoopfilter = 1 if g_intVideoBFrameDist = -128 then g_intVideoBFrameDist = 1 case "better" ' Complexity = 3 / Lookahead = 16 / Loopfilter = On / B frames = 1 / MS Level = Integer Chroma / MS Range = Auto if g_intVideoPerformance = -1 then g_intVideoPerformance = 60 if g_intVideoLookahead = -128 then g_intVideoLookahead = 16 if g_intVideoLoopfilter = -128 then g_intVideoLoopfilter = 1 if g_intVideoBFrameDist = -128 then g_intVideoBFrameDist = 1 if g_intVideoMSLevel = -128 then g_intVideoMSLevel = 1 if g_intVideoMSRange = -128 then g_intVideoMSRange = -1 case "best" ' Complexity = 5 / Lookahead = 16 / Loopfilter = On / B frames = 1 / MS Range = Auto if g_intVideoPerformance = -1 then g_intVideoPerformance = 100 if g_intVideoLookahead = -128 then g_intVideoLookahead = 16 if g_intVideoLoopfilter = -128 then g_intVideoLoopfilter = 1 if g_intVideoBFrameDist = -128 then g_intVideoBFrameDist = 1 if g_intVideoMSRange = -128 then g_intVideoMSRange = -1 case "insane" 'Complexity = 4 / Lookahead = 16 / Loopfilter = On / B frames = 1 / MS Level = True Chroma / MS Range = Auto / Motion Match = Auto if g_intVideoPerformance = -1 then g_intVideoPerformance = 80 if g_intVideoLookahead = -128 then g_intVideoLookahead = 16 if g_intVideoLoopfilter = -128 then g_intVideoLoopfilter = 1 if g_intVideoBFrameDist = -128 then g_intVideoBFrameDist = 1 if g_intVideoMSLevel = -128 then g_intVideoMSLevel = 2 if g_intVideoMSRange = -128 then g_intVideoMSRange = -1 if g_intVideoMMatch = -128 then g_intVideoMMatch = -1 end select i = i + 1 ' Parse all output related stuff case "-output" ' Get output file name. g_strOutput = ReadString( args, i, i+1 ) if g_strOutput = "" then ParseParameters = false exit function end if i = i + 1 case "-outputstring" ' Read in the string that is to be appended to output file name g_strOutputString = ReadString( args, i, i+1 ) if g_strOutputString = "" then ParseParameters = false exit function end if i = i + 1 case "-broadcast" ' Get broadcast port number. if i+1 <= UBound(args) and Left( args(i+1), 1 ) <> "-" then g_intBroadcast = ReadInteger( args, i, i+1 ) if g_intBroadcast = -1 then ParseParameters = false exit function end if i = i + 1 else g_intBroadcast = 8080 end if case "-push" ' Get push server, pub point and template name (optional) g_strPushServer = ReadString( args, i, i+1 ) g_strPublishingPoint = ReadString( args, i, i+2 ) if g_strPushServer = "" or g_strPublishingPoint = "" then ParseParameters = false exit function end if ' Check if template name is specified if i+1 <= UBound(args) and Left( args(i+3), 1 ) <> "-" then g_strPushTemplate = ReadString( args, i, i+3 ) i = i + 3 else i = i + 2 end if case "-time" ' Get the mark in time of the source file. g_intMarkInTime = ReadInteger( args, i, i+1 ) ' Get the markout time of the source file strMarkOutTime = ReadString( args, i, i+2 ) if strMarkOutTime <> "end" then g_intMarkOutTime = ConvertStringToInteger( strMarkOutTime ) else g_intMarkOutTime = 0 end if if g_intMarkInTime = -1 or g_intMarkOutTime = -1 then ParseParameters = false exit function end if i = i + 2 case "-duration" ' Get the duration of the encoding session. g_intDuration = ReadInteger( args, i, i+1 ) if g_intDuration = -1 then ParseParameters = false exit function end if i = i + 1 case "-silent" g_blnSilent = true case "-log" ' Print all output to log file g_strLogFile = ReadString( args, i, i+1 ) if g_strLogFile <> "" then on error resume next g_strLogFile = g_objFileSystem.GetAbsolutePathname(g_strLogFile) set g_objLogFile = g_objFileSystem.CreateTextFile( g_strLogFile, true) if IsNull(g_objLogFile) then OutputInfo "Invalid log file destination." ParseParameters = false exit function else g_blnLogOutput = true end if on error goto 0 else ParseParameters = false exit function end if i = i + 1 ' Parse all attributes case "-title" ' Get the title of the output file. g_strTitle = ReadString( args, i, i+1 ) i = i + 1 case "-author" ' Get the author of the output file. g_strAuthor = ReadString( args, i, i+1 ) i = i + 1 case "-album" ' Get the album of the output file. g_strAlbum = ReadString( args, i, i+1 ) i = i + 1 case "-trackno" ' Get the track number of the output file. g_intTrackNo = ReadString( args, i, i+1 ) i = i + 1 case "-year" ' Get the year of the output file. g_strYear = ReadString( args, i, i+1 ) i = i + 1 case "-genre" ' Get the genre of the output file. g_strGenre = ReadString( args, i, i+1 ) i = i + 1 case "-copyright" ' Get the copyright information of the output file. g_strCopyright = ReadString( args, i, i+1 ) i = i + 1 case "-description" ' Get the descrption of the output file. g_strDescription = ReadString( args, i, i+1 ) i = i + 1 case "-rating" ' Get the rating of the output file. g_strRating = ReadString( args, i, i+1 ) i = i + 1 case "-saveprofile" ' Get the profile file name to be saved. g_strProfileSave = ReadString( args, i, i+1 ) if g_strProfileSave = "" then ParseParameters = false exit function end if i = i + 1 case "-loadprofile" ' Get the profile file name to be loaded. g_strProfileLoad = ReadString( args, i, i+1 ) if g_strProfileLoad = "" then ParseParameters = false exit function end if i = i + 1 case "-verbose" ' Get the verbose mode. g_intVerbose = ReadInteger( args, i, i+1 ) if g_intVerbose = -1 then ParseParameters = false exit function end if i = i + 1 case "-s_config" ' Save the WEU configuration file strSaveToCfgFile = ReadString( args, i, i+1 ) if strSaveToCfgFile = "" then ParseParameters = false exit function end if i = i + 1 case "-config" if strLoadFromCfgFile = "" then ParseParameters = false exit function end if i = i + 1 case "-maxpacket" g_intMaxPacketSize = ReadInteger( args, i, i+1 ) if g_intMaxPacketSize = -1 then ParseParameters = false exit function end if i = i + 1 case "-minpacket" g_intMinPacketSize = ReadInteger( args, i, i+1 ) if g_intMinPacketSize = -1 then ParseParameters = false exit function end if i = i + 1 case else ' Show an error information for unrecognized parameter. OutputInfo "Invalid parameter: " & args(i) ParseParameters = false exit function end select next if strSaveToCfgFile <> "" then strSaveToCfgFile = g_objFileSystem.GetAbsolutePathName( strSaveToCfgFile ) ' Add extension if necessary if Right( LCase( strSaveToCfgFile ), 4 ) <> ".weu" then strSaveToCfgFile = strSaveToCfgFile & ".weu" end if CreateOutputFolder( g_objFileSystem.GetParentFolderName( strSaveToCfgFile ) ) set objTextFile = g_objFileSystem.OpenTextFile( strSaveToCfgFile, 2, True ) objTextFile.Write( strArgumentsQuoted ) objTextFile.close end if ParseParameters = true end function ' Show help information of this program. function ShowHelp() OutputInfo g_strProductName OutputInfo g_strProductCopyright OutputInfo "" OutputInfo "" OutputInfo "Encode from files or devices to Windows Media files or streams. Supported" OutputInfo "source file formats are .wmv, .wma, .asf, .avi, .wav, .mpg, .mp3, .bmp," OutputInfo ".jpg, and .avs." OutputInfo "" OutputInfo "" OutputInfo "Usage for I/O and statistics." OutputInfo "-----------------------------" OutputInfo "" OutputInfo "[-wme] " OutputInfo " Loads an existing Windows Media Encoder session file." OutputInfo "[-input] " OutputInfo " The file or directory to be encoded." OutputInfo " Specify a file or directory name. If you specify a directory, supported" OutputInfo " files in the directory will be encoded to the output directory, using" OutputInfo " the same encoding settings. " OutputInfo " Enclose file and directory names that have spaces in quotations." OutputInfo " For example: -input ""c:\my sample.wmv""" OutputInfo "[-output] " OutputInfo " The name of the output file or directory." OutputInfo " If the input is a file, -output corresponds to a file name. If the input" OutputInfo " is a directory, -output corresponds to a directory name." OutputInfo " The output directory will be created if it doesn't already exist." OutputInfo " An extension is automatically appended to output files." OutputInfo " (.wma for audio-only Windows Media files, and .wmv for video-only or" OutputInfo " audio and video Windows Media files.)" OutputInfo "[-devices]" OutputInfo " Lists audio and video capture devices." OutputInfo "[-adevice]