Thursday, January 24, 2008

Microsoft Office Supports PDF on the Clipboard, And Why That is a Big Deal

For months, I've wanted to know whether Microsoft Office 2008 supported copying and pasting PDF data from the OS X clipboard. I couldn't find out, and it's not like I didn't ask. Two days ago, Office 2008 appeared on my chair, and the answer is yes.

Backing up a moment. When you copy content in one application and paste it in another, you are using a system service to transfer the data be it via the old style Carbon Clipboard manager, the Cocoa NSPasteboard class, or the newish Pasteboard framework available to the non-Objective C crowd. The two applications must agree on the format of the data exchanged, so typically only widespread standards are used. For text, as I've outlined before the RTF format is preferred. For bitmap images, a good choice is lossless TIFF. Vectored images, however, were a quandary.

Vectored images are pictures composed of individual drawing operations such as MoveTo, LineTo, AddToPath, FillPath, etc.. Because they are not limited in resolution like a bitmap, they look good on screen and tend to print out with lovely crisp lines. They also tend to be smaller than bitmap files. Every application on Classic Mac OS used a convenient format called PICT which is basically a recording of the QuickDraw operations needed to generate the onscreen display. PICT is a primitive format, something more in tune with the computers of 1984 than 2008. Off the top of my head, it lacks fractional coordinates, paths, Bezier curves, gradient fills, pagination, is limited to QuickDraw fonts, has limited (to rotating text) coordinate matrix manipulations, poor support in Cocoa applications and its ugly. The only two good things I can say about it is it does allow for high quality printing via embedded PostScript, and you can squirrel away your own data in it in case the same PICT gets copied and pasted back into your application.

When OS X arrived, legacy Carbon applications kept on generating their PICT clipboards for both bitmap and vectored material even though the superior PDF format was available and universally used by newer Cocoa applications. QuickDraw became obsolete and onscreen drawing is most often done with Quartz calls, and yet applications still maintain ways to generate PICT clipboards at great expense of maintenance and design. Why?

Because Microsoft Office didn't support PDF, and if you want to sell business applications on the Mac, you have to share data with Office, and that content had better print nicely from within Office. I know from personal experience the aggravation of maintaining the portion of an application which renders content into QuickDraw PICTs; ugly, cludgy QuickDraw PICTs when I could be easily generating PDF clipboards; beautiful lightweight, lithe, PDF files.

To illustrate what I mean I created this pdf in an application which supports creating EPS files but not putting PDF on the clipboard. I opened it in the OS X Preview application (a Cocoa App):

Copied the image into TextEdit (another Cocoa App) from Preview:

TextEdit has a bug where it doesn't re-render embedded PDFs when it zooms.
Copied the image from TextEdit and pasted it back into Preview and zoomed in on a detail:

Now compare with a zoomed detail when using the PICT version from the clipboard of the original application (a Carbon app) (ignore the checkerboard) pasted into Preview:


Presumably, OS X could provide a service where it would extract embedded PostScript from PICTs (if available), and generate a pleasing PDF pasteboard, but it doesn't and I doubt that Apple wants to encourage developers to keep on using PICT.


Getting back to the big news, there was Office 2008 on my chair. Install. Draw a moon:

Copy. Launch Pasteboard Peeker and see this output (... means omitted content):
PasteboardRef: 1116096 ItemCount: 1
Index: 1 item ID: 1112493904
...
"com.adobe.pdf"
"Apple PDF pasteboard type"
'PDF ' P_____ 21056 PDF-1.3 4 0 obj << /Length 5 0 R /Filter /FlateDecode >> stream x

"com.apple.pict"
"Apple PICT pasteboard type"
'PICT' P_____ 409198 >n C 0 H
...


Yay.

And notice how svelte the PDF (21,056 bytes) is compared to the PICT (409,198 bytes). Rendering a gradient fill in QuickDraw is not pretty.

Go back to Word and add a star:

Copy and paste into Pasteboard Peeker and:
PasteboardRef: 1116096 ItemCount: 1
Index: 1 item ID: 1112493904
...
"com.adobe.pdf"
"Apple PDF pasteboard type"
'PDF ' P_____ 24935 PDF-1.3 4 0 obj << /Length 5 0 R /Filter /FlateDecode >> stream x

"com.apple.pict"
"Apple PICT pasteboard type"
'PICT' P_____ 498658 H
...
The PICT version bloats by 97K while the PDF gets a mere 4K. Not that size matters any more with RAM and hard prices the way they are.


Word in Office 2004 had a clipboard which looked like this:
PasteboardRef: 3323920 ItemCount: 1
Index: 1 item ID: 1112493904
...
"com.apple.pict"
"Apple PICT pasteboard type"
'PICT' P_____ 2222 U , , f
...


Open up the pasted PDF in Preview and Zoom:

Look at that beautiful shadow detail! Try to do that in a PICT!

Draw something in Sketch copy paste, yep, there it is, a PDF pasted into Word. Yay again.

But what does this all mean? It means that once Office 2008 sees widespread adoption, the rest of the Mac content creation software industry can rip out every last QuickDraw call in their application. It means we can build 64-bit versions of our applications. It means we had best start putting PDF on our own clipboards. It means Cocoa apps can generate content and with no extra effort have it look great inside Office apps. It means there will be a new, higher minimum quality for interchanged content. It means we can forget everything we ever knew about Classic Mac programming.

The future is finally here.
[Update: One fly in the ointment is that Word has a bug wherein if you paste a PDF graphic into a Word document, and subsequently copy and paste it from Word and into another application (such as Preview), it loses its vectored quality:


But while the graphic is still within Word, it scales, prints, and zooms beautifully, so presumably this is just a bug in the copy code and not a design flaw. The vectored PDF is being maintained internally in some vectored form.]

Tuesday, January 22, 2008

Space Heaters: Honeywell HZ-519 versus DeLonghi HHP 1500

I have an online account with Consumer Reports, which I've been quite pleased with; it's the first place I look for home appliance recommendations. The manufacturers of my washer, dryer, wet vac, space heaters, and lawn mower can all thank Consumer Reports for my purchase. However, sometimes, by sticking to objective measures, they get things wrong when problems crop up outside those objective measures. In my case, I feel their high recommendation of the Honeywell HZ-519 electric convection space heater was misguided, as compared to another heater they gave a not quite as high rating, the DeLonghi HHP 1500.



Problem 1: Physical Dimensions

You might notice that the HZ-519 is long and thin. Long and thin objects are delicate and require odd shipping boxes. As I, and at least one other Amazon reviewer found out, these things are easily bent in the middle during shipping as it is hard to protect, leaving me with some ugly and noisy bends in the metal. (The Amazon merchant did give me $24 back instead of taking the return). Also, while it has ample cord length, it is mounted at the right side, if your plugin happens to be to the left, the cord suddenly is no longer so long. Compare this with the squarish, solid HHP 1500 which fits in a box of normal dimensions, and whose cord can be used at a fair distance to the left and right.

Problem 2: Temperature Control

Consumer reports gives the HZ-519 high marks for its digital temperature control and timer, which are nice for a single use: set the temperature to maintain by pushing a few buttons, set the time to heat through a few more button presses. The HHP 1500 on the other hand has no way to set a temperature, you turn some knobs and it will try maintain a temperature: what temperature that is it doesn't say. You will have to futz with it over the course of a couple nights until you find a setting which is comfortable for you. But, and here is the big but, once you find a setting you like you are done. When you want to use the DeLonghi you come in flip the top knob on; with the Honeywell, you press the power button, press the "Temp/Timer" button to select temperature, hit a couple arrow keys; if you want automatically turn off the unit, that's more button presses. Every single session. There is no memory of the last setting. Yes, you do get a timer, which is nice, but you try setting the temperature on this thing in a darkened room, when all you want to do is crawl in bed. (There are versions of this heater with a display backlight, and with a remote control which would mitigate this annoyance.)





Problem 3: Being Nice to Your Fuses

The HHP 1500 has two main power settings. One draws about 7Amps when powering its element, the other around 13 Amps, which spikes at over 15 when turning on causing my Kill-a-Watt to make a warning beep. The HZ-519 has one mode which draws around 11 Amps. A typical household circuit is rated at 15Amps. Now imagine having two bedrooms which share an electrical circuit, each with their own space heater. If you installed two HHP 1500s, that's fine, just keep both of them at their 7 Amp setting, and it will just take longer to heat the rooms. If you have two HZ-519s, pop goes the circuit breaker. This assumes the rooms in question are small enough to be heated adequately at the lower setting.


Problem 4: Noise

OK, I shouldn't criticize the HZ-519 because mine has a lot of twisted metal from the shipping incident, but it is quite noisy as it expands and contracts. The HHP 1500 is dead quiet.

Problem 5: Flexibility of Placement

The HZ-519 is designed to be placed along a wall, while the HHP 1500 can be mounted on a wall or rolled into the middle of a room.

Energy Usage

Not a big problem here, and impossible for me to compare. The HZ-519 in one bedroom has been using about 6kWH (about a dollar) a night keeping the room at a comfy temp over the chilly temp I keep the rest of the house, while the HHP 1500 has been draining about the same. I would be happy with nice thick blankets, but my wife wants the children warm when they kick off their covers.

Safety

The HZ-519 does have such additional safety features as automatic switch-off when knocked over. You will have to judge how important this is for you.

In Conclusion

If you are in the market for an electric convection space heater, get the DeLonghi. Buy them in the summer when they are cheap, because they have really gone up in price since the cold weather set in. I paid $80 for a DeLonghi in late November, it's now mid-January and the same heater is $160.
[Updated with additional commentary after first posting]

Tuesday, January 01, 2008

Memories of RAM past

Pretending 1GB equals 1000 MB.


This is in the category of things that happen to everyone, but which should me remarked upon. Modern RAM capacities are amazing.


My first computer, a Mac Plus, purchased new from the University of North Dakota's bookstore, had .001 GB of RAM installed, which I upgraded first to .0025 GB, and then to its maximum .004 GB, at a cost, as I recall of about $150,000/GB.


I just purchased, at $15/GB (shipping included) a 2GB module for my MacBook, bringing it up to 3GB—and requiring me to dispose of an inconvenient 1GB module. So this means that my computer of today has 3000× the RAM of my 1988 computer, while the price per unit has dropped by 9,999/10,000ths of what it once was. Imagine if cars were improving at the same rate.


Here's a chart of the final RAM capacities for all my previous computers. I've long meant to make up this chart, so bear with the irrelevance to your life:


Drive capacities have gone through a similar transition, from the .0008 GB floppy in my Plus to the 200 GB drive in my MacBook.


The scary thing is the idea that over the next 20 years from now, RAM might increase in typical capacity by another 3000 times, and what will we be doing with it?

[Update: For whatever reason, my MacBook does not like the Transcend TS256MSQ64V6U module in combination with any other module I have. It works by itself, but put in either of the pre-existing 1GB modules (or even a 256MB module from a Mac Mini, and it would not boot. So, I'm stuck at a mere 2GB.]

Wednesday, December 26, 2007

Cute Safari Tip: “Apple” to Apple Symbol 

The default Safari bookmark bar has a link to “Apple”, and another “Apple” labeled RSS feed of Mac news. You can save space by replacing the word “Apple” with the apple symbol: . (Anybody reading this on a non-Mac will likely see a question mark or an empty square instead of the symbol which is the apple with a bite out of it logo.) This symbol can be found in the Special Characters window as Unicode F8FF (decimal 63743), or generated by shift-option-K.




Other Mac specific symbols can be found at MacBiblioBlog.

[Updated: Had given the wrong key equivalent]

Wednesday, December 19, 2007

The Chaotic Nature Of Window's Menus

As part of my day job, I've recently become familiar with the creation, display, and destruction of menus on the Windows platform. In writing this entry, I hope not only to point out the esthetic and technical disaster which is the Win32 menu framework, but offer a caution against getting in the same sort of problems on the Mac.


From the users point of view, menus on Windows are a chaotic mix of styles. While, we Mac users are used to the menus of each application looking the same on any given OS version, Windows users are treated with menus of wildly varying style, depending on the artistic sensibility of the individual programmer. Here are just a few of the menus found on my wife's fairly vanilla Windows Vista install:










Note the random selection of:
  • Highlight colors
  • Separator graphics
  • Highlight region shapes
  • Margins
  • Margin separators
  • Root menu item shapes
  • A ball icon where another application would use a check mark
  • A "Ctrl-P instead of a "Ctrl+P"
  • Minimum spacings between the title and the accelerator
  • Sizing of the submenu triangle
  • Drawing modes for greying out icons
  • Degrees of fade for greyed out text
  • Alignments of the accelerator text


Contrast this with a selection of applications on Mac OS X Leopard:






Although even Apple can't protect us from the attack of the ugly cross-platform icons:



Why the disparity? Because when programming to the Win32 API, Microsoft requires all but the simplest menus to be drawn by application code responding to simple window events: WM_DrawItem, WM_MeasureItem. The system doesn't make it obvious where to draw your text, how to highlight selections, what the margins are, etc. The only thing the system will do for you is erase the background. If all you want to do is draw an icon: perhaps the favicon for a website, you have to manually draw the whole menu item, and if you want any hope of having that menu item look like all the other menu items in that menu, then you have to draw all the items in that menu, and if you do that, you will want to draw all the menu items in all the menus. If you code using the MFC framework, you will end up using some 3rd party menu class, written by somebody in the same boat as you, having to emulate and approximate whatever style is used by their favorite Microsoft app on any particular OS. Future changes in appearance will not magically appear with a new OS, but require each application to be reprogrammed, or at least to have a dynamic library updated.


Again, the major reason Windows programmers draw their own menus is to add an icon to a handful of menu items—which is usually the idea of some marketing guy anyway. If Microsoft had only added the ability to provide a graphic, few people would have bothered to draw their own. Life is short. If they had done so, they could have added all sorts of cool wizbangery to Vista, and we Mac users would be reduced to complaining how they stole translucent menus from Apple.

And while it may seem like a minor thing, Microsoft does not provide separate routines to specify the text of a menu and its key equivalent accelerator. Even if you aren't drawing a menu yourself, you have to provide a string like "&Redo\tShift+Ctrl+Z".



Hopefully, .NET programmers have an easier time.


The net effect of all this is that Microsoft cannot:
  • Upgrade the operating system and come up with a cool new appearance in which all the 3rd party applications (or even old Microsoft applications) magically share how their menus appear. Click on a menu and it's 1986 all over again.
  • Have any kind of unified appearance.
  • Replace those awful looking, English-centric, and space hogging accelerators with elegant Apple style meta key glyphs.
  • Seamlessly move to *resolution independent GUIs. Apple's having trouble getting 3rd party applications to be resolution independent, but the fact that the OS draws the menus at least eliminates that as a problem.



* Resolution independence is the idea that in our future of ultra-high resolution monitors, a menubar for instance won't be 25 pixels tall, but will be 25 points (25/72nds of an inch) with very high quality text.

But.

While all this Microsoft bashing is fun, this is a morality tale of a sort. Apple in its wisdom has given Cocoa developers much more control over how menus are drawn in Leopard. You can in fact, draw anything you please in a menu now. Don't do it. It was bad enough when you could clutter up your menus with blocky little useless icons, now the user can innocently click on a menu and be confronted with the Gates of Hell. Don't do it. Resist the temptation. Put the NSView down. If you are porting a Windows app, do not let the pointy haired boss force you into porting the ugly menus. Tell him it can't be done. Tell him you would lose Tiger compatibility. Tell him anything, but don't mess with Mac menus.

"Just because we can do a thing does not mean we must do that thing." The Federation President in Star Trek: The Undiscovered Country


[Entry updated to point out more things wrong with the Windows menus and to add detail.]

Monday, December 03, 2007

Off Topic: The Perception of Time as I Age

2 observations:
1) The months pass faster than when I was younger.
2) I feel slower mentally. The ideas come at a markedly lower rate.

Is it possible that these two observations are sides of the same phenomenon? Perhaps my perception of time is based upon how fast I think. If my younger self had 1000 ideas a month, and my present self creates 500 ideas a month, then do I perceive 2 months as taking as long as 1 month used to take? It seems likely.

Thursday, November 22, 2007

There Must Be a Cocoa iTunes Coming + Vista 64-bit iTunes?

[Update: Apple released iTunes 8, and whatever it is, it is not pure Cocoa]

[Update: Apple did release a version of iTunes for 64 Bit Vista. I don't know how it matches up with the below speculation. ]

This is entirely speculation on my part. If I had insider information, I would not betray it. This is just my uninformed opinion.


Fact 1: iTunes as we know it is a Carbon application on the Mac. It after all is the direct descendent of SoundJam, a short-lived MP3 player for Classic Mac OS. Open up its package in the Finder and see things like a .rsrc file.

Fact 2: iTunes makes heavy use of QuickTime and the Mac Toolbox emulation layer which QuickTime for Windows contains. This is what allowed the same codebase to be deployed on both OS X and Windows relatively quickly. (OK, this may not be a fact, not having access to the iTunes code, but it seems darn likely.)

Fact 3: There is no 64-bit C API to QuickTime on the Mac. There is only a 64-bit Cocoa interface.

Fact 4: Pretty much all of that Mac Toolbox being emulated on Windows is no longer available under 64-bit compiles on the Mac.

Fact 5: All new Macs are 64-bit. Apple is in a good position to start promoting themselves as The 64-bit Company, as their path to 64 purity seems easier than Microsoft's, but it will take getting all their apps there first, and convincing their major developers to follow. I assume it was easy getting their Cocoa applications there, but any residual Carbon applications would be a nightmare.

Extrapolation 1: Even Apple will not be able to make iTunes a 64-bit application without a major rewrite. After you remove QuickTime, all the old Classic Mac APIs which are not in the 64-bit frameworks, etc., there is little left. Maybe much of the task specific onscreen drawing on the Mac is now done with Quartz calls, and the networking calls are probably being done with CFNetwork calls on the Mac, and maybe they are using WebKit to do the store, and that can all be salvaged, and hopefully the code is factored such that system calls are not sprinkled all over the place, but they are going to have to bite the bullet and just write a from scratch Cocoa application and call it iTunes 8.

Extrapolation 2: If Apple is not going to extend the life of Classic Mac APIs and QuickTime C APIs for 64-bit Mac applications, what are the odds of them doing so for the emulation layer on 64-bit Vista. Pretty low. There is no obvious quick way to get iTunes as we know it on Windows to run as a 64-bit process. I guess they could if they really wanted to, but it seems a pretty hacky solution and would basically obligate them to maintain an entire OS's SDK just to run iTunes and QuickTime.

Extrapolation 3: I assume Apple cares about the future of QuickTime and iTunes on 64-bit Windows. This is not a big market now, but will only get bigger, and Windows user are not going to accept running multimedia software in 32-bit emulation mode in perpetuity. They can do two things. They can create a new framework which can play and edit QuickTime content, perhaps a set of .NET classes, and write a separate version of iTunes which makes use of these classes. Or, they can bring Cocoa to 64-bit Windows, and run the same source based iTunes as the Mac. I suspect Apple doesn't want to do either, but iPod sales are important to them. They wouldn't want those early adopter 64-bit users running to Zune.


A little Googling on "64-bit iTunes" came up with this revealing alert text in the current Windows iTunes "This iPod cannot be used because the required software is not installed. Run the itens installer and remove itunes, then install the 64-bit version of iTunes." That makes me wonder if all this is going to fall out sooner rather than later. Or maybe it's an aberration.

Anyway, that's my uninformed opinion, and we'll see if it has any relationship to reality.

[Update: See this article about how Adobe is not releasing a 64-bit version of Photoshop until they can do the major re-writing required to remove their Carbon code.]

Wednesday, November 21, 2007

The Future or Lack of It for Carbon

If you are tasked with maintaining a large, old—is there any other kind—Carbon application, here's an illuminating experiment. In XCode 3.0, under Build architecture, turn on 64 bit compilation for Intel. Now try to compile.


In my case, I see errors and lots of them:

error: '::FlushVol' has not been declared
error: 'HideCursor' was not declared in this scope
error: 'ShowCursor' was not declared in this scope
error: 'LMGetFractEnable' was not declared in this scope
error: 'GetOutlinePreferred' was not declared in this scope
error: 'GetPreserveGlyph' was not declared in this scope
error: 'GetWindowEventTarget' was not declared in this scope
error: 'SetFractEnable' was not declared in this scope
error: 'SetOutlinePreferred' was not declared in this scope
error: 'MoveWindow' was not declared in this scope
error: 'SetOutlinePreferred' was not declared in this scope
error: 'OpenCPicture' was not declared in this scope
error: 'SetControlPopupMenuHandle' was not declared in this scope
error: '::SetControlMaximum' has not been declared
error: '::DrawThemeMenuItem' has not been declared
error: 'GetIntlResource' was not declared in this scope
error: 'CompareString' was not declared in this scope
error: '::SetMenuWidth' has not been declared
error: 'IsWindowVisible' was not declared in this scope
error: '::GetPicture' has not been declared
error: '::DrawPicture' has not been declared
error: '::EraseRect' has not been declared
error: '::FindDialogItem' has not been declared
.... lots more errors ...

So, we have a litany straight out of Inside Macintosh Vol. 1-3: all of QuickDraw, much of the File Manager, the Control Manager, the Dialog Manager, the Window Manager, the Menu Manager, the Font Manager all gone, but surprisingly not the Resource Manager. Anything that uses Pascal strings or FSSpecs. Few of the API's which came from the Classic Mac OS survive a 64 bit compile.


I don't know in the short term, what the carrot is for getting independent developers to make 64-bit compiles. Unless you are doing something that really needs 6 GB of real RAM—very few applications—there seems to be little performance advantage for 64-bit. And, it's hard taking a Carbon application, ripping out the APIs behind its entire GUI, and putting it back together again. Lots of redesign and drudgery for little immediate payoff. In the long term, Apple will presumably stop supporting 32-bit applications, but that is in the very long term.


Plus, there are little bits of functionality in the Carbon APIs which are hard to replicate in the more modern APIs. One example is embedding one's private metadata in the PICT clipboard flavor. I'd very much like to know how to do that with the PDF API. Another example is the XOR drawing mode for doing tracking, stupid and old fashioned, yes, hard to replace, yes.


There's an Ars Technica article which goes into this in more detail.

Monday, November 19, 2007

HDHomerun Gets More And More Useful

[Update: check out Signal GH, an iPhone utility for monitoring the signal quality of an HDHomerun].

One of the best bits of tech I've bought over the last year is the HDHomerun networked digital HDTV tuner. I was reminded of this a couple of weeks ago, when I was going through the process of setting up a Mac Mini as a dual boot Leopard/Vista desktop.


The OEM copy of Vista Home Premium I picked up cheap at MicroCenter comes with Windows Media Center, which Silicon Dust supports for use with the HDHomeRun, so for no added cost, I get live TV watching with a guide, and recording. This is functionality I would not easily get otherwise, as there is no MythTV client for Vista, and I am not going to get an additional tuner for the Mini. It just happened I get all this for free because I happen to own an HDHomerun.


Not that I'm very impressed with Windows Media Center, at least not on the Mini. HD playback is a bit stuttery, unlike VLC on the same OS and hardware; and navigation is confusing. Also, there doesn't appear to be an integrated solution for using my Wiimote; Remote Buddy on the Mac spoils you for effortless couch potato style navigation. MCE does allow the same application to control both live TV viewing and DVD playback, whereas I have to switch off between EyeTV and Front Row on the Mac, but that is comparatively easy with Remote Buddy.


Another HDHomerun nicety is that EyeTV can Picture In Picture both HDHomerun tuners (again on the same hardware Vista MCE can barely decode 1 stream), allowing me to watch 2 HD football games simultaneously, which will be my preferred mode going forward. I like to watch football live, so EyeTV wins over MythTV, whose live TV support is always a bit cumbersome, and the PinP feature seals the deal.


Anyway, my main point is to emphasize the value one gets from a networked device. Because the HDHomerun is accessible from any computer in my house, any computer capable of decrypting an HD stream can use it. In my case, I have 3 computers (my MacBook, a Mac Mini, and my Linux server) and 3 operating systems (Leopard, Vista, Linux), each with their own strengths, sharing this resource.

Wednesday, November 14, 2007

The Cover Flow Compulsion

Compulsion can be a silly thing. Ever since Cover Flow became ubiquitous on the Mac, I've been on a mission to stamp out generic covers. I spent 5 minutes last night looking for a MP3 track called Voyager "Motion" by someone named Sandra Collins which I'm not sure where it came from (did it come bundled with my Fischer Price iBook 6 years ago?), and which I have told iTunes never to play. That's just silly. But look at the pretty pictures swirl by....

Yes, Walt Mossberg, Cover Flow is addictive.

For tracks iTunes can't automagically find artwork for, Amazon is a gold mine of customer submitted artwork, at least for popular stuff; you can pick and choose your Beatle covers.

Then there's the DVD situation. MythTV wants your artwork in one folder where its database can keep track of it. Front Row 2.0 wants a preview.jpg file in the same folder with the VIDEO_TS. Vista Media Center Edition wants a folder.jpg in the same place.

My process was as follows. I copied the artwork from DVDpedia (which had downloaded them from Amazon), used Apple's Preview application to create a new file from the clipboard, and saved it as preview.jpg in every DVD folder on my server. Creating the folder.jpg file was a bit easier, as I wrote a script to make static links from the preview.jpg, the equivalent of typing
$ln -s preview.jpg folder.jpg
170 times. Try to let the computer do what computers do best. A lot of busy work, but look at the pretty pictures swirl by...

SVG on Webkit - Improving

I'm gratified to see WebKit's continuous improvements in its support for SVG. Recent builds fixed a bug, I and many others, reported involving non-support for superscripted and subscripted text. This might seem a minor thing, but SVG support means, for instance, that someday soon Chemistry students will be able to go to a structure on Wikipedia via their iPhone, Android phone, or iPod Touch and actually zoom in on any portion of it perfectly, without worry about pixelating some lame .png file, and without worrying about errors in rendering making the structure ambiguous.

XML based SVG might not be the hottest technology, but the need for an open standard, full featured, vectored image format is so great, it just keeps chugging along. And it's inclusion in the base technology of both the iPhone and the Google Android SDK means it will finally allow for the inclusion of resolution independent and small vectored files, where today monstrous bitmap files are used. I'm sure Google is eager for its use in web apps for such activities as creating charts and graphs.

Now if Apple would just turn it on for the iPhone.

Thursday, September 13, 2007

Walt Mossberg's Take on Linux Desktop Deficiencies

This is an e-mail I sent to Walt Mossberg, technology columnist for The Wall Street Journal after this morning's column on the practicality of Linux on the Desktop. In the column, Mr. Mossberg skewered Linux for playing neither MP3s or DVDs out of the box, and found this symptomatic of Ubuntu's incompatibility with the mainstream computer user.


    Mr. Mossberg,
    Just to let you know beforehand, I'm a Mac guy not a Linux evangelist, although I do maintain a Linux server in my basement.

    It seems to me that you should have mentioned the reason Linux distributions don't come with MP3 codecs or DVD players is because someone would have to pay for a license for those bits of software on a per user basis, and that gets in the way of distributing a free operating system from anonymous FTP sites. It isn't that the Ubuntu people haven't gotten around to adding that refinement, it's just that it's inherently incompatible with their distribution model. The MP3 codecs/DVD decryption software you end up downloading is either a clear copyright violation or outright illegal in the U.S. (DMCA) which makes it hard to get bundled with hardware.

    I hope you don't get an avalanche of e-mail saying you should use Ogg instead of MP3.

    --glenn


Mr. Mossberg quickly and politely replied, but since I didn't ask him for permission to repost, I will not publish his reply. As an aside, I've found him to be responsive to short, on point, polite e-mails; I don't know how he keeps up with it all.


Also, I might have been wrong, MP3 might be patent entangled not copyright entangled. Regardless, this is quite the problem for Linux distributions. While it's at least conceivable that some rich benefactor could get an unlimited license from Fraunhofer although Wikipedia says Fraunhofer earned 100,000,000 Euros in royalty payments in 2005 for MP3, but it seems unlikely that the DVD Forum could release an open source library and still maintain the pretense of DRM. And then there's the winner of the Bluray and HD-DVD war, and then whatever DRM hobbled downloadable format comes after that. Quite a problem.

It would seem that hardware vendors need a non-free version of Linux that they control the distribution of, which pays its per seat license fees and follows the DRM consortiums rules. Perhaps audio card manufacturers could market versions which are licensed to decode MP3 streams. I don't know. I do think that Walt Mossberg is right and people have some expectation to play standard media on their desktop computer (without breaking the law).

Wednesday, September 12, 2007

Apple's Cool New Site Search

I don't know when this was released, but the search field on apple.com is slick. It seems every day some hotshot AJAX programmer (or WebObjects guru) comes up with some new magic once reserved for desktop applications, not web page frontends. In this case, Apple's search function does a real time database search and populates a dynamic popup menu with images and text, all of which updates after every keystroke.

Type in "boo" and you get this:

Add a "t" and you get this:

Quick, slick and cool.

Tuesday, August 21, 2007

Recording Standard Definition TV from DirecTV with MythTV

In a followup to my note to myself on playing live TV from my satellite box using mplayer, this is about integrating a pcHDTV 3000's s-Video input into my MythTV system.

It would, of course, be nice if I could get all the programming I want in unencrypted HD, but sometimes all you can get or afford is old fashioned analog. In my case, I have a D12-300 DirecTV satellite receiver on my desk, this extra receiver costs me $5 a month over the cost for the receiver in the TV room, so it's a fairly good deal. What makes it a better deal is using my MythTV to time shift, skip commercials and watch it anywhere in the house wirelessly onto my MacBook.

Hardware



Most of the hardware I already had. I did purchase the USB to serial adaptor—according to accounts on the web not all adaptors work with DirectTV receivers—and the null modem adaptor.

Hardware setup

I plugged the USB end of the USB to serial adaptor into the DirecTV receiver, and the serial end into the null modem adaptor. I plugged the other end of the null modem into the serial port of my Dell Dimension—tighten those screws. I plugged the s-Video cable into the s-Video output of the satellite receiver, and into the s-Video input of the pcHDTV card. I plugged the RCA jacks of the audio cable into the red/white outputs of the satellite receiver and the mini-jack end into the line in port (2nd from the right) of the AV-710.

Software setup

My previous posting described setting up the system audio to activate the line in port for audio input. I would follow those instructions now, to confirm you can see and hear live TV via mplayer.

As I will be using a script to change channels over the serial port, I want a non-root user account to open up the serial port device, so as root from the command line:
# chmod a+rw /dev/ttyS0

I would test this by running your copy of the directv.pl script. For example:
$ /usr/share/mythdora/directv.pl 231
should bring up the Food network. (Your path will be different, probably.)

I went to my account on (the soon to be discontinued) zap2It labs and setup a listing grabber for DirecTV, limiting it to the 10 or so channels I would conceivably watch.

Then I ran mythtv-setup.
  • Capture Cards
    • Card Type: Analog V4L capture card
    • Video device: /dev/video
    • VBI device: /dev/vbi
    • Audio device: /dev/dsp
    • Audio sampling rate limit: 48000
    • Do not adjust volume: Checked
    • Default input: S-Video
  • Video Sources
    • Video source name: DirectTV
    • Rest of the settings are dependent on your having setup up a listing grabber for DirecTV
  • Input connections - [V4L :/dev/video] (S-Video) -> DirectTV
    • Display Name (optional): DirecTV
    • Video source: DirecTV
    • External channel change command: /usr/share/mythdora/directv.pl (your path will be different)
    • Preset tuner to channel: 231
    • Click on the Fetch channels from listing source
    • Starting channel: 231
    • Input priority: -1


Of course, I kept my pcHDTV's DVB setup to record over the air digital HD programming, although I did change the Recording Options for the Capture Card to only "Open DVB card on demand".
[Update: somewhere along the way, I lost ATSC tuning for the pcHDTV card, and I'm having a hard time getting it back. For me, this is not an urgent matter as I have the two tuners in my HDHomerun, but obviously it would be important to anybody with only a pcHDTV. I'll try to figure this out, but I think it has to do with a conflict between my kernel version and the DVB drivers.] [Update 2: I updated mythtv to the current build to support Schedules Direct and it works again. I apparently can now record off of one of the pcHDTV's outputs at a time (not both at once.)]

At this point, you should run mythfilldatabase.

I then restarted the mythbackend, and opened up the mythfrontend, but before watching any TV, I had to setup my recording profiles.
  • Utilities/Setup
    • Setup
      • TV Settings
        • Recording Profiles
          • Software Encoders (v4l based)
            • Default
              • Enable auto-transcode after recording: Checked
              • Width: 720
              • Height: 480
              • Codec: MPEG-4
              • Codec: MP3
              • Sampling rate: 48000
            • Live TV
              • Enable auto-transcode after recording: Checked
              • Width: 720
              • Height: 480
              • Codec: RTjpeg
              • Codec: Uncompressed
              • Sampling rate: 48000

Conclusion

After finishing all this, I was very surprised that I could watch Live TV both at my MythTV box itself, and over wireless with my MacBook, and I could also schedule recordings and it would all work. I like having a wired connection to the satellite box for changing channels, it should be 100% reliable unlike an infrared blaster arrangement. The video is amazingly ugly compared to the beautiful HD I get from my antenna, but then again, it's going to be a while before Good Eats comes in over the air.

I keep my audio sampling, storing and playback rates at a constant 48000 Hz as it is the standard playback rate for the PCM stereo audio which will eventually go out the optical port to my audio receiver, and I don't see the point of adding another possible failure point in the sampling conversion. My previous MythTV install made 44.1Khz recordings sound high pitched.

I'm just glad I'm done with this, and I hope this saves you some time.

Friday, August 17, 2007

Playing Live TV from Satellite box on Linux

This is more of a note to myself, as I'm sure this involves an unusual set of hardware and software.

I have a standard definition DirectTV satellite box on my desk. I wanted to display its content on my Mythdora Linux box—actually, I want to record standard definition programming with MythTV, but I haven't quite gotten there yet. [Update: This post is about recording]. I have a pcHDTV 3000 capture card in my Linux computer with an s-Video input, and a Chaintech AV-710 audio card with a line level input (it's the second one from the right). I figured I could bring the video in through the s-Video port and the audio in through the line level port via an s-Video cable and an RCA to mini-jack cable, it would just take a little configuration tweaking.

First, I had to use alsamixer to turn on capturing, so I brought up the capture display for the AV-710 by using alsamixer -V Capture and selecting the Line capture item and hitting the space bar and then setting the Capture level item to a moderate value. (Actually, I did a ton of stuff trying to make this work, but I think it boiled down to this.)

Then I had to figure out the voodoo to cause mplayer to display the video from the pcHDTV card combined with the audio from the AV-710 card. This ended up being:

mplayer -tv driver=v4l2:device=/dev/video:input=2:outfmt=rgb24:alsa:amode=2:audiorate=48000:forceaudio:immediatemode=0 -vo xv tv:// -vf pp=lb -ao oss:/dev/adsp

Breaking this command line into parts:
  • -tv driver=v4l2:device=/dev/video:input=2 means the Video For Linux framework will grab video from input 2 of the pcHDTV card
  • alsa:amode=2:audiorate=48000:forceaudio:immediatemode=0 means audio will come from the ALSA frameworks default capture device at a sampling rate of 48000 Hz (which is the frequency that my TOSLink output needs)
  • -vo xv tv:// set the video output
  • -vf pp=lb means to use a linear blend deinterlace algorithm
  • -ao oss:/dev/adsp means to output it to what happens to be the optical output of the AV-710

Sunday, August 12, 2007

Mac MythTV Frontend Settings

There are a lot of MythTV settings. Page after page of preferences. In many ways, this is bad design; a refusal by the authors to make decisions about correct and incorrect behavior. But that's the situation, and here are a few settings where I think the value should change.


Utilities/Setup.Setup.General.Audio.Enable AC3 to SPDIF passthrough
If you have your Mac hooked up to a receiver via an optical cable, remember to check this or you will throw away your surround sound. Unfortunately, it doesn't auto-detect the absence of such a cable and fall back to non-passthrough, so you'll end up unchecking this when you move your Mac.
Utilities/Setup.Setup.Apearence.Theme.Theme
If you are using a widescreen Mac, or attaching your Mac to an HDTV, you should try MythCenter-wide as the theme. Non-wide screen themes tend to get their lower buttons cut off in the more complicated preference panels.
Utilities/Setup.Setup.Apearence.Theme.QT Style
The Mac themed buttons are unusable (transparent blue on blue). Use Windows style.
Utilities/Setup.Setup.TV.Playback.General Playback.Deinterlace playback
Unless you have a Mac which can just barely display 1080i content, or your monitor will deinterlace content for you, you should turn this setting on.
Utilities/Setup.Setup.TV.Playback.General Playback.Algorithm
This is something you should investigate for yourself. Run the Activity Monitor application in your /Applications/Utilities folder to determine the performance hit of the various deinterlace methods, and test them for effectiveness. In particular, the BOB method doesn't work well for me, while the Kernel method works but uses more of my CPU. I will try using the One field method.
Utilities/Setup.Setup.TV.Playback.On Screen Display.OSD Theme
The Gray-OSD theme seems the the most tasteful of the bunch.
Utilities/Setup.Setup.TV.Playback.On Screen Display.Always use Browse mode when changing channels
If your channels take as long to change as mine, you'll prefer to see what's on before committing to changing the channel.
Utilities/Setup.Setup.TV.Playback.Mac OS X Video Settings 2/2.Video in the dock
I think this feature is pretty useless and a waste of power.

Sunday, August 05, 2007

Why Can I use MythTV with 802.11g, but not EyeTV?

The Linux box in the basement runs the MythTV backend. I can watch live HDTV wirelessly using 802.11g networking through the Linksys router in my back bedroom to my MacBook. As long as the microwave isn't on, and I stay within 30 feet or so of the router, the picture and sound are typically great.

I have an HDHomeRun networked HDTV tuner right next to the Linksys router, and I cannot watch 5 seconds of TV wirelessly without a skip, big pixilation, or pop using the EyeTV application. Using wired ethernet it's fine, but 802.11g? Forget about it.

I can set the MythTV to grab a stream from the HDHomerun, bring it down to the MythTV via wired ethernet, and then back up the same wire to the router, and out as radio waves, and it still works smoothly. I just watched 20 minutes of 1080i HD golf on CBS without a skip; although twisting the MacBook around will cause the occasional skip at this distance—perhaps 25 feet through a floor and a couple walls.

Why can MythTV do what EyeTV can't in this situation? I don't know; presumably it has more flexibility in buffering at the source, but it still has to average the same bit rate. MythTV might be better at handling lost packets... Again, I don't know. I just know MythTV works better for wireless HDTV.

Thursday, August 02, 2007

New Windows Remote Desktop Beta

The Mac Business Unit at Microsoft released the first beta of Remote Desktop Connection 2. This is good news for me. A perk of my job is that I get to do most of my C++ coding on my Mac, but I do need a PC on my desk for Visual Studio to implement and debug Windows specific objects. As I require cutting and pasting between the two environments, I use Remote Desktop Connection on my iMac to put a full screen PC on a secondary monitor. I can copy and paste text between the two environments, using the same trackball and keyboard; and I can do full compile link cycles while not taking away from my Mac's performance unlike a Parallels virtual machine.


Unfortunately, I was irked by inexplicable slowdowns and unreliable text pasting; and I had no real hope of the situation brightening as I believed Microsoft had abandoned Remote Desktop Connection development, and I would be stuck forever with a PowerPC only, buggy hack. And yet, here out of Redmond comes a beta of a universal binary version 2. Read the blog entry announcing the release. They took use cases like mine into account; I like the easy sharing of a Mac folder as a Windows volume; text pasting seems instantaneous, and GUI performance is fairly snappy on my 20" Intel iMac.


It shows its beta-ness. I crashed it several times trying to bring it up on my second monitor before it stuck. I hope the MacBU will fix the more blatant bugs in short order. Thanks MS.

Wednesday, July 25, 2007

HDHomeRun and EyeTV

[Update: check out Signal GH, an iPhone utility for monitoring the signal quality of an HDHomerun].
Cruising the AVS Forum Mac Home Theatre Forum I was gratified to see El Gato and Silicon Dust had come to together and done the obvious: bundle El Gato's best on platform EyeTV DVR software with Silicon Dust's networked HDHomerun high definition digital tuner.

This only makes sense, as El Gato no longer makes the closest approximation to the HDHomerun, the long lamented EyeTV 500 Firewire tuner with its support for digital over the air broadcasts and unencrypted cable streams. The HDHomerun can do both functions only better:
  • Two independent tuners
  • Shareable between computers
  • Placeable closer to roof antennas
  • Uses ubiquitous Ethernet port instead of specialized Firewire


If I were putting together a home theatre PC, the HDHomerun is the only ATSC/QAM tuner I would consider; it's just so much more flexible than something tied to a single computer.

Plus, using EyeTV with my HDHomerun cost nothing extra. I already owned a copy of EyeTV 2 and El Gato tech support gave me a link to the 2.4.2 update for free. New purchasers of a HDHomerun can get an EyeTV bundle for $200, meaning El Gato is charging $30 for a two seat license above the $170 price for just the HDHomerun.

The first problem was figuring out I had to run the Setup Assistant from the Help menu so EyeTV could find the HDHomerun; which it quickly did; and it immediately came up streaming 2 digital channels in separate windows. Then I had it search for available channels which took over an hour—812 frequencies @ 5 seconds each—using the exhaustive option. It found 15 digital sub-channels in my area, which is a bit low; but it is the height of summer and tree leaves down the street block my path to the Boston antenna farm. A later quick search found 12 channels, so the exhaustive search may be worth it. It would be nice if it would just take the information from my TitanTV account. Maybe El Gato could speed this up by using both tuners. A second exhaustive scan the next morning found 19 sub-channels.

At this point, I could watch TV, in fact, I could watch 2 separate TV streams at once on my MacBook, with sound from the frontmost stream. Not that I would make a habit of doing so; the combined effort of decoding 2 1080i streams into half sized windows takes 175% of a core, leaving a measly 25% to do anything else. Also, I was reminded of EyeTV's annoying habit of resizing the window every time a standard definition commercial comes on. Remember to fix the ratio at 16:9.

As I can watch HD from my MythTV via my home's 802.11g network, I was hoping to watch live TV direct from the HDHomerun over wireless, but this brought sputtering, stopping, and ugliness; El Gato should improve EyeTV's behavior over an unreliable network. Still, I have the whole house wired with Cat-6 Ethernet cable, so I have some flexibility.

EyeTV allows you to update the firmware to the HDHomerun quite easily. Much more easily than manually downloading the firmware and flashing the device with the HDHomerun's Windows utility. This is typical of EyeTV's nearly painless experience. EyeTV is the best I've seen at live TV viewing, and I've tried MythTV, VLC and SageTV (on the PC). I haven't tried it's DVR functionality, because I actually use my MacBook, and can't devote it to the task; if and when I get a Mac Mini for the TV room, I will give it a try. I just wish there was something to watch in the summer; I've 3 tuners in the house and nothing to see.

Friday, July 20, 2007

upgrading to Mythdora from Fedora Core 4

My Linux installation was not aging gracefully. I had installed Fedora Core 4 a couple years ago, and had intermittently added packages as needed to keep current compiled versions of MythTV running; if just barely. For instance, the DVD player didn't know what to do with DTS tracks, there was no overlay interface on playback (although this might be because I had a bad OSD theme selected). I wanted to try the new tickless kernel to see if it helped with using less energy and making less noise, but nobody is keeping the yum database up to date for Core 4 and a yum updage did nothing. So time to upgrade.

The Myth(TV)ology page recommends installing the Mythdora specialized distribution. This is Fedora Core 6 with pre-installed MythTV all on a DVD image. Also, I wanted to take the opportunity to bump up my boot disks capacity a bit, and also not destroy my initial installation, so I ordered a 400 GB from Frys.

Before I did anything, I backed up my MythTV database via:
$ mysqldump -u mythtv -pmythtv mythconverg -c > mythtv_backup.sql

I have a fairly uncommon configuration in that my master PATA (hda) drive is a Windows XP boot volume, while the slave (hdb) is my Linux disk. I replaced my hdb drive with the new 400GB drive, and booted off the Mythdora DVD. Now, I had to be very careful not to wipe out my XP installation; choosing to install on the hdb drive, and using the boot installer advanced options to install a boot installer on hdb. Experience told me that installing a boot installer on the XP disk would be bad. Then after installing Mythdora, I had to boot off a Knoppix LiveCD, and in the terminal make a copy of the first 512 bytes of the hdb1 volume:
dd if=/dev/hdb1 of=mydora_bs.bin bs=512 count=1
I mailed the resulting file to myself via a webmail account. I booted into Windows XP and followed the instructions for editing the boot.ini file to make my Linux installation an option for the Windows boot manager.

At this point, I could boot into Linux. I put my old Linux boot hard drive into a Firewire case, and attached it the computer, allowing me to recover the old database via:
$mysql -u mythtv -pmythtv mythconverg < mythtv_backup.sql
and to copy the contents of my recordings folder, the contents of my .mythtv folder, and anything else onto the new disk. My old recordings had been in a /video volume, but mythdora had created a /storage volume, so I created a symbolic link to point /video into the new partition.

After doing this, the overlay display disappeared, which caused me to discover that I had been using an invalid OSD theme (who names these things?) which came back after setting it to a valid theme, it took me a while to find the proper audio device settings to allow TOSLink pass through on my Chaintech AV-710 audio card (it's /dev/adsp), and of course there is always the nonsense in dealing with my complicated xorg.conf file.

And now I've upgraded, and everything seems to be working OK. I can play DVDs with DTS tracks. I have my overlay display. I'm getting used to Gnome instead of KDE.

Oh, and the energy use has not improved. If anything, it's using a few more Watts. Still worth the upgrade.