oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Putting Google Video onto Your iPod
Pages: 1, 2

The unescape Utility

Unfortunately, there's no "unescape URL" utility built into the Macintosh (or at least not one that I could find). There is, however, an unescape routine distributed as part of the standard developer library. The following utility takes one argument, an escaped URL (in quotes, please!) and returns it unescaped.

// cc unescape.c -o unescape -lcurl
#include <curl/curl.h>
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
  if (argc < 2)
      fprintf(stderr, "Usage: %s URL\n", argv[0]);
  printf("%s\n", curl_unescape(argv[1], strlen(argv[1])));

If you don't have the developer package installed, you'll find a pre-compiled version of this utility here.

Setting Things Up

You'll need to create both the getGoogle shell script and unescape.c source as plain text files in a new folder on your Desktop. Launch Terminal and change directories to that folder.

$ cd ~/Desktop/Escapestuff
$ ls
getGoogle       unescape.c

Compile the unescape utility. (Feel free to ignore the warnings.)

$ cc unescape.c -o unescape -lcurl
unescape.c: In function 'main':
unescape.c:14: warning: incompatible implicit declaration of built-in function 'exit'
unescape.c:17: warning: incompatible implicit declaration of built-in function 'strlen'

Make the getGoogle shell script executable.

$ chmod 755 getGoogle

Now you're ready to perform the download. The getGoogle utility takes one argument, the main Google Video URL in double quotes. curl provides live updates as the download progresses.

$ ./getGoogle ""
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.3M    0 12.3M    0     0   156k      0 --:--:--  0:01:20 --:--:--  160k
File has been output to ~/Desktop/GoogleOut.flv

After the download ends, you'll have a brand new file on your desktop: GoogleOut.flv.

Converting the Video

figure 3

Figure 3: Drop the FLV file onto the From field to start setting up your encoding.

It should come as no surprise that the FLV video you download will not play back on your iPod. Or in QuickTime. Or pretty much anything else. Even VLC won't play it--they dropped support as of 0.8.2. (Sure, if you've got $30 to blow, you could download the Wimpy AV player, which offers FLV support for both Windows and OS X, but let's get back to the whole iPod thing, right?)

Here's where the fabulous ffmpegX comes in. Or at least it does for the Mac. Windows users? You'll have use it the ffmpeg command-line utility or search for a Windows-based ffmpeg GUI like PSPEnc. With ffmpegX, converting your videos couldn't be simpler.

After installing ffmpegX (make sure to install all those extra components, namely mplayer, mencoder and mpeg2enc), just follow these steps:

  1. Drop the GoogleOut.flv file onto the From field.
  2. Select PSP MP4 from the To pop-up menu.
  3. If desired, edit the Save As output filename.
  4. Click Encode.

An ffmpegX progress window opens, letting you keep track of your encoding job. When finished, it chimes. The new MP4 file appears on your desktop (unless you chose to save it somewhere else) and is ready to play in QuickTime and iTunes.

All that's left now is to add your movie to your iPod. Drag the new MP4 file into your iPod playlist in iTunes. (You can also drop it directly onto the iPod icon there if you prefer.) iTunes copies the video and places it into your iPod's Videos-->Movies collection. Simply select it, sit back, watch, and enjoy.

Editor's note: Just in case you were wondering, it's OK to download this content for your own personal use. Here's the word from Google: "Accordingly, you agree that you will not copy, reproduce, alter, modify, create derivative works, or publicly display any content (except for your own personal, non-commercial use) from the Site."

Erica Sadun has written, co-written, and contributed to almost two dozen books about technology, particularly in the areas of programming, digital video, and digital photography.

Return to the Mac DevCenter