Windows Media Encoding Script
Windows Media™ Encoing Script
Windows Media™ Encoing Script
Other Articles Available
-------------
- Internet Radio Broadcast - Basic glossary
- Setting up SHOUTcast - Your first internet radio station
- Icecast server - basic setup
- Webcast Clients and Media Players
- A toolbar built to watch Internet TV
- Windows Media Family - Introduction
- Windows Media Encoder
-------------
Windows Media® Encoding Script is a useful command-line tool it can be used to convert live and recorded video and audio into Windows Media format files and / or streams, Suported formats are files with .wma, .wmv, .asf, .avi, .wav, .mpg, .mp3, .bmp, and .jpg file name extensions. You can also capture a live event directly from installed devices such as sound card, TV tuner or webcam. broadcast the encoded files or live event or save them for later use. Customizing a encoding session is easy using predefined profiles. With Windows Media® Encoding Script you have absolute control on devices, file format, size, compression type, codecs to be used, etc.
Windows Media Encoding Script is installed in the same folder as Windows Media Encoder. By default, the folder is located in Program Files\Windows Media Components\Encoder.
PROFILES:
A profile is a collection of command-line options adapted to the type of content being encoded, it is a combination of predefined parameters that include: connection speed, image and sound quality, codecs, etc.
When not profile is specified in a session de following options are applied by default:
If you do not specify a profile for a session, the following default options are used for the profile:
- Windows Media Audio 9 and Windows Media Video 9 codecs
- One-pass CBR encoding
- Frame rate of 30 fps
- Height and width that match the input source
- Stereo channel audio
- Sampling rate of 44,100 hertz (Hz)
- Buffer of 5,000 milliseconds
- Smoothness setting of 75
- Key frame distance of 10 seconds
- Audio and video bit rates of 64 and 250 kilobits per second (Kbps), respectively
You can override any of the default options by appending other command-line options to the command (examples below).
You can create a custom profile by specifying each of the options you want to use in the command and save it with the -saveprofile command that allows you to use it again. To load a profile just use the -loadprofile option. Profiles have a .prx file name extension.
Predefined profiles
Audio/Video:
- av20: Profile_AudioVideo_Modem_28K (actual rate: 20Kbps)
- av32: Profile_AudioVideo_Modem_56K (32 Kbps)
- av100: Profile_AudioVideo_LAN_100K (100 Kbps)
- av225: Profile_AudioVideo_LAN_256K (225 Kbps)
- av350: Profile_AudioVideo_LANDSL_384K (350 Kbps)
- av450: Profile_AudioVideo_LANDSL_768K (450 Kbps)
- av700: Profile_AudioVideo_NearBroadcast_700K (700 Kbps)
- av1400: Profile_AudioVideo_NearBroadcast_1400K (1400 Kbps)
- av350pal: Profile_AudioVideo_Broadband_PAL_384K (350 Kbps)
- av700pal: Profile_AudioVideo_NearBroadcast_PAL_700K (700 Kbps)
- av100_2p: Profile_AudioVideo_LAN_100K_2Pass (100 Kbps)
- av350_2p: Profile_AudioVideo_LANDSL_384K_2Pass (350 Kbps)
- av600vbr: Profile_AudioVideo_FilmVBR_600K (600 Kbps)
- avq97vbr: Profile_AudioVideo_FilmVBR_Quality97 (Quality 97)
Audio-only:
- a20_1: Profile_AudioOnly_FMRadioMono_28K (20 Kbps)
- a20_2: Profile_AudioOnly_FMRadioStereo_28K (20 Kbps)
- a32: Profile_AudioOnly_Modem_56K (32 Kbps)
- a48: Profile_AudioOnly_NearCDQuality_48K (48 Kbps)
- a64: Profile_AudioOnly_CDQuality_64K (64 Kbps)
- a96: Profile_AudioOnly_CDAudiophileQuality_96K (96 Kbps)
- a128: Profile_AudioOnly_CDAudiophileQuality_128K (128 Kbps)
Video-only:
- v20: Profile_VideoOnly_Modem_28K (20 Kbps)
- v32: Profile_VideoOnly_Modem_56K (32 Kbps)
Commands
|
Command
|
Arguments / Input
|
Use / Comments / Examples
|
| [-wme] | Windows Media Encoder session file | Loads an existing Windows Media Encoder session file |
| [-input] | file or directory name | The file or directory to be encoded. Specify a file or directory name. If you specify a directory, supported files in the directory will be encoded to the output directory, using the same encoding settings. NOTE: Enclose file and directory names that have spaces in quotations. For example: -input "c:\my sample.wmv" |
| [-adevice] | audio device number | The audio capture device to encode from |
| [-vdevice] | video device number | The video capture device to encode from. |
| -devices | list all available capture devices | |
| -duration | When encoding from devices, you must specify a duration | |
| [-output] | file or directory name | The name of the output file or directory. If the input is a file, -output corresponds to a file name. If the input is a directory, -output corresponds to a directory name. The output directory will be created if it doesn't already exist. An extension is automatically appended to output files. (.wma for audio-only Windows Media files, and .wmv for video-only or audio and video Windows Media files.) |
| [-outputstring] | string | The string to be attached to every output file name for directory mode. |
| [-broadcast] | port | Broadcasts via HTTP on the port specified. The default port is 8080. |
| [-time] | start time - end time | Specify the time segment (in msec) to be encoded. Use 'end' for <end time> if you want to encode to the end of the file. |
| [-silent] | Prevents statistics from being displayed after encoding is finished. | |
| [-config] | input configuration file | Inputs arguments from a configuration file. The default extension is .weu. Parameters in the file can be overridden by later arguments. |
| [-s_config] | output configuration file | Creates a configuration file. The file name extension .weu is appended automatically. |
| [-profile] | profile code | Specifies a predefined profile to use in the session. |
| [-loadprofile] | profile file name | Specifies a Windows Media Encoder or custom profile to use |
| [-a_codec] (1) | codec index | Audio codec to be used. Use -a_codecs to list available codecs. If you do not specify a codec, the Windows Media Audio 9 codec is used |
| [-a_codecs] | Lists all audio codecs that are installed on the encoding computer. | |
| [-a_content] (2) | mode | Audio content mode for the Windows Media Audio v9 Voice codec |
| [-a_contentedl] | file name | Specifies the places in audio content where music starts and ends. To do this, you must first create an optimization definition file. You must specify the Windows Media Audio Voice codec and -a_content 2 when when you use the -a_contentedl option. |
| [-a_folddown6to2] | surround mix - center mix - LFE | Fold-down coefficients for multichannel audio. Use whole numbers only. Values will be converted to negative numbers. Valid numbers are 0 to 144. For example, -a_folddown6to2 10 3 3 |
| [-a_formats] | Lists all audio formats for each codec. | |
| [-a_mode] (3) | mode_number | Audio encoding to be used. |
| [-a_peakbitrate] | peak bit rate | Specifies the peak bit rate in bits per second for peak bit rate-based VBR for audio. If not specified, the peak bit rate is 1.5 times the audio bit rate. |
| [-a_peakbuffer] | peak buffer | Buffer in msec for audio with peak bit rate-based VBR. If not specified, the default of 3000 msec is used. |
| [-a_setting] | setting |
Specifies the formats for audio setting. If you use quality-based VBR: -a_setting Qxx_SamplingRate_Channels. If you use the Windows Media Audio Professional 9: If you use the Windows Media Audio 9 Lossless codec: |
| [-audioonly] | Encodes the audio portion of the stream only. Video is ignored | |
| [-v_codec] (4) | codec index | Video codec to be used. Use -v_codecs to list available video codecs. |
| [-v_width] | width | Video frame width in pixels to be encoded. Default: Source video width. |
| [-v_height] | height | Video frame height in pixels to be encoded. Default: Source video height. |
| [-v_framerate] | rate | Video frame rate in floating point to be encoded. Default: 30 fps. |
| [-v_keydist] | time | Key frame distance in seconds for video. Default: 10 seconds. |
| [-v_preproc] (5) | filter number | Video preprocessing for certain input sources. (Only recommended for advanced users) |
| [-v_clip] | left - top - right - bottom | The region of the image (with respect to source) to be clipped/encoded. If the right is 0 or greater than width, it is ignored and re-assigned to width. If the bottom is 0 or greater than height, it is ignored and re-assigned to height. |
| [-v_mode] (6) | mode number | Determines the video encoding mode used in the session. Default is 0: 1-pass CBR |
| [-v_bitrate] | bit rate | Video bit rate in bits per second to be encoded. Default: 250000 bps. Set this to 0 for audio-only coding. |
| [-v_buffer] | buffer | Delay buffer in milliseconds for video. Default: 5000 msec. |
| [-v_quality] | quality | CBR: Quality/smoothness tradeoff. 0 to 100, 0 being the smoothest. Default: 75. Quality-based VBR: Image quality for the video. Encode video to the specified quality, regardless of bit rate. Default: 95 |
| [-v_peakbitrate] | peak bit rate | Peak bit rate in bits per second for peak bit rate-based VBR for video. If not specified, the peak bit rate is 1.5 times the video bit rate. |
| [-v_peakbuffer] | peak buffer | Buffer in msec for video, with peak bit rate-based VBR. If not specified, the default of 5000 msec is used. |
| [-v_performance] | performance | Use to adjust hardware performance settings. Possible values: 0, 20, 40, 60, 80, and 100, with 100 representing the highest quality. If you do not specify a value, codec defaults are used. |
| [-v_profile] | device conformance | Specifies the category of complexity of the encoded content. Use if you are targeting your content for playback on a hardware device other than a computer. Some hardware devices only support certain categories. (Refer to the documentation for your device for more information.) If you do not add the -v_profile option to a command, the correct complexity setting is selected automatically during encoding. Possible values are SP (Simple), MP (main), or CP (complex). |
| [-duration] | seconds | Amount of time in seconds to encode. Use when sourcing from devices. |
| [-saveprofile] | file name | Saves current settings to a file for later reuse. Default file name extension is .prx. |
| [-devices] | Lists audio and video capture devices. | |
| [-v_codecs] | Lists all video codecs. | |
| [-videoonly] | Encodes video stream only. | |
| [-pixelratio] | x y | Specifies the video pixel aspect ratio. |
| [-pixelformat] (7) | format | Specifies the video pixel format |
| [-maxpacket] | packet size | Specifies the maximum packet size in bytes. |
| [-minpacket] | packet size | Specifies the minimum packet size in bytes. |
| [-title] | string | Title of the content. Enclose strings with spaces in quotations. For example: -title "worldtvradio's test radio station" |
| [-author] | string | The maximum string length for each one is 255 |
| [-copyright] | string | |
| [-description] | string | |
| [-rating] | string |
Audio Codecs Index codes (1)
- WMA9STD: Windows Media Audio 9 (default).
- WMA9PRO: Windows Media Audio 9 Professional
- WMSP9: Windows Media Audio 9 Voice
- WMA9LSL: Windows Media Audio 9 Lossless; -a_mode 2 required
- PCM: No compression
Audio Content Modes (2)
- 0 = No special mode for the audio content (default)
- 1 = Speech mode
- 2 = Mixed (speech and music) mode (also requires -a_contentedl)
You must also specify the Windows Media Audio v9 Voice codec.
Audio Encoding Mode Numbers (3)
- 0: 1-pass CBR (default).
- 1: 2-pass CBR.
- 2: Quality-based VBR.
- 3: Bit rate-based VBR (two-pass).
- 4: Bit rate-based peak VBR (two-pass).
Video Codecs Index codes (4)
- WMV7: Windows Media Video 7.
- WMV8: Windows Media Video 8.1.
- WMV9: Windows Media Video 9 (default).
- WMS9: Windows Media Video Screen 9.
- MP41: ISO MPEG-4 Video v1
- UNCOMP: Full frames (uncompressed)
Video preprocessing filter numbers (5)
- 0: None (for progressive video input).
- 1: Deinterlace but preserve the size. For example, 640x480x30 interlace to 640x480x30 progressive.
- 2: Deinterlace but halve the size. For example, 640x480x30 interlace to 320x240x30 progressive.
- 3: Deinterlace, halve the size, and double the frame rate.
For example, 640x480x30 interlace to 320x240x60 progressive. - 4: Deinterlace, halve vertical size, and double frame rate.
For example, 320x480x30 interlace to 320x240x60 progressive. - 5: Inverse telecine from 30fps to 24fps.
- 6: Inverse telecine - First field is top field with AA telecine pattern.
- 7: Inverse telecine - First field is top field with BB telecine pattern.
- 8: Inverse telecine - First field is top field with BC telecine pattern.
- 9: Inverse telecine - First field is top field with CD telecine pattern.
- 10:Inverse telecine - First field is top field with DD telecine pattern.
- 11:Inverse telecine - First field is bottom field with AA telecine pattern.
- 12:Inverse telecine - First field is bottom field with BB telecine
pattern. - 13:Inverse telecine - First field is bottom field with BC telecine
pattern. - 14:Inverse telecine - First field is bottom field with CD telecine
pattern. - 15:Inverse telecine - First field is bottom field with DD telecine
pattern. - 16:Interlaced encoding.
- 17:Interlaced encoding - First field is top field.
- 18:Interlaced encoding - First field is bottom field.
Default: 0: None.
Video encoding mode numbers (6)
- 0: 1-pass CBR (default).
- 1: 2-pass CBR.
- 2: Quality-based VBR.
- 3: Bit rate-based VBR (two-pass).
- 4: Peak bit rate-based VBR (two-pass).
Available video format values (7)
- I420
- IYUV
- RGB24
- RGB32
- RGB555
- RGB565
- RGB8
- UYVY
- YUY2
- YV12
- YVU9
- YVYU
Examples
As usual, most default values should be enough to satisfy user requirements, however, Windows Media Encoding Script gives you total control on your stream. Novice users can start testing using a predefined profile, advanced users, on the other hand, can start from scratch, in both cases is good idea to save your progress to a profile for posterior use.
Here we add some real use examples, but feel free to test by yourself, only you decide which configuration is adequate for your preferences.
To start open a DOS window:
- Select Start - Run on the task bar
- Type cmd [enter]
- Type cd Program Files\Windows Media Components\Encoder [enter] (NOTE: this is the default folder, you must locate it first if you installed Windows Media encoder in a different folder)
To use Windows Media Encoder Script you must always use Microsoft Script Host (cscript.exe) then Windows Media Encoder script (wmcmd.vbs) then commands and values:
cscript.exe wmcmd.vbs –input C:\My-clips\yourfile.avi –output C:\newfolder-coded\yourfile.wmv –v_mode 0 –v_quality 40
In the example a file called yourfile.avi is compressed to a new folder / file called yourfile.wmv (Windows Media video Format) using a video mode 0 (1-pass CBR) and a video quality of 40
Note: You can use as many arguments as required just use space between them.
To broadcast a live event use:
cscript.exe wmcmd.vbs -adevice 1 -vdevice 1 –broadcast 8080 –duration 600
In this case port 8080 is used to broadcast a live event taked from audio device 1 and video device 1 with a duration of 10 minutes
Note 1 : To list available audio and video devices available use the -adevice and -vdevice options.
Note 2 : To broadcast a live event duration ALWAYS must be specified
Using predefined profiles:
cscript.exe wmcmd.vbs –input C:\your-clips\yourfile.avi -output C:\your-clips-coded\yourfile.wmv -profile av700
In this example, encoded file will have a video quality near to 700 kbps
Using user defined profiles:
cscript.exe wmcmd.vbs –input C:\your-clips\yourfile.avi -output C:\your-clips-coded\yourfile.wmv -loadprofile C:\profiles\400kbps_peakVBR.prx
In this case a profile called: 400kbps_peakVBR.prx is loaded and used to encode the file.
Technorati Tags: