HOWTO get YouTube video content onto your Apple iPod

Thursday, June 19th, 2008 at 11:00 pm | 3,831 views | trackback url
Tags: , , , ,

I’m sure you’ve heard of YouTube by now.

YouTube is a video sharing website where users can upload, view and share video clips with other visitors to the site. YouTube was created in mid-February 2005 by three former PayPal employees.

The San Bruno-based service uses Adobe Flash technology to display a wide variety of user-generated video content, including movie clips, TV clips and music videos, as well as amateur content such as video blogging and short original videos. In October 2006, Google Inc. announced that it had reached a deal to acquire the company for US$1.65 billion in Google stock.

In August 2006, The Wall Street Journal published an article revealing that YouTube was hosting about 6.1 million videos (requiring about 45 terabytes of storage space), and had about 500,000 user accounts.

A YouTube search done today reveals more than 83 million videos and many millions of user channels. In fact, there are so many, YouTube no longer lists how many and restricts all searches to only 1,000 results or less.

Not bad for a company that is completely unprofitable and whose revenues being noted as “immaterial” by Google in a regulatory filing. The bandwidth costs to operate YouTube alone are estimated at approximately $1 million a day.

But enough about the numbers and dollars, let’s talk about how to get that content onto your Apple iPod video device!

I find myself with lots of “spare time” around my commutes, waiting for trains, driving, late at night while I turn off my brain and relax and many other places. I’ve collected lots of audiobooks, music streams and videos that I watch and discard from my ipod on a regular basis. A lot of the video content I watch now comes directly from YouTube.

The first thing you’re going to need is a copy of YouTube Downloader. This is a very simple Python script that takes a YouTube URL as input and will download and copy the file to your local system.

There are versions of youtube-dl available to all of the current Linux distributions if you simply install it with your normal packaging tools (yum, aptitude, synaptic, etc.), as well as a detailed guide to installing YouTube Downloader under Windows XP for those stuck on that legacy platform.

That’s step one.

The second step is to grab a current copy of the ffmpeg Video Encoder. Your Linux distribution may have this already, but if not, you can just download the latest source with SVN or Git and build it yourself.

For Windows users, you can either download a compiled version (you’ll need a copy of 7-zip to unpack it), or follow this HOWTO and build your own on Windows from source.

If you’re building this on Linux or Windows, make sure you include libfaac support in your build. This is critical, because iTunes won’t accept the format if it isn’t in MPEG-4 format (or AVI, but AVI files are enormous).

At the very least, use the following options when building ffmpeg from source:

./configure --prefix=/usr --enable-gpl --enable-pthreads 
            --enable-libvorbis --enable-libtheora 
            --enable-libgsm --enable-libfaac --enable-libfaad 
            --enable-liba52 --enable-shared --enable-libschroedinger 
            --enable-libx264

If you got it right, you should see something similar to the following:

install prefix            /usr
C compiler                gcc
.align is power-of-two    no
ARCH                      x86_64 (generic)
big-endian                no
MMX enabled               yes
CMOV enabled              no
CMOV is fast              no
EBX available             yes
EBP available             yes
gprof enabled             no
debug symbols             yes
strip symbols             yes
optimizations             yes
static                    yes
shared                    yes
postprocessing support    no
software scaler enabled   no
new filter support        no
filters using lavformat   no
video hooking             yes
Imlib2 support            no
FreeType support          yes
network support           yes
IPv6 support              yes
threading support         pthreads
SDL support               yes
Sun medialib support      no
AVISynth enabled          no
liba52 support            yes
liba52 dlopened           no
libamr-nb support         no
libamr-wb support         no
libdc1394 support         no
libdirac enabled          no
libfaac enabled           yes     <--- This is what you want to see
libfaad enabled           yes
libfaad dlopened          no
libgsm enabled            yes
libmp3lame enabled        no
libnut enabled            no
libschroedinger enabled   yes
libtheora enabled         yes
libvorbis enabled         yes
libx264 enabled           yes
libxvid enabled           no
zlib enabled              yes
bzlib enabled             yes

Build it and install it. Now you should have a working ffmpeg encoder.

The third step is to encode the video and lastly, sync it to your iPod.

In this process, I'm going to use the example of "Groovy Dancing Girl" starring "Sophie Merry" from Ireland. She created an Internet sensation with her YouTube video, but now she's become quite famous as a new face on Etam's product lines.

This was a short-enough video to use as an example, but in practice, I'm normally converting 1-2 hour videos found on YouTube for watching on my iPod. Inbox Zero with Merlin Mann is a good example of just such a video.

Let's put all the steps together:

  1. Download the video using youtube-dl. We're going to pass it the -l (that's an 'ell', not a 'one') option so we save the video itself with the original title as it appeared on the upstream YouTube URL.

    $ /usr/bin/youtube-dl -l http://www.youtube.com/watch?v=Sr2JneittqQ
    Retrieving video webpage... done.
    Extracting video title... done.
    Extracting URL "t" parameter... done.
    Requesting video file... done.
    Video data found at http://208.117.254.159/get_video?video_id=Sr2JneittqQ&origin=sjc-v78.sjc.youtube.com
    &signature=7324C862B157C2C77781B15449C09F83FEBDAC71.89013B87A16736E75BB13B354
    A03F528D0CEABFC&ip=65.172.152.98&ipbits=16&expire=1213949408&key=yt1&sver=2
    Retrieving video data: 100.0% (   8.81M of 8.81M) at   85.50k/s ETA 00:00 done.
    Video data saved to Groovy Dancing Girl-Sr2JneittqQ.flv

  2. Encode the video using the ffmpeg you just built above:

    $ ffmpeg -i Groovy\ Dancing\ Girl-Sr2JneittqQ.flv -threads 4 -b 604k -ac 1 -ab 256k -ar 44100 -vol 500 Groovy\ Dancing\ Girl.mp4
    FFmpeg version SVN-r13835, Copyright (c) 2000-2008 Fabrice Bellard, et al.
      libavutil version: 49.7.0
      libavcodec version: 51.57.2
      libavformat version: 52.16.0
      libavdevice version: 52.0.0
      built on Jun 19 2008 22:21:44, gcc: 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
    
    Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 29.92 (359/12)
    Input #0, flv, from 'Groovy Dancing Girl-Sr2JneittqQ.flv':
      Duration: 00:03:42.35, start: 0.000000, bitrate: 56 kb/s
        Stream #0.0: Video: flv, yuv420p, 320x240, 29.92 tb(r)
        Stream #0.1: Audio: mp3, 22050 Hz, mono, 56 kb/s
    Output #0, mp4, to 'Groovy Dancing Girl.mp4':
        Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 604 kb/s, 29.92 tb(c)
        Stream #0.1: Audio: libfaac, 44100 Hz, mono, 256 kb/s
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #0.1 -> #0.1
    Press [q] to stop encoding
    frame= 6654 fps=571 q=2.0 Lsize=   18676kB time=221.63 bitrate= 690.3kbits/s    
    video:16489kB audio:2055kB global headers:0kB muxing overhead 0.708581%

    This will give you a video called "Groovy Dancing Girl.mp4", which is of type:

    VIDEO:  [mp4v]  320x240  24bpp  29.917 fps

  3. Now drag this .mp4 video directly onto your iTunes application window to add it to your Video library, and iTunes will sync it to your iPod the next time you connect. Voila!

    If you're solely a Linux user, you can use Songbird (a Mozilla project), or install Amarok (my personal favorite, absolutely blows away iTunes in features).

If you have any questions, contact me or leave your comments here and I'll do my best to help you out.

Good luck!

Last Modified: Monday, July 16th, 2012 @ 10:02

Leave a Reply

You must be logged in to post a comment.

Bad Behavior has blocked 238 access attempts in the last 7 days.