'***************************************************************************** ' ' Microsoft Windows Media ' Copyright (C) Microsoft Corporation. All rights reserved. ' ' FileName: WMCMD.VBS ' ' Abstract: Windows Media Command Line Script Utility ' Use Cscript.exe wmcmd.vbs /? for Help ' '***************************************************************************** Option Explicit ' Check to see if script is run within cscript host. if instr( LCase(WScript.Fullname),"cscript.exe" ) = 0 then WshShell.Popup "This script must be run using cscript.exe from a command window." , 0 , "Windows Media Encoder Command Script" , 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 WMA9STD_FOURCC dim WMA9PRO_FOURCC dim WMA9LSL_FOURCC dim WMSPEECH_FOURCC dim PCM_FOURCC dim WMV7_FOURCC dim WMV8_FOURCC dim WMV9_FOURCC dim WMS9_FOURCC dim MP41_FOURCC dim UNCOMP_FOURCC dim WMA9STD dim WMA9PRO dim WMA9LSL dim WMSPEECH dim PCM dim WMV7 dim WMV8 dim WMV9 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 WMA9STD_FOURCC = 353 WMA9PRO_FOURCC = 354 WMA9LSL_FOURCC = 355 WMSPEECH_FOURCC = 10 PCM_FOURCC = 0 WMV7_FOURCC = 827739479 WMV8_FOURCC = 844516695 WMV9_FOURCC = 861293911 WMS9_FOURCC = 844321613 MP41_FOURCC = 1395937357 UNCOMP_FOURCC = 0 WMA9STD = "WMA9STD" WMA9PRO = "WMA9PRO" WMA9LSL = "WMA9LSL" WMSPEECH = "WMSP9" PCM = "PCM" WMV7 = "WMV7" WMV8 = "WMV8" WMV9 = "WMV9" 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_strInput dim g_strOutput dim g_strOutputString dim g_intSessionType dim g_strProfile dim g_strTitle dim g_strAuthor dim g_strCopyright dim g_strDescription dim g_strRating dim g_strAlbum dim g_strWMEFile dim g_strProfileSave dim g_strProfileLoad 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_objEncoder dim g_objSourceGroup dim g_objAudioSource dim g_objVideoSource dim g_objProfile dim g_objFileSystem 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_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_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 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_strInput = "" g_strOutput = "" g_strOutputString = "" g_intSessionType = WMENC_CONTENT_ONE_AUDIO g_strProfile = "" g_strTitle = "" g_strAuthor = "" g_strCopyright = "" g_strDescription = "" g_strRating = "" g_strAlbum = "" g_strWMEFile = "" g_strProfileSave = "" g_strProfileLoad = "" g_strProfile = "" 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_blnEncoderStarted = false g_blnEncoderStopped = false g_blnEndPreProcess = false g_blnDevice = false g_intErrorCode = 0 g_intRunningSource = 0 g_blnAudioOnly = false g_blnVideoOnly = 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_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_intClipLeft = -1 g_intClipRight = -1 g_intClipTop = -1 g_intClipBottom = -1 g_blnCreateCustomProfile = true ' Create an encoder object. set g_objEncoder = WScript.CreateObject( "WMEncEng.WMEncoder" ) WScript.ConnectObject g_objEncoder, "Encoder_" ' Setup call back events set g_objFileSystem = WScript.CreateObject( "Scripting.FileSystemObject" ) 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 end if WScript.Quit() ' Output information function OutputInfo( strInfo ) WScript.Echo( strInfo ) 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 ' Parse the parameters of this program. function ParseParameters( args ) dim strMarkOutTime dim strArguments dim strSaveToCfgFile dim strLoadFromCfgFile dim strCfgFileArguments dim colStrConfigArgs dim objTextFile for i=0 to UBound(args) if args(i) = "-s_config" then i = i + 1 else strArguments = strArguments & args(i) & " " end if if args(i) = "-config" then strLoadFromCfgFile = ReadString( args, i, i+1 ) if strLoadFromCfgFile = "" then ParseParameters = false exit function end if i = i + 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 colStrConfigArgs = Split( strCfgFileArguments ) if ParseParameters( colStrConfigArgs ) = false then ParseParameters = false exit function end if end if next ' OutputInfo "Args = " & strArguments 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 case "-help?" ' Being up the encoder util chm ShowHelpChm() 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 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_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 and g_strAudioCodec <> WMA9PRO and g_strAudioCodec <> WMA9LSL 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 <> WMS9 and g_strVideoCodec <> MP41 and g_strVideoCodec <> UNCOMP 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 = ReadInteger( 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 bufferwindow size g_intVideoQuality = ReadInteger( args, i, i+1 ) if g_intVideoQuality = -1 then 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_performance" 'Get video complexity setting 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 = "" then ParseParameters = false exit function end if 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 ' Parse all attributes case "-title" ' Get the title of the output file. g_strTitle = ReadString( args, i, i+1 ) if g_strTitle = "" then ParseParameters = false exit function end if i = i + 1 case "-author" ' Get the author of the output file. g_strAuthor = ReadString( args, i, i+1 ) if g_strAuthor = "" then ParseParameters = false exit function end if i = i + 1 case "-album" ' Get the album of the output file. g_strAlbum = ReadString( args, i, i+1 ) if g_strAlbum = "" then ParseParameters = false exit function end if i = i + 1 case "-copyright" ' Get the copyright information of the output file. g_strCopyright = ReadString( args, i, i+1 ) if g_strCopyright = "" then ParseParameters = false exit function end if i = i + 1 case "-description" ' Get the descrption of the output file. g_strDescription = ReadString( args, i, i+1 ) if g_strDescription = "" then ParseParameters = false exit function end if i = i + 1 case "-rating" ' Get the rating of the output file. g_strRating = ReadString( args, i, i+1 ) if g_strRating = "" then ParseParameters = false exit function end if 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( strArguments ) objTextFile.close end if ParseParameters = true end function ' Show help information of this program. function ShowHelp() 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 "and .jpg." OutputInfo "" OutputInfo "" OutputInfo "Usage for I/O and statistics." 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 "[-adevice]