Saturday, August 30, 2008

iPod Touch: How to Set Up a Random Album Playlist

This isn't about video or HDTV, but it is about my new iPod Touch, which I've been talking about in several recent posts.

Because it only has 8 GB of flash memory, most of which is devoted to videos, I'd like to find a way to set up a smart playlist in iTunes that will allow me to select, say, a random 2 gigabytes worth of music to sync to it as a playlist. Here's the catch. I want not randomly selected songs, but randomly selected whole albums.

A post by "Myra" about halfway down in this forum thread shows how.

The key thing is to checkmark Shuffle By Albums (rather then By Songs or By Groupings) in the iTunes Controls menu. (In pre-8.0 iTunes, go to iTunes Preferences and, under Playback, select Albums rather than Songs or Groupings at the bottom of the pane, and click OK.)

Then set up a smart playlist (I call mine "iPod Random Album") and set it up this way:

  • I enter "Limit to 2 GB selected by random" and checkmark it
  • I checkmark "Live updating"

When I click OK, the playlist fills in with 2 GB worth of randomly selected whole albums!

If I delete an entire album from the playlist, a new album, randomly selected, magically replaces it.

If I delete everything in the playlist, it magically fills in with an entirely new random selection of albums.

If I want, I can add various selection-limiting rules. For instance, right now I'm limiting the albums on the iPod to those in a certain other playlist of mine called "Elaine." To do that, I just use the rule "Playlist is Elaine."

The rule "Last played is before {enter a date two days ago}" will keep the list fresh.

If you object to shuffling albums rather than songs, you can revert to Shuffle: Songs in iTunes Preferences: Playback after making the playlist. Just remember to return to Shuffle: Albums each time you want to refresh the playlist.

Thursday, August 28, 2008

Hooking iPod Touch to an HDTV

Apple's iPod Touch is sort of a jack-of-all-trades. Not only will it play music and videos for your eyes (and ears) only, in the standard video iPod way. It will also connect to your HDTV and play media for all to see and hear.

The secret to this is to get either an Apple Composite AV Cable ($49) ...

... or an Apple Component AV Cable ($49).

They both come with not only a means to connect your iPod Touch to a TV, but also a USB power adapter to hook it to electrical power. (This, along with virtually everything else I say in this post, applies equally to an iPhone as to an iPod Touch, by the way.) You just connect either version of AV cable to the 30-pin dock connector on the iPod's bottom edge, plug the AV cable's video and audio connectors into an appropriate input on your TV, and plug the USB connector on the AV cable into the USB adapter, which plugs into a wall outlet.

The audio connectors on both AV cables are the same: the typical red and white stereo audio RCA plugs. They go into, respectively, a pair of right and left audio-in RCA jacks on your TV.

The video connectors differ with the type of AV cable you get. If you get an Apple Composite AV Cable (which is what I have) you plug a single yellow-identified "composite" video RCA plug into a like jack on the TV. If you get the Apple Component AV Cable, you insert RCA plugs coded red, green, and blue into the appropriate "component" or "YPbPr" video inputs on your TV.

I recommend also getting the Apple Universal Dock ($49) to go with your setup. It lets you hook the 30-pin connector on the AV cable to it permanently. Then when you want to use the iPod Touch with the TV, you just stick the iPod in the dock, turn on the TV, and make sure the TV is set to use the correct input for the iPod.

The dock even comes with an Apple Remote that you can use from your easy chair to pause playback, skip to the next song or chapter, etc.

A very nice thing about using the iPod-to-TV connection to play videos, which is its main purpose, is that it does a pretty darn good job of it.

True, the resolution is only 480i. This is not high-definition video. An Apple TV can give you up to 1280 x 720 pixels of resolution, progressively scanned at 24 frames per second. Not so, the iPod Touch. A video file with that kind of HD resolution won't play on an iPod, period. Files that play on an iPod will have lower resolution in both the horizontal direction (the first number) and the vertical direction (the second number).

The second number (vertical resolution) will typically be 480 pixels, at most. For widescreen movies that play with black letterboxing bars at the top and bottom of the screen, this number is reduced appropriately.

The first number (horizontal resolution) can be at most 720 pixels, I believe. (Actually, though, because some videos are "anamorphically encoded," somewhat more than 720 pixels can be horizontally squeezed into the width of a nominally 720 x 480 video frame.)

The TV playback from an iPod touch iPhone will use "interlaced" fields, not "progressively scanned" frames, according to a footnote in this informative support document from Apple. Thus, it is 480i, not 480p, video playback that you will see on your HDTV screen.

Your HDTV will, however, "deinterlace" this 480i signal to give you a seemingly "progressive" viewing experience, ideally with no visible "scan lines" or jagged, vibrating edges on objects. How close to this ideal your experience will be depends in part on how well your HDTV does deinterlacing and in part on how "clean" your source video is, in terms of its encoding.

A nice thing about video playback on an HDTV from an iPod touch, at least in my opinion, is that the proper picture geometry is always preserved. For example, if the original video uses the old-style 4:3 aspect ratio, that's what you'll see on the TV screen. The 4:3 video frame will be "pillarboxed": flanked by thick vertical black bars on a 16:9 HDTV. (For this to be so, you'll need to make sure that "Widescreen" is selected under Video Preferences on the iPod.)

Or, if the original video has an aspect ratio greater than the HDTV's nominal 16:9, the iPod Touch will give you black letterboxing bars at the top and bottom of the screen.

Of course, if the original video has exactly 16:9 as its aspect ratio, you'll see neither letterboxing bars nor pillarboxing bars, and every pixel on the HDTV screen will be lit.

There are many people, though, who disagree with me on this — they want to see every HDTV screen pixel lit, no matter what the aspect ratio of the original video is. If the original ratio is not 16:9, they would like the image to be stretched either vertically or horizontally, as needed, to fill the screen. That this produces incorrect picture geometry — people who are too tall and skinny, or too short and fat — doesn't bother this type of viewer.

Since the iPod Touch introduces black bars whenever needed to preserve correct picture geometry, this type of viewer might not be happy.

The iPod Touch/TV combination has a few drawbacks, too. One is that you have to summon up the video, music album, playlist, etc. that you want to play from the touchscreen of the iPod itself, which at the time already has to be connected to the 30-pin connector of the AV cable (or to the dock). There is no way, even using the Apple Remote, to select items to play back from the TV screen itself. Plus, if you remove the iPod from the dock to locate your media files and initiate play, when you put it back in the dock, you'll just have to start things all over again.

Another drawback is that when you're playing music, you don't see the title, album art, etc. on the TV screen, as you would if you were using an Apple TV ... just a black screen.

The iPod-to-TV connection is not nearly as sophisticated as an Apple TV. The contents of the iPod screen are not sent to the TV, ever. That means you can't use the TV screen as an enlargement of the iPod screen, nor (as already mentioned) can you use the buttons on the remote to navigate to buttons and hotlinks on the iPod and select stuff. The remote won't do anything at all until you're actually playing something.

When you do play something, you will see its album art and identifying and control information on the iPod screen ... a nice touch, but it's not a lot of use to you from a distant easy chair.

Apple needs to rethink the user interface for the iPod-to-TV connection bigtime, in my humble opinion. My first inclination is to think that there's no reason why Apple shouldn't make the iPod Touch do everything an Apple TV does.

The Apple TV syncs automatically and wirelessly to your iTunes library. To sync the iPod Touch you have to connect it to the Mac running iTunes — even though the iPod Touch does connect wirelessly to your home network.

The Apple TV wirelessly streams video and music from iTunes — multiple iTunes libraries, not just the one used for syncing. To do the same with iPod Touch, you have to get geeky: see iPhone Remote Software Streams Media to iPhone/iPod!. Even then, the user interface that you have to put up with is worse-than-primitive by Apple TV standards. For example, when you are streaming a video into your HDTV via an iPod Touch, the chapter-advance function on the Apple Remote doesn't work. Instead of zipping to the start of the next chapter, it terminates the QuickTime playback of the video. Not wonderful.

The Apple TV does YouTube. So does the iPod Touch — but not using its iPod-to-HDTV interface.

The list goes on of things an Apple TV does that an iPod Touch, hooked to an HDTV, ought to emulate. When you think about it, there are only a few things an Apple TV can do that Steve Jobs and Company can be forgiven for not putting in the iPod Touch.

The Apple TV has a 40 GB or 160 GB hard drive to store synced material, while the iPod Touch uses a lesser amount of flash memory, 8 GB, 16 GB, or 32 GB. Clearly, you won't be able to sync as much stuff with an iPod Touch as with Apple TV.

The iPod Touch has to limit the amount of power it consumes so as to provide reasonable battery life and not generate too much heat. I imagine the reason that it limits video resolutions and bitrates and won't support videos using space-saving "B-frames" (bidirectional frames) has to do with this understandable design constraint. This is why Apple TV can play certain videos that iPod Touch can't.

Still and all, once you have your video library converted for use with an iPod Touch (or iPhone), those same videos play back on an Apple TV with all the resolution and quality they are capable of providing, given their iPod-specific limitations. It would be nice if the iPod Touch could likewise output them at resolutions higher than 480i, at least when using the Apple Component AV Cable.

Now, it may be that the chipsets necessary to make that happen are just too big, or run too hot, or gobble up too much power, or add too much to the cost of the iPod Touch to be economically feasible. Even so, I would sure like to see such a hi-def output capability, via component video if not HDMI, built into a future iPod Touch.

Tuesday, August 19, 2008

iPhone Remote Software Streams Media to iPhone/iPod!

Good news! You can now get media files such as movies, music, and photos to stream from your computer to your iPhone/iPod Touch using a software package called iPhone Remote. I have a new iPod Touch, or iTouch for short, so I'll talk specifically about it, but what I say below applies equally to the iPhone.

If you have one of these units, you know that iTunes syncs media files in your iTunes library to it. Every media file that you sync to your unit gets copied to its internal memory. Mine has 8 gigabytes, which gets used up pretty fast. About 500 songs plus 2 movies plus 3 TV shows will fill up the entire 8 gigs.

Meanwhile, I have about 120 movies in my library. I've quickly gotten tired of syncing the 1 or 2 movies I want to watch next. Isn't there a way, I wondered, to stream movies to the iTouch?

This YouTube movie clued me in:

If you watch it carefully a couple of times, you may glean all the information you need to get iPhone Remote working for you. But if you want more detail, read on.

The first 6 steps in the movie are pretty much optional. They concern making it possible for iPhone Remote to stream media to your iTouch when you're out of range of your own home wireless network, by setting up a dynamic host name on the Web that will always, when used as part or a Web address or URL, access your Mac remotely.

Step 1 creates a free user account at During that step, you set up a user name and password to protect the account. Step 2 then sets up a dynamic DNS host name within that account. The purpose of these two steps has to do with giving a permanent Web-accessible host name to your wireless router's IP address.

For example, I am using as my host name. You can't click on it or type it into a browser to link to it directly, since I don't have it set up for that. What it does is serve as a proxy for the IP address of my home router, which is (slightly scrambled)

So when I go into Safari (this works best with Safari, not with my usual browser, Firefox) and go to the URL, what I see (after authenticating my identity) is:

This is the browser interface put up by iPhone Remote. It is intended for the iPhone or iPod Touch, but I can look at it in Safari on my Mac.

(To actually get this far, I need to go through an authentication phase in which I first choose to continue despite an "invalid" security certificate for my pseudo-website, and then I log in with my username and password. This is the username and password I created when I installed iPhone Remote.)

DNS, by the way, stands for Domain Name System, the system by which a domain name such as .biz can be qualified to become and further qualified to become the host name When DNS is dynamic, the Internet Protocol address of the router associated with my host name can change. My Internet provider periodically changes the IP address of my router: becomes, say, With dynamic DNS, the change is transparent when I use host name

Steps 3 and 4 in the movie also have to do with dynamic DNS setup. Something has to tell that my router's IP address has changed, whenever that happens behind my back. The DynDNS Updater, a piece of free software you can download from, sets up a "daemon" that sits in my Mac system and monitors my router's IP address. When that IP address changes, the DynDNS Updater daemon automatically updates my account at

Step 3 in the movie has you download and install the DynDNS Updater. Once that is done, Step 4 configures it. You tell it your user name and password at this stage ... which may or may not be different from the user name and password you're going to use with iPhone Remote later on. DynDNS Updater then retrieves your account information and host name from (I'm not quite sure why the movie shows the host name being manually entered in DynDNS Updater, since mine appeared automatically under User when I first fired up DynDNS Updater.)

You also want to make sure the preference is set in DynDNS Updater Preferences to automatically fire the daemon up each time you reboot your Mac.

Things get a bit trickier in Step 5: you need to forward your router's ports 5010 and 5012 to your Mac.

DynDNS Updater uses two software "ports" in your router. One becomes its "server port" and the other is its "media port." You can see this in the iPhone Remote Preferences window, once you have downloaded and installed iPhone Remote in Step 7 below:

Notice that you have to turn on the "Share media insecurely" option in order to allow your videos and music files to be played on an iPhone or iPod touch. Anyone who knows the full path name to a media file of yours (and also can authenticate with your username and password) can play your videos and music on his iPhone or iTouch.

Back to the idea of "ports": your router has to be set up to "forward" ports 5010 and 5012 to the Mac which hosts the media files you want to play on your iPhone/iTouch. In my case the Mac in question has been given the statically assigned IP address, so I have to go into AirPort Utility and do some Port Mapping on my AirPort Base Station:

The two entries in question are the two at the bottom: 5010 -> and 5012 -> You have to add those to get iPhone Remote to work.

In the movie, a Step 5 procedure for a different type of router is shown. If you have an AirPort Base Station, you should ignore it.

Also ignore Step 6, which wants you to enable dynamic DNS on your router. I'm not quite sure what this step does, but it's not applicable on an AirPort Base Station. I suspect it is yet another way to notify when the router's IP address changes.

Step 7, the next step in the movie, is a crucial one. You need to download iPhone Remote at and install it on your Mac. (Note that nothing at all gets installed on the iPhone or iPod Touch. You are not using unauthorized software or "jailbreaking" your unit.)

This is the time that you actually configure iPhone Remote's preferences, including setting up or changing the user name and password you'll be using on your iPhone/iTouch when you want to play a movie or a music file. To do this, you click on "Change Password" in the Preferences window:

Then you simply enter a Web Username and Web Password. Then you dismiss the dialog by clicking Save and in the window above click Restart Server.

This is also the time you make sure your server and media ports have the right numbers, 5010 and 5012, respectively, and that you checkmark the "Share media insecurely" option.

Once you've done that, you can close the Preferences window.

That's basically it! You're ready to start using iPhone Remote from Safari on your iPhone or iPod Touch.

Make sure that iPhone Remote is still running. You can leave the Preferences window open if it makes you feel better ... but as long as iPhone Remote is running, you're fine. Now enter your host name, followed by :5010, into Safari's address line on your iPhone/iTouch. In my case, I enter

If you get a message about an unknown security certificate at this point, touch Continue. Enter your iPhone Remote user name and password when prompted. You'll see a miniature version of:

and when you touch the Files button, you'll see a list of files and folders at your user folder level on your Mac. From there you can navigate either down the folder hierarchy or (by touching the active hot links in the blue bar toward the top of the the screen) back upward to your hard drive level or to the level of your computer as a whole. Hence, you can navigate to any movie or music file on your computer that will play on your iPhone/iTouch and, by touching its name, play it in QuickTime on the iPhone/iTouch!

Thursday, August 07, 2008

Videos for iPod Touch, Part 2

In Videos for iPod Touch, I talked about my sleek-looking new iPod Touch 8G:

No, I said, it's not an iPhone, but iPhones are wait-listed right now.

The iPod Touch shares with the iPhone the ability to sync with iTunes and play video movies and TV shows, music, podcasts, etc. But not all videos that iTunes (or my Apple TV) will play can go onto the iPod — even though the offending videos are nominally in the MPEG-4/h.264 format that the iPod expects. I expect other iPod owners have the same kinds of problem. This post is about ways around the problems.

There are actually two kinds of problem here:

  1. If a video has been encoded with a video bitrate of over 1500 kbps, the iPod won't sync to it or play it.
  2. The iPod can't sync to or play videos that have been encoded with B-frames, space saving representations of individual video frames that record differences between themselves and following frames (and from preceding frames, but that's not a problem).

The iPod simply doesn't have enough memory or processing power to cope with high-bitrate videos or with deriving current frames from following frames in the video stream.

One solution to either incompatibility problem is to re-rip the video from an original DVD. I use HandBrake to port videos from DVD to iTunes. HandBrake 0.9.2 (the current version) has several presets for iPod-compatible rips. The one which I use a slightly modified version of is "iPod High-Rez." Any of the iPod-related presets will work, in that they carefully avoid giving you B-frames and video bitrates in excess of 1500 kbps. (They also insert the mysterious "iPod atom," making the output compatible with pre-Touch video iPods.)

However, I recommend that you modify the preset, as I did, to turn on Anamorphic: Strict under Picture Settings. This allows your output file to use "anamorphic encoding" if the DVD itself does. For more on what that means, see below.

The second workaround for getting a non-iPod-playable video to play on an iPod is to do a conversion of an existing rip into a form that works with iPod.

The simplest way to do a conversion is to select the movie or TV show in iTunes and select "Convert Selection for iPod/iPhone" in the Advanced menu. iTunes will verify that the video is not already iPod-playable, and if not it will start to convert it to an iPod-usable format — a lengthy process. The output file automatically goes into ~/Music/iTunes/iTunes Music/Movies (or ~/Music/iTunes/iTunes Music/TV Shows). The file name is the same as that of the original file, modified as necessary to ensure uniqueness. The original file is left untouched.

Using iTunes to do the conversion has several drawbacks:

  • The process is super-slow. It takes iTunes much longer to convert a file than it would take HandBrake to re-rip it.
  • You can't direct the output to any folder or hard drive you want. You have to be content with iTunes' default folder.
  • You can't name the converted output file anything other than iTunes' automatic choice of file name.
  • You can't control parameters like the resolution in pixels of the video frame. In my admittedly limited experience, iTunes seemingly insists on giving the output video file a frame width of 640 pixels, with a corresponding pixel height designed to reproduce the original's aspect ratio.
The second way to do a conversion is to use QuickTime Player. That allows you more control over such things as the destination drive and folder, the output file name, the video resolution, and other useful parameters. But, like iTunes itself, QuickTime is slow, slow, slow.

I'm currently investigating a third alternative: using a third-party video converter.

I'm presently trying the $29 ImTOO iPod Video Converter for Mac:

ImTOO's website says it "can convert video and audio files such as AVI, MPEG, WMV, DivX, MP4, MOV, XviD, VOB (the video format used in DVD), MP3, AAC, AC3, etc., to iPod supported formats, including MP4, MOV, MP3, and M4A."

I have just begun to experiment with ImTOO, and I find it pretty much works as advertised. And it's fast ... as long as it isn't butting heads with a HandBrake DVD rip, in which case it slows down to a crawl in favor of HandBrake.

Still, I have found at least two of my HandBrake rips that ImTOO's conversion attempts stall out on. At least using the settings I have tried, ImTOO gets to a certain point in the conversion and then just sits there ... forever.

One drawback with ImTOO is that MPEG-4/h.264 conversions for iPod are automatically given the .mp4 file extension, which means they automatically open in QuickTime Player, when double-clicked in the Finder. The .m4v extension, allowing automatic opening in iTunes, would be better.

A second drawback with ImTOO is that if your original file was created by HandBrake with chapter stops/names, ImTOO won't carry them over to the converted file. Bummer.

Another ImTOO drawback, one that applies to other third-party converters I've tried as well, is pretty technical, so bear with me as I try to describe it. I'm going to present this somewhat technical discussion in blue, in case you want to skip it. I'll also indent it.

I have an existing rip of Harry Potter and the Prisoner of Azkaban that HandBrake made some time ago. Its video frame dimensions (per iTunes' Get Info Summary) are 853x360 pixels. This means that if I play the video in iTunes or in QuickTime Player, I'll see it in a frame that is 853 pixels wide by 360 pixels high. 853:360 corresponds to the aspect ratio of the Potter movie on DVD.

Yet if I play the video in QuickTime Player, the player's Inspector window says (under "Format") that the video frame is only 720x360! What accounts for the discrepancy between 853 and 720? And why is the default-size QuickTime viewer window actually 853 pixels wide, not 720?

The solution to this mystery is that the HandBrake output simply reproduces the 720 pixels that are physically present in each row of each video frame on the DVD. But HandBrake also detects that the widescreen DVD was "anamorphically encoded" — formatted especially for widescreen TVs — such that the DVD player stretches the 720 pixels provided per row into the space of 853 pixels, thereby widening the frame as it is being viewed.

Handbrake also detects that the nominal 480 rows of pixels in each video frame on the DVD is actually only 360 useful rows. The remaining rows at top and bottom of the screen are not even coded; they are played as black letterboxing bars. Since they're not coded on the DVD, they don't need explicit coding in HandBrake's output, either. So HandBrake outputs an MPEG-4/h.264 file that has video frames of 720x360 pixels. These 720x360-pixel frames are intended to be displayed as if each frame had 853x360 as its true dimensions.

(For a clear discussion of anamorphic encoding in general and how HandBrake deals with it, see "Guide to Anamorphic Encoding in HandBrake.")

In other words, the HandBrake output is anamorphically encoded, just like the input from the DVD. Anamorphic encoding simply means that (in this particular case) a 720x360 pixel grid is stretched at time of playback to fill an 853x360 frame.

Yet when ImTOO converts the anamorphically encoded HandBrake-ripped video, it doesn't retain the anamorphic encoding. Instead, when ImTOO is set up to use an output video size of 853x360, it internally expands the 720x360 pixels in each input frame to fit into an 853x360 box and then uses that box to derive a non-anamorphic 853x360 output file.

(Actually, the ImTOO conversion fails unless the output video size is trimmed by a single pixel to 852x360! Apparently the two numbers surrounding the "x" have to be even.)

I have found that the only way to keep the original aspect ratio and also retain all the input file's video detail is to enter iTunes' video dimensions for the input file into ImTOO's Video Size field in the "Advance" settings. In the example of Harry Potter and the Prisoner of Azkaban, that's 853x360 — trimmed to 852x360 — not the unstretched 720x360 shown in QuickTime's Inspector window. Setting the ImTOO video size to 852x360 seems to be the only way to preserve the aspect ratio of the original video frame, for this particular movie.

When ImTOO is set up to retain all the detail in the original video file and preserve the same aspect ratio, it uses more pixels in the video frame, hence contains more bits in the output file, than it really needs to. This is because ImTOO can't produce an anamorphically encoded output file even when the input file is anamorphic. So its output, in this example, has video frames whose dimensions in pixels are 852 horizontally by 360 vertically.

Unfortunately, all that careful manipulation of ImTOO's conversion parameters results in an output file from ImTOO that iTunes won't sync to the iPod Touch! The output file plays in iTunes, on Apple TV, and in QuickTime Player ... but won't work with the iTouch. My guess is that the 852x360 video frame contains too many pixels to be iPod-acceptable.

A workaround to that problem might be to use, say, 720x304 as the output frame size in ImTOO. 720:304 is basically the same aspect ratio as 852:360. When ImTOO uses a video size of 720x304 for this movie's conversion, the output file syncs to the iPod just fine.

Trouble is, there are now only 304 pixels of vertical resolution in the picture, not 360 pixels vertically. The difference is not noticeable on the iPod, whose screen resolution is only 480x320 anyway. But the video looks much softer on my Apple TV-fed HDTV.

Yet I have found that this strategy of reducing the vertical resolution to preserve the aspect ratio is what at least one other converter I've tried, TechSpansion's
VisualHub, does by default when converting videos for the iPod Touch. It is a sensible choice, given that VisualHub, like ImTOO, cannot retain anamorphic encoding.

In fact — please note this well — the only reason I have any objection at all to this conversion strategy used by ImTOO and VisualHub is that I prefer to end up with a single video file that has all the resolution of the original DVD and plays on Apple TV as well as on iPod.

Yet the only way I have found to do this is to use anamorphic encoding that is honored by iTunes, Apple TV, and iPod ... and none of the converters I've tried so far can do that. HandBrake alone seems to be able to produce anamorphically encoded output that works with all my software and all my devices. That is why I plan to re-rip all my existing iPod-incompatible DVD rips with HandBrake, rather than converting the existing rips with ImTOO or VisualHub.

Note: ImTOO has in its advanced options, in addition to the Video Size parameter, an Aspect parameter. If I set the former to 720x360 for the Potter movie and the latter to 2.37 (852 ÷ 360), I get output that mimics the input when played in QuickTime Player. That is, it shows as 720x360 under Format in the Inspector window, while actually playing as 852x360. Thus, it would seem to be anamorphically encoded. However, neither iTunes nor the iPod will play it at 852x360, only at 720x360, which gives the wrong aspect ratio and distorted image geometry. I have no idea why iTunes/iPod honor the anamorphic nature of the HandBrake-ripped file but not of the ImTOO-converted file.

OK, that's the end of the admittedly technical discussion about various iPod video converters' lack of support for "anamorphic encoding" that works in all my software and in all my devices. There is, however, an important lesson to be learned from that discussion, one that all iPod Touch owners need to hear. It is this: contrary to what you may have heard elsewhere, the iPod Touch (and presumably the iPhone) can play videos that have more pixels in the video frame than the nominal 480x320 screen resolution of the playback device, the iTouch or iPhone, can display!

iPod Touch videos can have more than 640 pixels in their video frame width, which I previously thought to be the maximum number of bits allowed! I don't know what the true upper limit is as yet, but it's at least 720 pixels of horizontal resolution! (There may also be an upper limit, at present unknown, on the product of the horizontal resolution in pixels and the vertical resolution in pixels.)

Of course, you'll see at best only 480x320 resolution on the iPod itself. But the same file can be played on, say, Apple TV with full resolution. Cool!

Monday, August 04, 2008

Videos for iPod Touch

My new iPod Touch 8G (for 8 gigabytes of storage) is a $299 marvel. Sleek-looking, too:

No, it's not an iPhone, but iPhones are wait-listed right now.

The iPod Touch shares with the similar iPhone the ability to sync with iTunes and play videos, music, podcasts, etc. The videos can be movies or TV shows downloaded from the iTunes store. Or they can be videos you yourself have created, including those you have ripped from your collection of DVDs (see earlier posts in my Ripping DVDs series for more on that).

I have an extensive library of movies (and TV shows) that I have ripped from DVDs, usually using HandBrake. They were converted by HandBrake from the MPEG-2 format used on DVDs into the MPEG-4/h.264 format, the increasingly common format used in Apple products: iTunes, Apple TV, and the iPhone and video iPods, including the iPod Touch.

Only problem is, some of my MPEG-4/h.264 videos which play fine in iTunes and on my Apple TV can't be copied to my iPod Touch. When I try to sync them, I get an error dialog such as this one:

Some of the videos in your iTunes library, including the video "Notorious", were not copied to the iPod "Eric's iPod Touch 8G" because they cannot be played on this iPod.

Expanding the dialog box reveals:

"Notorious" was not copied because the video format is not supported by the iPod "Eric's iPod Touch 8G".

I have learned that there are three usual suspects:

  1. The video file does not contain an "iPod atom."
  2. The video file was encoded with "B-frames."
  3. The video file has too high a video bitrate, over 1500 Kbps.

Of course, if any of the videos are not shown in iTunes' Get Info Summary panel as being of kind: (Protected, or not) MPEG-4 video file using video codec: H.264 with profile: Low Complexity, then that would be yet another problem entirely. Other formats/codecs/profiles are not iPod-playable.

Whether or not an MPEG-4 video file is "Protected" — copy protected, that is, per the iTunes Store's Digital Rights Management protocols — makes no actual difference to iPod playability. The files your get from the iTunes store will be protected, of course, but they'll work fine on an iPod Touch. The files you rip from DVDs will not be copy protected at all. But to also work fine on iPod Touch, a video file you make yourself must be MPEG-4/h.264/Low Complexity, and it must adhere to certain extra rules.

HandBrake knows about all these rules, and if you use one of HandBrake's built-in iPod presets — I recommend "iPod High-Rez" — you'll always get an output file that is iTouch-compatible.

But several of my "legacy" rips aren't iTouch-compatible, as it turns out. Some of them were ripped by an earlier version of HandBrake (the current version is 0.9.2) that didn't always make iPod-compatible output files. At that time, I had no idea about any restrictions on iPod compatibility, and didn't really care. I was primarily interested in getting the best possible results for my Apple TV. Now, I wish I had had more foresight.

Anyway, here is more about the three usual suspects:

1. What is the mysterious "iPod atom"? It is apparently nothing more than a sequence of bytes that starts with the four hexadecimal characters 'uuid' followed by the parameter '1200', also in hex. This goes into the so-called "MPEG-4 file container" as "metadata." It magically allows iTunes to sync the video to certain picky early video iPod models (but not the iPod Touch or iPhone, which ignores the "iPod atom").

For early video iPod owners: if a video file's only flaw is the lack of an iPod atom, I am given to understand that AtomicParsley can help. According to this discussion, one can download and install a certain special version of AtomicParsley and then use the following command line in Terminal to insert an iPod atom in any MPEG-4 video file:

AtomicParsley OUTPUT.mp4 --DeepScan --iPod-uuid 1200 --overWrite

where OUTPUT.mp4 represents the name of the video file. You need to change OUTPUT.mp4 to the name of the MPEG-4 file you wish to modify. It's best to copy the original file and work only with the copy. (I assume the extension .m4v, where applicable, works also.)

I tried this with the 0.9.0 version of AtomicParsley, which is the only one I could actually find on the Internet. It simply did not work at all as an inserter of iPod atoms. Then I read the discussion referenced above a bit more closely and learned that I really need a certain "subversion" of AtomicParsley that does support this procedure. Unfortunately, I could not locate that subversion.

However, I am also led to believe that the "iPod atom" is needed only for the so-called 5th-generation and 6th-generation video iPods, the ones with the truly tiny video screens, that came along prior to the iPod Touch and the iPhone. The iTouch and iPhone don't care about the presence or absence of the "iPod atom," one way or the other.

2. MPEG-4 videos can optionally use so-called "B-frames." When they do, no iPod model to date can play them.

B-frames are "bidirectional," in that they are streamlined video frames that represent only the video information that has changed in that particular frame, compared to a prior video frame or a following video frame. B-frames make for smaller MPEG-4 files, because the ability to key off a later frame, not just an earlier one, can result in there being far fewer bits in the file.

Forcing the MPEG decoder to scan ahead to look at following frames, though, is not supported for iPods. It requires too much memory and too much processing overhead. However, iTunes can do it; so can the Apple TV.

If you rip a DVD especially for Apple TV in HandBrake, HandBrake will use B-frames ... and the resulting output file won't play on an iPod, no matter what you do.

3. Every MPEG-4 file has a certain "total bitrate." If you look at iTunes' Get Info Summary for the file, you'll see both a bitrate (such as 159 kbps) and a total bitrate (such as 1657 kbps). The first is how many bits (or thousands of bits) per second are used for the audio. The latter is how many are used for the video and audio, together. If you subtract the former from the latter you'll get the video bitrate, in this case, 1498 kbps. It has to be 1500 or less to work on an iPod.

(Actually, I seem to have some files where the crucial figure is just a little over 1500 kbps, but the videos play OK on my iPod. I can't explain why this is.)

So those are the three "usual suspects" that can keep an otherwise good MPEG-4/h.264 video file from working on an iPod Touch or iPhone. The first doesn't actually affect the iPod Touch or iPhone, only earlier video iPod models.

The second and third affect all video iPods. If you have a file which uses either B-frames or too many bits per second for the video (or both) you'll need to do one of two things to get the movie, TV show, or whatever to work on an iPod. Neither choice is easy.

The first choice is to re-rip your video from scratch. It's the choice I recommend, where feasible, for reasons that will be made clear as I discuss the second choice in my follow-on post, Videos for iPod Touch, Part 2.

If you do elect to re-rip your video, you need to make sure you do it in such a way as to produce an iPod-playable output file. You need to include an iPod atom, assuming you are using an earlier-model video iPod (even if you aren't, including the iPod atom doesn't hurt anything). You need to make sure no B-frames are used in the output. And you must make sure the video bitrate is 1500 kbps or less.

If you are using HandBrake 0.9.2 to do the ripping, the easiest way to avoid going wrong is to use one of the included presets for the iPod or iPhone. These include:

  • iPhone / iPod Touch
  • iPod High-Rez
  • iPod Low-Rez

I find "iPod High-Rez" ideal for my purposes, as it automatically includes the iPod atom in case it's needed, spurns B-frames, and sets 1500 kbps as the maximum video bitrate.

I actually have created my own modified version of this preset, as I (owing to poor hearing) like to include English-language subtitles on all my rips. I strongly recommend that you modify the preset, as I did, to turn on Anamorphic: Strict under Picture Settings. This allows your output file to use "anamorphic encoding" if the DVD itself does. More on what that means can be found in Videos for iPod Touch, Part 2.

The second workaround for getting a non-iPod-playable video to play on your iPod is to use special software to do a conversion. I'll cover that option in Videos for iPod Touch, Part 2.