Carl’s Geek Notes

August 27, 2008

XmlNamespaceManager and overridden default XML namespace

Filed under: C#/.NET, Computers, Programming, Web Services, XML — Carl @ 12:22 pm

Issue: My XmlDocument.SelectNodes() or SelectSingleNode() wasn’t working correctly with the incoming XML. It was always returning null even when the element was specified.

Problem: If the XML has an overridden default XML namespace (i.e., the root node has an attribute xmlns=”urn:MyNamespace” in it), SelectNode is unable to properly resolve it.

Solution: Use an XmlNamespaceManager to give a prefix to the default namespace, like so:

string MyXML = "<?xml version=\"1.0\"?><MyElement xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"urn:MyNamespace\"><MySubElement>3</MySubElement></MyElement>";

// Create and load the XML document
XmlDocument MyDoc = new XmlDocument();
MyDoc.LoadXml(Response);

// Create a namespace manager with the XML document's name table
XmlNamespaceManager MyNamespaces = new XmlNamespaceManager(MyDoc.NameTable);

// Add namespaces for all prefixed xmlns declarations
MyNamespaces.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
MyNamespaces.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");

// Add the default namespace with a custom prefix
MyNamespaces.AddNamespace("MyNS", "urn:MyNamespace");

// Use the namespace manager to select the node
// Make sure that each element in the default namespace is prefixed with your custom prefix
// It is not sufficient to do MyNS:MyElement/MySubElement, both must be qualified!
XmlNode MyNode = MyDoc.SelectSingleNode("MyNS:MyElement/MyNS:MySubElement", MyNamespaces);

August 13, 2008

High-quality anamorphic video for iPod Classic

Filed under: Computers, Gadgets, iPod — Tags: — Carl @ 4:43 pm

Want to encode your DVDs in the highest possible quality for both your iPod and your computer screen?  Dissatisfied with having the 640-pixel width limit?  Discover the joys of encoding anamorphic videos for your iPod with Handbrake.

First, make sure you’re on the most recent version of Handbrake.  I used version 0.9.2, build 2008021900 for this.

Next, rip your DVD as an ISO with DVD Decrypter or similar.  Mount your ISO image and start Handbrake.  Browse to the VIDEO_TS directory on your DVD and select the appropriate title (the longest one is usually the main movie).

Make sure your destination file is .m4v–that seems to be more tag-compatible than .mov in iTunes.

Then, click on the preset for iPod High-Rez.  Ensure that the encoder is H.264 and audio is AAC.  Check the box for Insert iPod Atom.

Under the Picture Settings tab, check the Loose Anamorphic box.  Enter your width as 720.

Now, here’s the important part that is easy to overlook (and it only shows up as an error if you open the Activity Window after your encode and review it thoroughly).  Go to the Advanced tab.  Change the value for vbv-maxrate=1500 to vbv-maxrate=2500 to ensure that your video buffer keeps up with your desired framerate.

(The rest of these settings are optional, but I’ve had very good success with them.)

Under the Video tab, check 2-pass Encoding and Turbo first Pass.  Set Avg Bitrate (kbps) to 2500.  (I noticed some “stuttering”–a horizontal line scanning across the picture occasionally–at 2000 kbps but it disappeared at 2500 kbps.)

Under the Audio & Subtitles tab, set the Audio Quality Bitrate to 160 or less–I prefer 128 as I really don’t notice difference between AAC-encoded audio at 128 and 160.  Your mileage may vary, however.

Prepare to wait several hours for this to complete on a 2 hour movie (about 5 for both passes on my computer).  If you start one when you go to bed at night it will be probably be ready in the morning.

Why doesn’t this break the 640-pixel width limit?  Because you’re using anamorphic video, the same method that DVDs use to store 720 pixels of width in a 640-pixel grid.  Then the pixel aspect ratio stretches it to the appropriate width.

On videos that are enhanced for 16:9 display, you now have a video that will play on your iPod and will have 853 (or thereabouts) pixels of width once the anamorphic storage and pixel aspect ratio is taken into account.

(I believe this methodology is compatible with iPod Touch and iPhone, but I have no experience with that so I can neither confirm nor deny.  I’m fairly certain this does not work with a fifth-generation or 5.5G iPod.)

View additional properties for AD accounts

Filed under: Computers, Windows Administration — Carl @ 9:00 am

Need to find more information about an Active Directory account than is readily viewable in Active Directory Users and Computers, like last login time, last password change time, password expiration date, SID, GUID, and more? Download this handy utility:

http://www.computerperformance.co.uk/w2k3/utilities/acctinfo.htm

put it in %SYSTEMROOT%\system32, regsvr32 it, close & reopen ADUC, and look for the new tab for Additional Account Info. Very handy!

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.