DVD-to-Creative Zen Conversion Tutorial (WMV)

If you’ve seen my previous post about encoding your DVD rips to Xvid with MeGUI than the battle for WMV conversion is 90% done. This post replaces the “Encoding with MeGUI” section of that guide. Encoding to WMV will utilize the same AviSynth script that we created there and that’s where this guide begins.

Windows Media Encoder going forward will be referred to as WME.

Preparation
Windows Media Encoder
Windows Media Player 11 (if you haven’t already upgraded)

If you don’t want to install Windows Media Player 11, you’ll still need the upgraded codecs that come bundled with it. You can download a standalone distribution here.
Windows Media 11 Format Runtime

WMCmd.vbs is a very small file that is included in the WME download and in fact the command-line version of WME. Officially, WME does not accept AviSynth scripts as input. However, a very generous Microsoft employee has (legally) taken it upon himself to “hack” this file to do so. Grab the file here. After you’ve done that, go to the install path of WME and find WMCmd.vbs that’s already there. Rename it anyway that you want – just don’t delete it. Then replace it with the hacked file.

Yay. We’re on our way.

Procedure
We’re going to create a batch file…well…because it’s easier than typing all of the command-line arguments directly into a non-point ‘n’ click world. It allows for easier entry and editing of said arguments. Start by opening up Notepad or your favorite plain text editor. Then copy and paste the following:

“C:\WINDOWS\system32\CScript.exe” “C:\…\WMCmd.vbs” -input “C:\…\my-script.avs” -output “C:\…\my-video.wmv” -v_codec wmv9 -v_mode 0 -v_buffer 5000 -v_bitrate 500000 -v_keydist 30 -v_quality 10 -v_performance 20 -pixelformat yv12 -v_profile sp -a_codec wmastd -a_setting 96_44_2 -a_mode 0

A few things to consider about all of that:

1. The path to WMCmd.vbs is relative because you could’ve installed WME wherever you wanted to so you’ll have to fill that in. The same goes for the path to your script and your output file.
2. -v_bitrate is video bit rate in bits/second. Don’t be too liberal here. I would stay in the range of 300 kbps to 700 kbps.
3. -a_setting is audio parameters – example 96_44_2 is 96 kbps, 44.1 kHz, 2-channel stereo. All of these can vary if you wish but again I wouldn’t stray too far off.

Save the text file and give it a bat file extension, foregoing the usual txt extension.

Got it? Good. We move on.

Before we dive in to command-line stuff, let’s make it easy to start up a command-line window for WME quickly and efficiently. Open up the folder where WME was installed and then open up a second window and navigate to the C:\Windows\system32 folder. In that second folder hit the letter ‘C’ on your keyboard and scroll down until you find cmd.exe. Right-click on it and select Copy. Then switch to the first window, right-click on an empty space and select Paste. Close the second window. In the first window, right-click and drag cmd.exe to your Desktop. On the context menu that appears, select Create Shortcuts Here. Double-click your new shiny shortcut.

My God we’re good. :-)

To call up our batch file for WME all that we have to do is type in the full path location and file name of the batch file itself.

Click Enter and watch video conversion magic happen right before your eyes. When the encoding is finished you will have a WMV file that will seamlessly and quickly sync to your Zen.

DVD-to-Zune Conversion

Disclaimer – The process of using DVDFab HD Decrypter will not be covered here to avoid legal issues. :-)

Software
DVDFab HD Decrypter
DGMPGDec
AviSynth
AviSynth plugin – dgdecode.dll (included with DGMPGDec)
AviSynth plugin – nicaudio
VirtualDubMOD
Windows Media Encoder
Windows Media Encoder Command Line Script Utility

Procedure
Install everything above and reboot your PC about 9 times. :-) Of course, the first thing you want to do is “backup” your legally purchased DVD to your hard drive. I use one of two different apps depending on the DVD. Sony’s ARcoSS protection found on newer Sony releases can choke DVD Decrypter as it’s no longer being developed.
After the DVD rip has finished, launch DGIndex from the DGMPGDec download. Open the folder where the rip is located and identify the larger VOB files. This part will require some trial-and-error, especially if the DVD’s special features were also backed up. In my example below the movie-only content, excluding special features and menus, is the VOB’s that are circled.

Select the VOB’s and drag-and-drop them into DGIndex. Hit F6 on your keyboard. The movie will begin playing and you will see an information window attached to the right side of the main window. What’s most important here is Frame Size, Aspect Ratio, Frame Rate, Video Type, and Frame Type. Write all of this down or memorize it. After a couple of minutes, hit ESC on your keyboard.

In DGIndex’s main window, pull down the Audio menu and select Demux All Tracks unless you are absolutely certain you know which one you want to use, in which case select Demux Tracks and then Select Tracks. Next, pull down the Video menu and select Field Operation. Here we’ll reference what we found earlier. If the Video Type and Frame Rate are Film and Progressive, we’ll select Forced Film. This will be typical for standard-issue Hollywood DVD releases. Alternative findings will be on episodic TV show DVD’s, where sometimes the Frame Rate will be 29.97, Video Type will be Video, and Frame Type will be Interlaced. Frame Size will not change in order to comply with NTSC standards. Actually, all of this is to comply with the NTSC. Anywho…I digress. Next, pull down the File menu and select Save Project. Give the D2V file a name and a location and a-way we go! DGIndex will scan the entire movie in just a few minutes. When it’s done close DGIndex. You now have a D2V file.

Next, you’ll need an AviSynth script (AVS). Open a new Notepad file and save it as “my_movie.avs” without the quote marks. You can name it anything you’d like. Your AVS will look like an uncompressed AVI to Windows Media Encoder but to you and me it’s just a text file created in Notepad. A sample AVS will look like this:

loadplugin(“c:\..dgdecode.dll”)
loadplugin(“c:\..nicaudio.dll”)
v=mpeg2source(“c:\..my_movie.d2v”).lanczosresize(320,240)
a=nicac3source(“c:\..my_movie.ac3″,2).ssrc(44100)
audiodub(v,a)

This is as basic as it gets. The script above – provided you put in the correct paths to your D2V and AC3 files – will produce a passable WMV for your Zune. AviSynth is a fruitful landscape. There are a ton of filters to enhance your results i.e. sharpening filters, color correction, etc. There is little that AviSynth cannot do, but the learning curve is steep. I will not go through all of that now. Check out http://www.avisynth.org/mediawiki/Main_Page

Test your script. Open in either Windows Media Player, VirtualDubMOD, or Media Player Classic. If all is well, it will play the movie at a 320×240 resolution. If you get an error, take note. AviSynth is very good about telling you exactly which line and column of the script the error occurs in. Usually, it’s just a spelling or syntax error.

Now it’s time to create a batch file. This is an optional step, but I find that using a batch file makes it alot easier to layout and edit your command-line arguments before letting the encoder loose on it. Open another new Notepad file and save it as “batch_file.bat” without the quote marks. Again, you can name it whatever you want to. Take from the example below.

cscript wmcmd.vbs -input e:\scripts\my_movie.avs -a_codec wmastd -a_setting 48_44_2 -a_mode 0 -v_codec wmv9 -v_bitrate 500000 -v_buffer 5000 -v_mode 0 -v_complexity 2 -output e:\test\video\my_movie.wmv

The command-line interface is invoked with “cscript” and the encoder is invoked with “wmcmd.vbs”. If these two files are not in the same directory then you’ll need to provide the full path to each. But as I remember they are both together after a normal installation of the encoder; typically C:\Program Files\Windows Media Components\Encoder. Everything else in the batch file can be in any order. Notice that the INPUT file is our AVS, not the DVD VOB’s. “-v_” indicates a video stream argument. “-a_” indicates an audio stream argument. The “-a_setting” argument variables are bitrate_samplingrate_channels; in our example that would be a bitrate of 48kbps, a sampling frequency of 44.1 kHz, and stereo (2 channels). The “-v_bitrate” parameter is another that you can alter for desired results. The best balance between quality and battery life is anywhere between 400000 and 800000; notated as bits per second. After the parameters are set, save the changes (CTRL-S), open a DOS box (cmd.exe) and navigate to the Windows Media Encoder folder (usually C:\Program Files\Windows Media Components\Encoder). Now just simply invoke your batch file by typing the full path and filename of the batch file. Windows Media Encoder will begin reading your batch file and invoke the encoding process. If you get an error, it’s most likely due to an incorrect path to a file somewhere, either in the AVS or the batch file. If the AVS plays fine in Media Player then look at your batch file and double-check all the arguments and paths.

Just remember to change directory paths to your particular system. The examples are paths on my machine. I’ll be in the ZuneScene forums or VideoHelp forums for additional help.