in

andy vt's tools & blog

automating lazy

This Blog

Syndication

andy vt's blog

September 2009 - Posts

  • Getting Lossless Audio off the PC

    While video quality is important, I find that it's the audio that really transforms a good movie into an immersive experience.  As challenging as it can be to get flawless video playback working on the HTPC, enabling proper lossless multi-channel audio playback adds another layer of difficultly into the mix.  In this guide we will discuss the different options available for getting full fidelity HD audio off your PC and into the Audio/Video receiver (AVR).

    As you've probably guessed the crux of this guide is about converting compressed lossless audio formats into LPCM (Linear Pulse Code Modulation) for output over the HDMI or analog connections to an AVR.  So if your PC isn't setup to support one of these connections stop reading and fix it; take your time, we'll be here when you're done.  Also if you're using an application like Power DVD or Total Media Theater for all your media needs, while you probably need to reexamine that choice (unless the player is being launched per media item from another application like Media Center or Sage), you've already covered.  Both applications support lossless multi-channel LPCM output without much effort, just configure the audio settings to 6 or 8 channel (depending on your setup) and it's done.

    With that out of the way let's talk codecs and containers.

    Most of the retail lossless audio content is encoded as Dolby TrueHD or DTS-MA but some (mostly older files) contain LPCM audio tracks.  LPCM is the easiest codec to deal with because there's nothing to do, it's already raw lossless audio just waiting for transport.  You can leave it in the M2TS or remux to MKV, either will work fine with the ffdshow or MPC-HC audio decoder.  The only real problem is that because it's raw audio, the file uses a lot more space than a compressed format would.  Now if you have unlimited storage that inefficiency isn't an issue, but personally I don't like to waste even when there's plenty. 

    Dolby TrueHD is the most popular audio codec that I've seen, but unfortunately the options are more limited compared to LPCM.  As far as I know ffdshow is the only free/open source software (OSS) DirectShow decoder for TrueHD, but even it requires using newer a version than the "stable" build we installed last week.  I've done some testing and ffdshow seems to work great provided you can find a splitter that actually presents the full TrueHD stream. 

    Going through the different M2TS and MKV splitter/demux filters on my HTPC with GraphStudio we can see that support is limited.

    ArcSoft Mpeg Demux (M2TS): TrueHD is presented and will connect to ffdshow, but audio type isn't created correctly (note only two channels are available) so no audio plays

    Haali Splitter (MKV): Even though we can clearly see that the TrueHD track is contained in the file, no audio track presented.  Haali clearly doesn't support TrueHD at all.

    Haali Splitter (M2TS): Same result as when using Haali to split a MKV.


    MPC-HC Mpeg Splitter (M2TS): Audio track is presented as AC-3, it's unclear if ffdshow is decoding HD or extracting core AC-3 for playback.  I tried to build ffdshow locally so I could attach the debugger and see how the audio is handled, but wasn't able to get it to compile. 

    SageTV Beta Demuxer (M2TS): TrueHD is presented, connects to ffdshow and plays perfectly. (Note that the subtype GUID displayed matches the TrueHD media type from wmcodec.h in the Windows Platform SDK, which is exactly what should be there)

    As you can see, TrueHD can work under the right conditions with the right container.  Taking a longer term look, the MKV ecosystem is half way there; MKVToolnix will mux TrueHD into mkv, and it's detected properly in MediaInfo, so it will just take some effort from Haali to get it working properly for DirectShow players.

    Where TrueHD is a little complex, DTS-MA is blocking.  There are no free/OSS decoders available that can decode with full fidelity. Even in the professional space only the ArcSoft decoder supports 7.1 DTS-MA, but as it doesn't remember channel settings you will only get two channels of lossless audio.  There is some good news for the lazy/patient, because ffdshow can connect to the DTS-MA and decode the core so you'll at least get multi-channel audio with that option.

    Now that we've covered the problems, let's discuss one solution.  Before we get to that it is important to remember that lossless audio is lossless audio; as long as we can guarantee that each step in our process is bit perfect it doesn't matter what codec is used while the audio sits on the hard disc.  I know it seems pretty obvious when you think about it, but for those who've been around for a while it can be a difficult to get past the "all transcoding is lossy" mindset; at least it was for me.

    Simply put, for everything but TrueHD, I think the best solution is to convert the lossless audio track to FLAC.  For those who don't know, FLAC or "Free Lossless Audio Codec" is (as you can probably guess from the name) a lossless open source audio codec.  The main benefit to FLAC is that because the specification and tools are open source, and it's been around for a while, there is a mature environment where several excellent options for converting, decoding (madFLAC, MPC-HC audio decoder, ffdshow, etc) are available, and it all works perfectly in MKV so we can leverage a single splitter and not have to worry about potential issues with merit and the different m2ts splitters.  The approach for TrueHD is a bit more nuanced, if you're a SageTV user and don't mind running beta bits either keeping the original M2TS or remuxing (w/ TSMuxer) a streamlined version with just the A/V tracks you want is a viable option.  On the other hand if you're a Media Center user, M2TS can work on Vista with the right splitter but 7MC uses Media Foundation instead of DirectShow for M2TS playback, and at least in my [limited] testing the experience was pretty bad (i.e. VC-1 files don't play video), and there is no lossless audio support. 

    Before we get started you'll need a copy of eac3to and MKVToolnix.  We're only going to use eac3to to handle audio conversion and video extraction right now, but it has several other features that should be noted.  The most useful is the ability to work on Blue-ray and HD-DVD folder structures directly, instead of the M2TS approach we're going to use in the walk through.  Usage is the same, but when run on a disc structure eac3to can also extract the chapter information which can also be muxed into the MKV later.  The other feature we're not going to use now but worth pointing out, is subtitle extraction; unfortunately eac3to doesn't do all the work here and only a .sup is produced, but five/ten minutes with SupRip (not to be confused with the myriad of other subtitle OCR software with similar names) will turn the images into a very useful SRT file which can also be muxed into the MKV or left on the file system if your player supports external subtitles.

    For the command line challenged, there are GUIs for eac3to available, the more popular ones are linked from the eac3to page on Doom9.  For the rest of us go ahead and open up a command window (type "cmd" into the start search box) and hit enter.

    Then "CD" (type "cd \process" at the prompt and hit enter) to your process directory, input the path to eac3to (the easiest way on Vista to get the full path is to hold down the shift key and right-click the exe and select "Copy as Path", then right-click the command window to paste it in; 7 users can just drag the exe from explorer into the command window), the path to the M2TS file that will be processed, and press "enter".

    As you can see, when eac3to is run directly on the file (or disc structure) without any arguments it just enumerates the streams that are contained.  The reason we do this is to tell it next which streams to extract and what to do with them.

    In this case we're just going to extract the video and HD audio streams, so we want to run the same command as before (press the up key to reload it at the prompt) but this time we want to add the stream number and the target format (i.e. 1: dtshdvideo.mkv 2: dtshdaudio.flac) before hitting the "enter" key.  It doesn't matter where you put the files (in this case they will end up in the folder we're running the tool from) but it's very important to get the extension right as that's how eac3to knows what format/container to use when extracting the stream.

    Where TrueHD and LPCM can be handled using OSS, bit-perfect decoders included with eac3to for our test a file with DTS-MA was purposely selected because it's the most complex.  Referring back to the screen shot, you'll notice that the "ArcSoft DTS Decoder" was used to decode the audio.  While eac3to will work with different decoders, the ArcSoft one is the only filter that supports 7.1 bit-perfect decoding. 

    If you have an HD PVR you're covered, the version of ArcSoft TMT that's included works great after updating to the 1.0.9.6 (or later) rev.  For everyone else I also tested with the trial rev of TMT3, and that works too.  So just include this a step to checking out the software; personally after years of using PowerDVD I think TMT provides a better BD playback experience so it's worth checking out anyway.  For those using Window 7, note that TMT2 (the version included with the HD PVR) is not compatible; so you'll want to install it on a virtual machine (or another box with XP or Vista) and copy the ArcSoft folder ("%ProgramFiles%\ArcSoft") over if you want to run eac3to natively. 

    The final step is to mux the A/V files into an MKV using mkvmerge, a tool included in MKVToolnix.  If you chose the installer an option for MKVMerge will be available from the programs menu, otherwise double click "mmg.exe" to run the tool. 

    After it opens either drag/drop the two files onto mkvmerge, or click "Add" to browse and select them.  I like to order the video stream first, and add a "Track Name" that describes the stream.  For audio tracks, it's also a good idea to set the correct language.  For those who use an HD200 extender, now is a good time to jump back to the eac3to window and extract or encode a 5.1 AC-3 stream that you should mux in as a secondary audio stream (the HD200 will only decode to stereo); order is important because while the HD200 supports stream switching, the PC doesn't without dragging out a mouse.  Make sure to change the "Output filename" before you "Start muxing".

    If you ran eac3to on a disc structure to extract chapters, or dumped the .sup and did the OCR already both can be added as tracks prior to muxing as well.

    Downloads:

    Optional:

    Posted Sep 28 2009, 10:00 AM by babgvant with no comments
    Filed under: ,
  • DVRMSToolbox 1.2.1.9 - Early Access Release 4

    This is an Early Access release.

    Version 1.2.1.9
    - Change MP4 muxer to GDCL filter for iPhone/iPod compatibility
    - Add ExtraData action for adding static context values by type using xml document (<root><data name="ForceStereo" type="bool" value="true"/></root>)
    - Add WMV to supported output types from ConvertVideoFile and DTBVideoEditor.  Default prx is cbrZune (supports AC3 btw), to use a different PRX in ConvertVideoFile ExtraData must be used with <root><data name="PrxPath" value="prxfile.prx"/></root>
    - Add "Convert For Zune (no commercials)" and "Convert for iPhone (no commercials)" profiles
    - PC support > < testing with numeric and string values
    - Add FWThrottle action to profiles created with DTBVideoEditor
    - Add AtomicParsely action, and AtomicParsely.exe
    - Refine status/completion for convertors
    - Fix a bug where an audio decoder is specified for a native audio format copy in VideoConvertor
    - VideoConvertor will prefer to use DSCutter with uncompressed samples
    - VideoConvertor replaces "MPC - Mpeg Splitter (Gabest)" with "MPC - Mpeg Source (Gabest)" as a preferred filter; if original behavior is desired use the CLISD instead
    - DTB will assume all SSL certs are valid when retrieving metadata
    - Fix filter connection issue using DSCutter with SBE file types
    - Update todvrms to 1.0.1.0
    - Add AttributeEnable and AVC1toH264 filters
    - ConvertVideoFile and DTBVideoEditor will calc resize value based on frame height/width when either is set to 0
    - PC support = != testing of numeric text values as numbers

     UPDATE: I think the x64 issue has been fixed, found two potential causes for the problem.  Let me know if it's still an issue.

    bin | source

  • Installing Ffdshow

    AntiPack was intended as a starting point in that it only includes high quality hardware accelerated codecs for the most popular A/V formats, but does not support everything.  If you need more, ffdshow should be next on your list.  It provides the most full featured software video and audio decoder of any OSS or free DirectShow filter; because of this when installed and configured properly it is an excellent complement to what we started earlier.  For me, the most important feature that ffdshow provides that isn't found anywhere else is DTS-MA support.  While only core (i.e. DTS) is supported because the underlying libdts/libca does not yet support full MA, ffdshow will connect to splitters that present the proper DTS-MA media type (like the beta SageTV demuxer) without needing to transcode or recontainer the content prior to playback. 

    I don't generally recommend ffdshow to those just looking "to make it work" because it requires some tweaking beyond installation to ensure good behavior.  Today we're going to walk through how to install it, and the basic configuration to make sure that it works they way you want.  Keep in mind this is just an installation guide, ffdshow has many capabilities that are beyond the scope of this article.

    This walk-through is based on the latest stable build of ffdshow tryouts (Beta 6), but there are much newer unofficial builds available; either way the installation process should be pretty much the same.

    I almost left out screen shots of the less interesting dialogs in the install to make this shorter, but opted to include everything for completeness. 

    Choose a language.

    Click "Next"

    Choose an install location and click "Next".  If you change it make sure you remember the folder, you'll need it later.

    VFW, or Video for Windows, is a media framework that predates DirectShow and as far as I know the only current use is for transcoding.  The other options are all more advanced features beyond the scope of this guide.  If you plan to use ffdshow for transcoding leave the box checked, otherwise uncheck the box and select "Next".

    Click "Next

    Here's where the install gets interesting.  This page is where we have the option to choose which codecs ffdshow will support. Don't worry, it's easy to reconfigure if you change your mind later.  Click the "Decode the following video formats with ffdshow" checkbox twice to clear all the selected video codecs, then walk through the list and specifically opt in on the codecs you want it to handle.  I use a combination of the modified MPC-HC video decoder in AntiPack and some professional filters for most of my video needs, so there isn't much here for me to select.

    You may need some of the more obscure codecs on the second page like MJPEG or CamStudio though.  If you'd prefer to select everything and use merit to control ffdshow that's also a viable approach, we will cover setting ffdshow's merit in a bit.

    I use the same opt in approach for audio as video, so click "Decode the following audio formats with ffdshow" twice to clear all the selections.

    While I'm not a big fan of the ffdshow video decoder (you probably guessed that already :)); the audio decoder is quite useful not only because it works, but also because it handles audio stream switching very well.  Because of this I enable most of the audio formats even though in some cases another filter (like AC3Filter) is my preferred filter for that type.  Note that DTS-MA is not on this list (or the audio decoder configuration dialog we'll look at later) if you want to decode DTS-MA core you must enalbe DTS.  Also note that while AC-3 and Dolby TrueHD are presented as separate options, AC3 must be enabled for TrueHD decoding support.

    And some more audio codecs, select what you want and click "Next".

    If you want to bitstream AC-3 or DTS select the appropriate box for S/PDIF passthrough and click "Next".

    I prefer to listen to audio in the native format so I disable the mixer.  If you'd prefer that ffdshow expand the audio, select the appropriate option for your setup and click "Next".

    Almost done, click "Install".

    Because we're going to change the merit for both filters which will require escalation, it's best to uncheck both "Run..." options.

    Should be easy enough to find the ffdshow configuration links on the start menu, right-click and select "Run as administrator".

    But when we do that it doesn't work because the paths in the shortcut aren't created correctly.  What this means for anyone running in a limited user context (Vista or 7 with UAC enabled) is that ffdshow is now installed with a ridiculous merit, and it's not immediately clear how to fix it.  To make matters worse, when the configuration dialogs are run normally from the start menu, merit control is allowed and the UI fails so gracefully that the failure is hidden from the user.  The only obvious way that I could find to discover the problem was to relaunch the dialog and check.

    Fortunately working around this issue is relatively easy.  By opening an escalated command prompt and typing "rundll32.exe "\Program Files\ffdshow\ffdshow.ax",configureAudio" the audio dialog will launch in the correct context enabling us to change the merit to more reasonable value.  To make it even easier, two cmd files can be downloaded with the command already included (if you changed the install directory here's where you'll want to remember).  Just right-click the correct file and select "Run as administrator" to launch.

    Let's start with the video decoder.  Run the cmd file, then select "DirectShow control" on the left.  Pull the merit slider from "ffdshow default" to a more appropriate value like "normal".  I use "unlikely" because I want ffdshow's video decoder to only provide coverage.

    And codec support is controlled from the "Codecs" page; run wild.  There is a lot more to the video decoder, including post processing for image quality.  This is only intended to be a quick install guide and walk through, so we'll leave that for another time.  Go ahead and click "OK" and let's move on to the audio decoder.

    After launching the audio decoder configuration dialog with the cmd file (remember to right-click and run as admin), browse to the DirectShow control screen and select a more reasonable merit.  Because I like the audio decoder, I go with "normal".

    Like the video decoder codec support is managed on the codecs page.  From here you have a lot of control, clicking on the "Decoder" column even lets you choose which OSS library will handle the format.

    If you've changed your mind since the install on how you want channel mapping to occur, browse over to the "Mixer" page.  If you opted to disable it, make sure you check the "Mixer" box at the top before leaving the page.

    The last screen we're going to look at is "Output". This page is where we can toggle between S/PDIF and PCM, control sample formats, and even have ffdshow encode PCM to AC-3 for bitstreaming (have to remember add this as an option the earlier article on multi-channel audio).  Click "OK" to save the settings and you're done.

  • Server Narcolepsy

    On a whim I shortened the system idle timeout to 15 min on my SageTV server the other day and almost immediately noticed an issue when using the HD200 for playback.  After pausing a show for 5 or 10 min to deal with a kid issue, I came back to find that the server had idled to sleep while I was away.

    Figuring this was a bug I contacted support, they were nice enough to let me know that Sage uses its own idle timer managed using the "power_management_idle_timeout" setting in the Sage.properties file.  I forgot to ask why they don't use the system timer and just call the Win32 API to reset it, but I expect that it's probably because Sage supports multiple OSs.

    The default value is 2 minutes (or 120000 milliseconds); I changed it to 10 minutes so hopefully that makes the issue go away.

    Posted Sep 19 2009, 11:48 AM by babgvant with no comments
    Filed under:
  • DG45ID

    I'd been meaning to do a full review of the DG45ID motherboard in my "extender" for a long time.  Finally got around to doing a full write up last week.  

    Check it out over at Missing Remote.

  • DVRMSToolbox 1.2.1.9 - Early Access Release 3

    This is an Early Access release.

    Version 1.2.1.9
    - Change MP4 muxer to GDCL filter for iPhone/iPod compatibility
    - Add ExtraData action for adding static context values by type using xml document (<root><data name="ForceStereo" type="bool" value="true"/></root>)
    - Add WMV to supported output types from ConvertVideoFile and DTBVideoEditor.  Default prx is cbrZune (supports AC3 btw), to use a different PRX in ConvertVideoFile ExtraData must be used with <root><data name="PrxPath" value="prxfile.prx"/></root>
    - Add "Convert For Zune (no commercials)" and "Convert for iPhone (no commercials)" profiles
    - PC support > < testing with numeric and string values
    - Add FWThrottle action to profiles created with DTBVideoEditor
    - Add AtomicParsely action, and AtomicParsely.exe
    - Refine status/completion for convertors
    - Fix a bug where an audio decoder is specified for a native audio format copy in VideoConvertor
    - VideoConvertor will prefer to use DSCutter with uncompressed samples
    - VideoConvertor replaces "MPC - Mpeg Splitter (Gabest)" with "MPC - Mpeg Source (Gabest)" as a preferred filter; if original behavior is desired use the CLISD instead
    - DTB will assume all SSL certs are valid when retrieving metadata
    - Fix filter connection issue using DSCutter with SBE file types
    - Update todvrms to 1.0.1.0
    - Add AttributeEnable and AVC1toH264 filters

    bin | source

  • 7-1

    After fighting with the ATI driver on Windows 7 for 2 weeks, I finally gave up.  Grabbed the wiz.bin and did a WHS restore back to Vista; now I can use standby and have the display work when it wakes up again.

    Honestly, I won't miss much. 

  • DVRMSToolbox 1.2.1.9 - Early Access Release 2

    This is an Early Access release.

    Version 1.2.1.9

    - Change MP4 muxer to GDCL filter for iPhone/iPod compatibility
    - Add ExtraData action for adding static context values by type using xml document (<root><data name="ForceStereo" type="bool" value="true"/></root>)
    - Add WMV to supported output types from ConvertVideoFile and DTBVideoEditor.  Default prx is cbrZune (supports AC3 btw), to use a different PRX in ConvertVideoFile ExtraData must be used with <root><data name="PrxPath" value="prxfile.prx"/></root>
    - Add "Convert For Zune (no commercials)" and "Convert for iPhone (no commercials)" profiles
    - PC support > < testing with numeric and string values
    - Add FWThrottle action to profiles created with DTBVideoEditor
    - Add AtomicParsely action, and AtomicParsely.exe
    - Refine status/completion for convertors
    - Fix a bug where an audio decoder is specified for a native audio format copy in VideoConvertor
    - VideoConvertor will prefer to use DSCutter with uncompressed samples
    - VideoConvertor replaces "MPC - Mpeg Splitter (Gabest)" with "MPC - Mpeg Source (Gabest)" as a preferred filter; if original behavior is desired use the CLISD instead
    - DTB will assume all SSL certs are valid when retrieving metadata

    bin | source

@2008 andy vt
Powered by Community Server (Non-Commercial Edition), by Telligent Systems