• Categories

  • Archive of Posts

  • Advertisements

Mencoder Proper – Encoding Quest Over

For the past few weeks I have been posting about “My Encoding Quest”.    The genesis of the posts was my desire to re-encode HD MKV files into native Media Center DVR-MS files while retaining the same video and audio quality.  Well the quest is over and the result is a program that I wrote called MencoderProper.  This post is a history of everything that led to this point while a cross post over on EngadgetHD will show you the best way to use it.

I originally had a multi-step manual process that used Transcode360 and MKV2VOB.  I would convert the MKV to an MPG using MKV2VOB, then play the MPG in Media Center using Transcode360, and  finally converting the Transcode360 cache file to DVR-MS using VideoRedo.  If it sounds complicated its because it is complicated.  At the end of the day though it worked.

After updating to Windows 7 I found that Transcode360 was no longer working and therefore neither was my conversion process.  I had always intended to find a better way of converting my MKV’s and now I finally had the proper motivation.

After doing some research into trying to get Transcode360 to work, I realized that I really did not care for the streaming capability of Transcode360.  I only wanted the encoding portion which Transcode360 offloaded to Mencoder.  The key that made Transcode360 work where other options had failed was that it had programmatic way to determine the best Mencoder command line options for the particular video you were trying to encode.  Luckily for all of us, Transcode360 is open source and the code is available.

So inspiration hit and I thought, “Why don’t I just modify the portion of the code that calls Mencoder for my purposes.”  It was also during this time that Ben Drawbaugh from EngadgetHD posted his tutorial explaining how to get MKV TV shows into Media Center.  I read the instructions and tried to use the same steps for my MKV files instead of going down the longer road of writing my own code.  Unfortunately it did not work and created files with incorrect aspect ratios.

After that failure MencoderProper was born.  I wrote a wrapper application that calls Mencoder properly (hence the name).  Originally it was built to use from the command line but the fates aligned and Ben and I actually started working together and merged both of our projects.  Now MencoderProper is built into and distributed as part of latest release of DVRMS Toolbox ( and I finally have the 1-click conversion process I have always wanted.  Point DVRMSToolbox at any MKV and it will convert it to DVR-MS at full resolution with the correct aspect ration and perfect AC3 5.1 surround sound.  No problems with extender support and you have full rewind and fast forward capability.

Ben has a post on EngadgetHD with a great “how-to” guide.  Go read it and enjoy what I think is the solution for converting MKV’s for Media Center.  If readers are interested in the details of MencoderProper I will write the post.  Also please provide any feedback or issues that you find in the comments section.  Now that this is finally out I can get back to a regular posting schedule.


My Encoding Quest

common (image) aspect ratio found in video.Image via Wikipedia

Over the past few days I have been on a crazy encoding quest. I use to have a kind of convoluted process of converting MKV movies into DVR-MS files but I was inspired by Ben Drawbaugh’s post on EngadgetHD to simplify the process. The simple thought has turned into a journey that I did not expect.

So first let me explain the old process. After I had the MKV file (fill in the blank) I would do an initial conversion using MKV2VOB. That conversion would give me an MPG file that maintained the same HD video resolution and a 5.1 AC3 audio track. A number of MKV files have DTS audio so the AC3 audio track was very welcome. For some reason this file would not open in VideoRedo so I did another conversion using Transcode360. I would just play the file via Media Center using Transcode360 and the file would be encoded into a proper MPEG2 HD file with AC3 audio. The last step would be to open the file from the Transcode360 cache folder in VideoRedo and perform a quickstream fix to end up with an HD DVR-MS file with 5.1 audio. Whew! Not only is that too many steps but I have also had trouble installing Transcode360 under Windows 7.

After reading Ben’s post about converting MKV’s using DVRMS Toolbox I thought I could just use the same process for my movies. Well, I was wrong. The two sticking points for this working are aspect ratio and audio. The process that Ben layed out was specific to TV shows which all have the same 16:9 (1.78:1) aspect ratio. Movies on the other hand usually have either a 1.85:1 or 2.39:1 aspect ratio. TV shows also have AC3 audio by default while movies could be either AC3 or DTS so the audio track would need to be converted.

As I started to dig deeper I realized that both processes use MEncoder to do all the heavy lifting. The difference was really in the way MEncoder was used. Transcode360 always worked because it analyzed the movie file to make sure apsect ratio was preserved and AC3 audio was used.

My next thought was that I could just reuse the C# code that is part of Transcode360 and create a simple command line program that would use the Transcode360 logic and in the end be used in conjunction with DVRMS Toolbox. I personally do not care for the transcode on the fly functionality as much as I care about getting the movie file in the format that I want and need which in this case is DVR-MS so that I can have a smooth fast-fwd / rewind experience.

I am probably about half way through coding my new C# application and it has been a lot of fun. It has been awhile since I did any coding so it’s nice to get back to it. When the application is complete then you will be able to just run the app at the command line and pass in the path to the file that you want to encode like this: c:\mencoderproper.exe “c:\test.mkv”

The result will be a file named test.mpg with full HD video in the proper resolution with AC3 audio. Once I have this working I can integrated it with DVR-MS and have a process that will watch a TO CONVERT folder. Once a file is place in that folder it will be re-encoded and then converted to a DVR-MS file using todvrms.exe. The resulting file will be moved to the home server and added to the movie collection.

As soon as I have everything working I will post everything for download.

Reblog this post [with Zemanta]