Converting AVIs for my Zune

Posted in General at 8:21 pm by jw

It’s been a while, a few things I need to update, but I’m going to do this one first because it will probably interest the most random people out there. Recently I got myself a new Zune so I could watch my DVR’d BSG episodes while on a treadmill trying to get fit. I love the device – it has a nice big screen (about twice the size of a comparable iPod), 80G of storage and a pretty slick interface. Sadly, the PC software leaves a little to be desired though.

In any case, the Zune can only play WMV and simple MP4 video. The PC software automatically converts a bunch of different file formats for you into something the Zune can play (ie WMV) but wouldn’t understand AVI files, particularly ones that use the XVid codec.

I figured it shouldn’t be too hard to find something that would do the conversion for me and a quick search of Google told me there were quite a few products there that promised to make everything easy and magically do the conversion for me. They mostly cost about $30, but if I was going to spend money I really wanted something that would fit all my personal criteria:

  • Zune native format – no second conversion by the Zune application after I’ve done my own conversions.
  • Batch encoding – I want to point it at a whole bunch of files and just let it go.
  • Low priority – I want to be able to run the conversion in the background and not have to fight with it when I want CPU power for something else.
  • Multithreaded – I have a dual core CPU. Why not use it?
  • MP4 format with H.264 encoding – why not use the best format the Zune supports?
  • Keep the original frame rate – there’s no point converting 25fps to 30fps or vice versa.
  • No black bars – if the original was 1.7:1 then just make another 1.7:1 video instead of putting black bars. The Zune can handle it.
  • Reduce to 320x? – may as well reduce the resolution to the Zune’s native display.
  • Able to cope with minor damage to the input files (some of my DVR’d files aren’t that good http://tabsmall.com/cialis-otc/)

Honestly, I didn’t think any of those were particularly much to ask from a conversion program. The later iPods support a very similar set of features to the Zune so I expected the conversion programs would easily do what I wanted. Sadly, it wasn’t to be. Here’s a list of the apps I tried and where I found their failings were:

Cucusoft’s Zune Video Converter

Not too bad a product, but wouldn’t let me set an automatic frame rate (defaulted to NTSC), and insisted on putting black bars at the top and bottom of letterboxes. Failed to handle any input file errors, and was no ability to set the priority to default to low.

Xilisoft’s Zune Video Converter

Seemed pretty good, but again no automatic frame rate detection. Setting the encoder to H.264 produced a file that wasn’t playable on the Zune and had to be converted a second time. Didn’t cope with any input file errors and there was no ability to set the priority to low.

Imtoo’s Zune Video Converter

This was exactly the same program as the Xilisoft one. Go figure.

PQDVD’s Zune Video Converter

Seemed the best of the bunch – handled input file errors with no problem but didn’t seem to want to remember the previous encoder settings so you had to go back and specify H.264 every time. There was no automatic frame rate detection either, and the priority (again) couldn’t be set to low.

Free iPod Video Converter

I had great hopes for this one – it automatically kept the frame rate for me and promised H.264 encoding. The wizard interface was a little clunky but livable. Videos converted played fine in the PC player and transferred without conversion to the Zune but just gave an error when I tried to play them.

Nero Recode

I actually own Nero 8, so I gave Nero Recode a try. It seemed to do very well when using the iPod profile but when I finally got to play it on the device, it had trimmed the video to the left side rather than letterboxing it. The trim controls were strangely complex so I just gave up.

Windows Media Encoder

Promised a lot, but didn’t really deliver. Figuring out how to rescale the video and keep the frame rate turned out to be close to impossible and would have left me making a new conversion profile for every different type of file. Not something I really wanted to do.

Various Doom9 Solutions

The hard-core converters were a bit of a disappointment. As I expected they all had a whole bunch of controls but none really seemed to work as well as even the basic commercial ones above. Made me kinda sad because Doom9 has previously been a great resource for ripping my DVDs to media files for playing on my PC!

So, disappointed with all of these offerings, I decided to sit down and try to use the Windows Media Encoder APIs to do the whole thing myself. After a few hours work with the SDK and Visual Studio 2005 (it crashes with 2008 – go figure), I had something actually encoding to a .wmv file, but I ended up running against the same problems I had with Windows Media Encoder – you needed to build the profile up from scratch for every variation in the input file which really made it more work than I wanted to put in right then.

Finally, I was looking at the freeware H.264 encoder (x264) and noticed it was on the same site as one of my favorite open source media players (VLC). Looking more into VLC I found out that it can also transcode files, and noticed that .mp4 was one of the outputs. From there, it was all a matter of figuring out the arcane command line incantation to get it to produce an mp4 that the Zune itself was happy to play. Finally it all worked out and I ended up with the attached 4NT script: makezune.btm

Works like a charm! Go go VLC.

Edit: I’ve been asked by a couple of people to write a version of the script file that runs in the regular XP/Vista command shell, so here it is. I even threw in a couple of comments to make life a little easier! makezune2.cmd

Edit #2: Note that this solution only works with the Zune v2.0 (4/8/80G) and not the original 30G Zunes which can only play .wmv files. To get those to work is probably going to involve some heavy tinkering with the Windows Media Encoder libraries.

Edit #3: So I put the time in to actually tinker with the Windows Media Encoder. After finding Alex Zambelli’s upgraded WMCmd.vbs (local link) script, it was a relatively simple matter of trial and error to find the parameters needed to make a file compatible with the Zune. The real problem was figuring out the scaling. Fortunately, some really ugly batch file scripting came to the rescue and the final product is in makezune3.cmd

Note: For any attached file, use right click, save link as… and then rename it to the proper name. To avoid issues with downloads of script files being prevented by Internet Explorer, I’ve actually stored everything as text files.

Tags: , , , ,


  1. Dorick Said:

    January 10, 2008 at 1:22 pm

    You’re my hero. Thank you for reporting on your findings. I ‘ve got this nice video iPod wasting away in my truck acting as MP3 storage.

    With this VLS solution I will now be able to quietly watch the hours at work fly by. =)

  2. Bo Said:

    January 15, 2008 at 5:01 pm

    Great post. What do I do with the script you wrote? I’m not very familiar with VLC. Any help would be appreciated.

  3. jw Said:

    January 15, 2008 at 8:47 pm

    I rewrote the script for regular windows, so just save it as “makezune2.cmd” somewhere on your computer (assuming you don’t want to use the 4NT version).

    Once you’ve done that, edit it so that VLC and OUTDIR point to the right places on your computer (wherever vlc.exe is and wherever you want the converted files dumped).

    After all that, you can just open a command prompt (Start/Run/cmd.exe), change to the folder of your video files and run “makezune2” and it should convert all the avi’s it finds. If you want to convert a particular file then just use “makezune2 filename” instead.

    If you need more help, post back or email me.

  4. Bo Said:

    January 16, 2008 at 7:28 am

    I got the conversion to work, but when I transfer the file to my Zune it takes about 30 minutes, so I think the Zune software is converting the mp4 again. Is this what it is supposed to do?

  5. jw Said:

    January 16, 2008 at 9:44 am

    Hmm… it shouldn’t try to reconvert it for one of the recent Zunes (4/8/80G), but not sure about the original ones. It’s possible that those might not support the same mp4 format that the recent releases did. I’ll do some research. Which Zune do you have?

    Edit: The original 30G Zunes can’t play .mp4 files. Give me some time and I’ll see if I can get VLC to convert to .wmv files that the original Zunes can play, if you like?

  6. jw Said:

    January 16, 2008 at 1:44 pm

    Ok – doing some research on VLC and .wmv files, it seems that it won’t work. You’ll probably have to do some work with Windows Media Encoder if you really want it to work for you on a 30G Zune (which I’m assuming is what you have). I’m sure there’s a way to autogenerate the profiles, but it just seemed like it was getting really hard when I was investigating.

  7. jb Said:

    January 16, 2008 at 2:37 pm


    I am a VLC developer.
    I think you are wrong, you can use VLC to encode to WMV.

    Use WMV2 as a video codec, WMA as an audio codec, and ASF as a muxer.

    Mail me if you succeed or fail 😀

  8. jw Said:

    January 16, 2008 at 5:44 pm

    Working on it. Using a video codec of WMV3 and audio of wma2 is transferring without conversion but causes the Zune to crash a few seconds into the video.

  9. jw Said:

    January 17, 2008 at 2:22 am

    Some work with VLC convinced me it was easier to just go directly to the Windows Media Encoder directly (which VLC does anyway for WMV3 if I recall correctly). Edit #3 above is the end result, and should work on the v1.0 Zunes (and works just fine on my 2.0 as well).

    Remember for that script to work you need to have the Windows Media Encoder installed (download from Microsoft at the link above).

  10. Bo Lollar Said:

    January 28, 2008 at 12:47 pm

    I tried your makezune3.cmd, but everytime I run it I get an error message “Microsoft (r) Console Based Script Host has encountered a problem and needs to close.” Error signature shows “AppName:cscript.exe AppVer: ModName:wmenceng.dll ModVer: Offset:0008ab56”. Do you have any ideas about this? Any help would be appreciated.

  11. jw Said:

    January 28, 2008 at 3:59 pm

    That’s a crash in windows media encoder. Try running the Windows Media Encoder GUI and see if it will convert the file manually? I know this is all a pain. 🙁

  12. Bo Lollar Said:

    January 29, 2008 at 12:59 pm

    Windows Media Encoder GUI converts manually without any problems. Any other suggestions? Sorry to keep bugging you.

  13. jw Said:

    January 29, 2008 at 8:35 pm

    I don’t mind being bugged about it – really want to make sure I can help someone else!

    Just checking – are you using the WMCmd.vbs script I linked or the one that comes with Windows Media Encoder? I think the one that comes with the Encoder is buggy and causes crashes, so make sure you either replace the WMCmd.vbs script in the encoder directory with the one I linked, or at the very least make sure the WMCmd.vbs script is the one that is being pointed to in the batch file.

    Any idea which line on the batch file is causing the issue? If you delete the “@echo off” from the top it will show the lines as it executes them.

  14. Lam Said:

    April 3, 2008 at 10:24 pm

    Wonderful information. Thank you very much for your effort and insight.

    One question: how to incorporate subtitle-track and audio-track via microsoft media encoder? I know how to do it with VLC via makezune2.cmd, but not sure how to do it via makezune3.cmd. Any suggestion?

  15. jw Said:

    April 6, 2008 at 1:46 am

    I’m not sure subtitles and extra audio tracks are even possible with a wmv file.

  16. jungle Said:

    May 8, 2009 at 11:55 am

    i recommend you daniusoft video converter~haha

  17. Ry Jones Said:

    July 10, 2009 at 12:56 pm

    The command scripts seem to be missing. Could you put them back, or email them to me?

  18. jw Said:

    July 10, 2009 at 10:13 pm

    Oops – they vanished when I upgraded my site. Back now. Sorry!