Please Sir May I Have Another

A fanatic, says George Santayana, is somebody who redoubles their efforts when they have forgotten their aim.

Fingerpointing, today, is left as an exercise to the reader.

From the FFmpeg Download and CVS page:

In short, if you want to work with FFmpeg, you are advised to go along with CVS development rather than relying on formal releases. CVS snapshots work really well 99% of the time so people are not afraid to use them.

I’m special; I’m that one percent. I’m willing to pretend that it’s the top one percent! Special like a fox!.

FFMpeg is a swiss-army-knife media converter. It’s really useful; it’s also total attention-deficit-teenware, but hey, if you’re comfortable butchering other people’s source code, it’s good enough! It’s only got about a hundred different compiled-time options, and the version that comes packaged for Ubuntu doesn’t “do” stuff like, well, basically anything you’d ever want to use it for, and if you don’t like that you can, apparently, choke on it.

But I want to convert my video files, so that I can watch them on my new toy.

The extended entry contains all the gore about how I got the whole thing to actually work, but really, I just want to say that when more than two people use your software, especially when more than two people incorporate your sofware into other projects, running a project with no version numbering or point releases, on CVS access alone is about two parts mind-bending idiocy and one part gibbering insanity. It’s some sort of Heisenberg usability principle; it may or may not work reliably or at all depending on the exact moment your users checked out their code.

Which is why, of course, you’ll need to make some changes to the ffmpeg code, for this to work. I’m sure I’m making this more difficult for myself than I had to, but it’s Linux, so you already knew that. Read on; the funny bit is right at the end!


When you’re done with this, ffmpeg will have a lot more things compiled into it than you strictly need for the iPod video conversion. I’ve gone that route because I’m a big fan of pulling the bandaid off quickly, and I really didn’t want to have to do this more than once.

Here we go:

  1. You need a CVS checkout of the FFMpeg source, which you can get by doing this:

    cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg

    Leave it alone for the time being, we’ll get back to it.

  2. You’ll need the x264 source from Videolan. I downloaded the latest daily snapshot in convenient tarball form. If you don’t have nasm you’ll need that too, but “apt-get install nasm” will take care of that. Then it’s gunzip, untar, configure, make, make install. If you’ve made it this far, you know the drill.
  3. The lame-dev packages provide by Ubuntu just wouldn’t work for me for some reason, and you need ones that will. What did work for me was the latest LAME source tarball. Again, gunzip, untar, configure, make, make install.
  4. FFMpeg needs a bunch of dev packages to compile with all its bells and whistles, so:

    sudo apt-get install libmpcdec-dev libmpeg3-dev libtheora-dev libfaad2-dev libfaad2-dev libfaac0-dev libdts-dev libxvidcore4-dev

    There might be some in there you don’t need, and you might be missing some I already had, and didn’t explicitly ask for. My notes on this consist of “history > grep apt-get” and I’d be glad for any feedback.

  5. The ugly bit. In your ffmpeg/libavcodec directory, pthread.c and add this up at the top:


    #ifndef HAVE_THREADS
    #define HAVE_THREADS 1
    #endif

    Then, in utils.c, replace “#if !defined(HAVE_THREADS)” near the bottom with “#ifndef HAVE_THREADS”, save and exit. I’ll have diffs up for this shortly, for those of you diff-inclined.

  6. Going back to our FFMpeg directory, I used the command line options detailed in this shell script, which you can copy and chmod +x if you like. I wrote that while I was playing dependency whackamole. Now, with a little luck and another chmod +x, you should be able to do the ./myconf, make and make install that will give you a does-everything version of ffmpeg. Halleluja.

Once all that’s done, I’ve got a present for you: a cute little shell script that does the messy bits for you, takes in your videos of (I believe) whatever kind and dumps out your ipod-friendly movies out the other side. You can even ask it if ffmpeg already has the stuff you need installed. Dirt simple, and dirt simple to use, and I hope you like it.

If you have a Linux box to run the conversion on and and a Windows or Mac box to plug your iPod into, it’ll probably work great.

I hope you find this useful. I hope you can, and do, use it.

Because, here’s the punchline, after all of that effort, I can’t use it..

Because gtkpod doesn’t sync videos, only music.

Khaaaan!

6 Comments

  1. Posted February 25, 2006 at 10:52 pm | Permalink

    Truly awesome, Mike. Truly molar-grindingly awesome.

    Also, the most minor of minor nits:

    sed ’13,16s/^\t/ /’ ipodconv > ipodconv2

    >

  2. Mike Bruce
    Posted February 25, 2006 at 11:33 pm | Permalink

    The latest version of gtkpod allegedly supports video (from 0.99.0).

    Also you could just use mencoder instead of ffmpeg? Irritatingly baroque to use, but mplayer/mencoder has non-CVS releases and compiles with no hassles. I think they just include their own snapshot of ffmpeg/libavcodec.

    There’s also a package called “transcode” that you might want to check out.

    And it isn’t clear what you’re using x264 for?

  3. Alex
    Posted February 26, 2006 at 2:29 am | Permalink

    I use ffmpegX every once in a while. It’s a GUI wrapper for ffmpeg that’s about as atrocious as such a thing would pretty much have to be.

    The awfulness off ffmpegX’s UI, and the vaguely baroque (by Mac standards) install … It was like using a linux distro as my primary OS!

  4. Alex
    Posted February 26, 2006 at 2:35 am | Permalink

    Oh, yeah. For mac people:

    http://howto.diveintomark.org/ipod-porn-conversion-guide/

    Ignore the title. The site’s quite SFW, title setting off keywords aside.

  5. Mike Hoye
    Posted February 26, 2006 at 7:36 am | Permalink

    Thanks, Ben, made the change.

    Mike: Transcode and mplayer both rely on ffmpeg. x264 because h.264 is Apple’s new video codec and I thought I might need it. Also, because this is a completist exercise.

  6. Mike Bruce
    Posted February 26, 2006 at 1:54 pm | Permalink

    Yes, they both rely on ffmpeg, but mplayer (at least) includes its own copy, so you don’t have to deal with any CVS-version woes.