Thursday, February 21, 2008

TiVoToGo, Part 3

In TiVoToGo, Part 1, I spelled out the basics of using TiVoToGo to transfer TV programs from your TiVo DVR to your Mac (or a Windows PC, for non-Mac people). In TiVoToGo, Part 2, I talked about a secret way to export the programs, once they are on your Mac, to Apple TV.

Now, more about the latter.

Apple TV is a gadget from Apple, Inc., that mates to your TV and home entertainment system and delivers to them the media files your Mac or Windows PC has access to. Apple TV sits next to your HDTV and is connected by an HDMI cable as an input to it. It also connects wirelessly into your home computer network, which Apple hopes you build around one of its AirPort Base Station 802.11g or 802.11n routers. (If you use a non-Apple WiFi router, that's fine too.)

Apple TV works hand-in-glove with iTunes, whether on a Mac or on a PC. Music, movies, TV shows, podcasts, and most or all of the other stuff you have in your iTunes library can be shared with it. Apple TV can even (since the latest software release, version 2.0) directly access the iTunes store and buy or rent, and then download, movies and other content without your having to get on your computer to do it.

Obviously, Apple wants you to get content for Apple TV right from the iTunes store. But there are also ways to furnish it with content that doesn't come from Apple. One way is to export TiVoToGo content to it.

The "approved" way to transfer TiVoToGo content to your Mac is with TiVo Transfer, software that comes with Toast Titanium. Once the content is on the Mac in the form of a file with a .tivo extension, Toast can export it in a format compatible with Apple TV.

To get it to do that, as I said in my previous post, you have to enter

defaults write com.roxio.Toast "tivo export mode" -integer 1

in the Mac OS X software application called Terminal. This app allows you to talk to Unix, the operating system at the heart of Mac OS X. This particular command basically (via Unix) tells Toast to make its entire range of export options available to you. If you don't do it, Toast will only let you export TiVo programs in formats suitable for the iPod and other portable devices. These formats have too little resolution for high-quality display by Apple TV on an HDTV.

Once you have availed yourself of all of Toast's export options, you'll want to choose its H.264 codec for all Apple TV exports of TiVoToGo programs. H.264 is an especially efficient version of the MPEG-4 encoding standard; TiVo files use the less-compact MPEG-2.

H.264 is theoretically able to encode video content that can be, but does not have to be, high definition. That is, it can accommodate the bitrates, frame rates, and resolutions associated with 1080i, 1080p, and 720p video. It can also accommodate standard-def fare, either 480i or 480p, including the versions thereof found on DVD.

Thus, if you transfer, say, a 1080i or 720p TV recording from your TiVo to your Mac and export it in H.264 format using Toast's default H.264 settings, you'll get a truly high-def version of the program that will play in QuickTime Plus and in iTunes with resolution and quality much like the original. (It will be an extremely large file, owing to the high bitrate that Toast uses by default.)

Problem is, that file is not apt to be compatible with Apple TV. If you tell iTunes to sync it to your Apple TV, iTunes will refuse on grounds that the file is unplayable by Apple TV.

The problem is that Apple has placed limits on the bitrates, frame rates, and resolutions Apple TV can use, in the H.264 suite of formats.

To find out more about these limits, check out The Complete Guide to iPod, Apple TV and iPhone Video Formats at iLounge. Here is the crucial table:

It shows that Apple TV allows a resolution of at most 1280 pixels across the screen by 720 pixels up and down. This is 720p resolution, which means 1080i and 1080p (both 1920 x 1080) are not supported. (Note: for purposes of this discussion, I'm ignoring the MPEG-4 column, which pertains to a version of MPEG-4 which Apple TV can also use but which is not as compact and efficient as H.264.)

Moreover, when using 1280 x 720 resolution for H.264, the frame rate can be no more than 24 frames per second for Apple TV. Most 720p TV fare uses a frame rate of 60 fps (modified, for technical reasons, to 59.94 fps).

If you lower the resolution to 960 x 540 (preserving the usual 16:9 aspect ratio), you can bump the frame rate up to 30 (or 29.97) fps.

I have successfully tried exporting a 1080i program whose original resolution was 1920 x 1080 at 640 x 360 (which again preserves the 16:9 aspect ratio) and found I could keep the original 59.94-fps frame rate. The resulting file plays fine on Apple TV. Thus, there are various combinations of frame rates and resolutions that, taken together, work with Apple TV. It is not clear how you can find out what they all are, except by trial and error.

Notice that there is also a maximum bitrate shown in the table for H.264: 5 million bits per second (mbps). This figure reflects the highest average rate at which bits can be presented to Apple TV's H.264 decoder.

This technical note
at Apple's Developer Connection website says (scroll down about halfway) that bitrate spikes can be as high as 12 Mbps.

The higher the resolution and/or the frame rate, the higher the bitrate, all other things being equal. But the bitrate will also vary with the amount of overall scene complexity and particularly the complexity of the motion in the scene. For example, in a shot of a golf ball crossing a green, there is little overall scene complexity, and the motion is also quite simple. Such a scene will be be greatly compressed by the H.264 algorithm. The resulting bitrate will be low, whatever the resolution or frame rate.

On the other hand, imagine a shot in which the camera pans across the crowd at a football game. The scene is complex, because of all the tiny details in the representation of the crowd. The motion is also fairly complex, because the camera is in motion and so are the individuals in the crowd. The resulting bitrate will be high, even if the resolution and frame rate are not.

Apple TV needs video that is limited in frame rate, resolution, and bitrate, compared to what H.264 is really capable of. In Toast, when I export what was originally a 720p HDTV file, here is the Video panel of the MPEG-4 Export Settings dialog. I see this dialog when I click Options in Toast's Save As dialog, next to H.264, after I have chosen H.264 as the output video format from the Format popup in that dialog:

Notice that I am using a conservative bitrate of just 1000 kbps, which is 1 Mbps. My Custom resolution is just 640 x 360. My frame rate is 29.97, which is half that of the original.

More about such technical topics can be found at The Complete Guide to iPod, iPhone and Apple TV Video Conversion (Mac) at iLounge. Notice that this page is an entry point to a four-page article covering a broad range of related topics. A complete rundown on all Apple TV coverage at iLounge can be found at All Things Apple TV.

That's enough for now. More later ...

No comments: