A Django site.
April 20, 2008

Hans Fugal
no nic
The Fugue :
» 64-bit Transcoding

I have a 64-bit desktop machine, that has rarely been run as a 64-bit machine. The hassle was too great and I couldn't really see a reason to put up with it.

I think that 64-bit support has come a long way in the meantime, and it may be time to try it out. It sounds like a livable situation. So with the pending release of the next Ubuntu version I'm thinking of wiping and going 64-bit.

One of the primary motivators is that 64-bit holds some promise for transcoding video, and now that I have an HDHomeRun to capture over-the-air HDTV signals, I will be doing quite a bit of video transcoding for MythTV (to save disk space—a full-quality HDTV program is about 9 gigabytes per hour).

But before taking the plunge, I thought I'd do an empirical test and see if there would be any real savings. I captured a couple of minutes of HD content from PBS, then transcoded 60 seconds using ffmpeg and mencoder. Then I did the same with the Ubuntu 64-bit live CD. The 64-bit execution difference was statistically significant.

ffmpeg was about 1.12 times as fast—a savings of about 10 seconds per minute, or 10 minutes per hour.

mencoder was about 1.08 times as fast—similar savings.

I didn't test mythtranscode itself, since getting it installed in a live CD environment would be too much work. I also must point out some other possible confounding variables. I used the Ubuntu 7.10 versions of ffmpeg and mencoder in 32-bit, and the Ubuntu 8.04 versions in 64-bit. Did both projects improve their code to be about 10% faster in the meantime? Unlikely, but perhaps not unfathomable.

So will I make the switch? I don't know yet. 10% faster is significant, but not obviously worth it. I'll have to think about it.

For the curious, here's my numbers. I did at least two runs of each to check for agreement, and what you see is the average. Of course, these would not be the settings you'd necessarily use to transcode—ffmpeg has a pretty low default bitrate for example—but I think we can agree the speedup is likely to be in the same ballpark no matter what settings you're using.

# 64-bit    32-bit
# 86 s      95 s
time ffmpeg -y -t 60 -i foo.avi -acodec copy bar.avi
# 55 s      64 s
time ffmpeg -y -t 60 -i foo.avi -acodec copy -s 640x480 bar.avi
# 83 s      90 s
time mencoder foo.avi -oac copy -ovc lavc -frames $[30*60] -o baz.avi

February 19, 2008
» Flash video encoding with ffmpeg

I just had occasion to convert a handful of MPEG-1 videos to Flash video format, and I thought I'd better document how I did it because I'm certain to need to do it again.

The main tool I used was ffmpeg, which I needed to compile and install on my Powerbook. Because I expect to want to use ffmpeg with a few additional features, I installed slightly more than what was strictly necessary for this project (ffmpeg and libmp3lame would have been enough this time around).

  1. libmp3lame was already installed. If it hadn't been, the source code is available at lame.sourceforge.net. It's a fairly simple ./configure ; make ; sudo make install process.
  2. libogg and libvorbis were also already installed. If they hadn't been, I'd have gone looking for the code at xiph.org.
  3. libtheora wasn't installed. Once again, the code is at xiph.org, and it's a simple configure, make, make install.
  4. libx264 wasn't installed. That code needed to come from Subversion:
    svn export svn://svn.videolan.org/x264/trunk x264
    Once again, a simple configure, make, make install.
  5. The ffmpeg code itself also comes from Subversion, and the configure command requires a few extra switches:
    svn export svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
    cd ffmpeg
    ./configure --enable-libmp3lame --enable-gpl --enable-libx264 --enable-libtheora --enable-libvorbis
    make
    sudo make install
  6. Once the software was installed, the actual conversion was a fairly simple shell script:
    for i in *mpg
    do
      ffmpeg -i "${i}" -ar 22050 -ab 96 -aspect 4:3 -r 12 -f flv -s 320x240 -acodec libmp3lame -ac 1 "${i}.flv"
    done

These steps were based on this older post, with some updates required because of changes in ffmpeg options and because I wanted to add in Vorbis, Theora and x264 support in my ffmpeg build.

, ,