• 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.


40 Responses

  1. Personally im new to media center and was just looking into a solution like this. Before i was just converting to wmvhd which took ages. Thanks for the work, this quest is very much appreciated, and believe me you are not alone :p

  2. I saw the engadget post and was wondering why its doing the optimal resolution calculation? Its changing the resolutions on my movies slightly and it seems unneeded (because it is making the image a bit worse…. stretched out)

  3. Without that the aspect ratio for any movie greater than 1.84:1 was incorrect. Check out this post:


    If you have a sample file of what you are trying to convert then shoot me an email and I will see what is going on.

  4. Thanks for all your hard work, I have been struggling a bit with this in the last few months myself and had been looking forward to your solution. I will start using it and let you know if I have any problems…

  5. my email is jagowar at gmail dot com

    send me an email and ill send you a sample I tested against…. 2.35:1 1080p file.

  6. Hi,

    I am using DVRMSToolbox and am attempting to convert from the m2ts file to the dvr-ms format using MencoderProper, but I keep getting the following error from MencoderProper:

    Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
    at MediaInfoLib.GetMediaInfo..ctor()
    at MencoderProper.FileSource.GetMediaInfo()
    at MencoderProper.MEncoderTranscoder..ctor(String InputFile, String OutputFile)
    at MencoderProper.Program.Main(String[] args)

    Is this something that I am doing wrong, or is there a bug that can be fixed?

  7. George,

    This is a bug that I have just fixed. It was reported over on the DVRMS Toolbox forum. I am testing it now. If you send me your email address I would love the help in testing.

  8. Sure thing. My address is afterwords at gmail.com.

  9. Am thrilled with the program's potential. Have you been able to get it working on Win 7 x64?

  10. Still no luck for me on the m2ts file. Even with the new version you had me download. I'm not sure if it's Win7 x64 or something else. I don't have any .mkv files to try.

  11. Andres, this is super exciting and the process does seem to work well. However, I've been testing on my 1080P content, and the transcoding process has compressed the video too much for my liking. Is there a way in DVRMSToolbox for me to adjust the MencoderProper settings for the MPEG2 compression?
    Awesome tool

  12. @Adam

    Try changing the value of "HighResThreshold" in the MencoderProper.config file. It is set to 2073600 by default which is (1920x1080 = 2073600). Any resolution higher than that will down convert. If for some reason MediaInfo is reporting a higher resolution then you need to up the value in "HighResThreshold". Try that and let me know.

  13. Andres, the source vertical resolution is 1080 (or less), but now I'm curious why the process scales the transcoded output to 1086? Anyway, thanks to the pointer on the config file. I'm now playing around with average/max bitrate options in there. I'll report back my findings. Thanks again!

  14. Andres, this is great. One issue I'm having is that my first movie conversion (Wall-E) converted just fine, but won't play on the extender or on the media center. I'm doing the conversion on a WHS – so don't know if that is a potential issue. Anything I should look at specifically?

  15. @David

    What file format are you coming from?

  16. Andres – it's a MKV.

  17. I have just finished convert a couple of my dvd's to h264 avi's but am wondering if i can convert them to dvr-ms without gaining size or losing quality – is this what your new tool does or have i misunderstood?

  18. @zeph The tool was built primarily with MKV's in mind but it does work for most other file types/codecs.

    When going from MKV to DVR-MS it does retain quality but the resulting file size is usually slightly larger but not by much.

  19. Im getting a error on encoderproper with subtitles.


    C:\Program Files\DVRMSToolbox\Applications\MencoderProper>MencoderProper.exe "D:
    \Torrents_Finished\Series\Medium – s01e01 – Pilot.avi" "D:\DTBTemp\Medium – s01e
    01 – Pilot.mpg"
    [MencoderProper] Need some help running Mencoder? Well that's what I'm here for
    [MencoderProper] You entered [D:\Torrents_Finished\Series\Medium – s01e01 – Pilo
    t.avi] as the file you would like to convert and [D:\DTBTemp\Medium – s01e01 – P
    ilot.mpg] as the destination file.
    [MencoderProper] Initializing……..
    [MencoderProper] Loading config file located at: C:\Program Files\DVRMSToolbox\A
    [MencoderProper] Config file loaded.
    [MencoderProper] Initialization complete.
    [MencoderProper] Obtaining input file location from parameter passed in and sett
    ing output to parameter passed in.
    [MencoderProper] Found subtitle file. Will hardsub with [D:\Torrents_Finished\S
    eries\Medium – s01e01 – Pilot.srt] subtitle file.
    [MencoderProper] Getting MediaInfo for [D:\Torrents_Finished\Series\Medium – s01
    e01 – Pilot.avi]
    [MencoderProper] Video Height: 352
    [MencoderProper] Video Width: 624
    [MencoderProper] Number of Audio Streams: 1
    [MencoderProper] Audio Aspect Ratio: 1.773
    [MencoderProper] Audio Type: MPA2L3
    [MencoderProper] Audio Bitrate: 48000
    [MencoderProper] Audio Channels: 2

    Unhandled Exception: System.FormatException: Input string was not in a correct f
    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffe
    r& number, NumberFormatInfo info, Boolean parseDecimal)
    at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo in
    at System.Convert.ToInt32(String value)
    at MencoderProper.FileSource.GetMediaInfo()
    at MencoderProper.FileSource..ctor(String inputFile, String outputFile)
    at MencoderProper.MEncoderTranscoder..ctor(String InputFile, String OutputFil
    at MencoderProper.Program.Main(String[] args)

    C:\Program Files\DVRMSToolbox\Applications\MencoderProper>



  20. Are you on a 64bit machine?

  21. No. Windows 7 RTM x32.

  22. Hey Andres, any developments with mencoder proper working on x64 Windows 7?

  23. Id also like to see if there is an update… I was running the 32 bit fine but since I got the final copy I figured it was time to upgrade (not remembering this issue).

  24. Andres,
    I Found a solution that allows me to use mencoderproper on my Vista x64 machine. A post on babgvant.com suggested using corflags.exe (a component of the Microsoft .Net SDK) to force mencoderproper.exe to run in x86. Worked like a charm.


  25. Thanks a lot for that info. I will write it up and share it with the readers. Awesome find!!

  26. Hi, sounds like you and Ben have been doing so great work!

    How about converting to WTV files? As they are the native format for Win7 now.

    I'd like to be able to one click convert MKV's with AC3 / DTS / AAC audio tracks to .WTV files with AC3 audio.

    I could then play them on my XBOX 360 extender with full FFWD functionality.



  27. Like most others on this posting, I am really excited about this tool, but I keep experiencing distortin in the final video, dring the MKV to MPG process artifacts are introduced into my video, and it does not matter if the video is 1080p or 720p or how much the video is compressed before hand.Are there any hints to ensure that the final video has almost the same quality as the source video?Or is anyone else experiencing the same issue, what I'm seeing looks like a distortion-jitter across the entire screen almost every second or so?

  28. I have not experienced the artifacts and issues that you are describing. Do you have a small sample file that you could share? If not I have one and can share with you so we can compare results and go from there.

  29. I dont have one handy, but can generate one this evening, how would be the best way to send it to you?Note: I was able to see it in 2 diff movies (I've only tried 2 diff movies so far)

  30. I have converted A LOT of movies with this and it works great for me so I hope we can get it working for you as well.I have a sample file uploaded to Google Docs. Send me your email address and I will share it with you. If I get a chance I will upload my result file too.

  31. I got the sample, I see that looks great, prior to the conversion.I will attemt to convert it ASAP.

  32. Andres, thanks soo much for your time, I have uploaded 2 sample files, both continue to display artifacts after mpg conversion.Note I have adjusted the resolution of the videos so that they no longer report that the resolition will be auto adjusted by mencoder.1080p samplehttps://docs.google.com/leaf?id=0B8sdjFpb92SRYmU3NmY1MzUtNDQ3Yi00MGI5LThlNzMtNDRlOGRmNGY5YjY0&hl=en720p samplehttps://docs.google.com/leaf?id=0B8sdjFpb92SRNTVmZjcxMmMtMjJkNy00N2Q1LTg2NzUtMmE1NmFhN2ZjODcz&hl=enDoes anything in these samples look 'off' to you, when I play them back they look fine as MKV's.

  33. Do you use RIPBOT 264 to transcode to mkv, if so, are there setting I should look out for?

  34. I've also uploaded the original m2ts file that was used to generate my mkv's from.Sample m2ts file:https://docs.google.com/leaf?id=0B8sdjFpb92SROGQ5OGNkZWYtMTUzOS00ZmFjLWJjMTQtZTRkNTIzN2Q5YTk2&hl=en

  35. You can go straight from m2ts to dvr-ms with MencoderProper and DVRMS Toolbox. Have you tried it? I can upload my DVRMS Toolbox profile for you to try.

  36. Sure, I can give that a shot.

  37. I just tried converting the m2ts file, and recieved the same results, full-screen jitter.Have you had a chance to try and convert the sample files I provided?Thanks

  38. Andres,I apologize for all these questions, but I noticed that when I converted my file the log shows one series of events, and when i convert yours it shows a slightly different series of events.Log snippit from your sample file:==========================================================================Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec familySelected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)==========================================================================Writing header…INITV: 0.200, 0.158, fps: 23.976VDec: vo config request – 1280 x 688 (preferred colorspace: Planar YV12)VDec: using Planar YV12 as output csp (no 0)Movie-Aspect is 1.86:1 – prescaling to correct movie aspect.videocodec: libavcodec (1280×688 fourcc=3267706d [mpg2])INITV: 0.242, 0.200, fps: 23.976Flushing video frames.Writing index…Log snippit from my sample file:==========================================================================Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec familySelected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)==========================================================================VDec: vo config request – 1280 x 688 (preferred colorspace: Planar YV12)VDec: using Planar YV12 as output csp (no 0)Movie-Aspect is 1.86:1 – prescaling to correct movie aspect.videocodec: libavcodec (1280×688 fourcc=3267706d [mpg2])Writing header…INITV: 0.200, 0.158, fps: 23.976Flushing video frames.Writing index…thanks again fo your time.

  39. Andres, can you provide me with any other information regarding what tool you use to create your source files with, I have been using tsMuxeR and Rip-Bot 264, have you been using different tool for extracting the main movie files from your source media?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: