Friday, March 23, 2007

mencoder goodness for TivoDecode Manager

As a follow up to yesterday's entry, I have finally managed to compile a custom Mac Intel Core 2 Duo build of mencoder that provides drop in functionality to TivoDecode Manager (TDM) while cutting encoding times in half. 7 hours of sleepless night-time later I present to you the new & improved Mac Intel-optimized mencoder binary (7.5MB).

Here are the benchmarks I have so far:
TDM's provided mencoder binary

$ time /Applications/TiVoDecode\ Manager.app/Contents/Resources/mencoder -af volume=13:1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -demuxer lavf -lavfdopts probesize=128 -oac lavc -ovc lavc -lavcopts keyint=15:aglobal=1:vglobal=1:coder=1:vcodec=mpeg4:acodec=aac:vbitrate=1800:abitrate=128 -vf pp=lb,scale=640:480,harddup -o ~/Desktop/clip.tdm.mp4 ~/Desktop/clip.mpg

real 1m9.518s
user 1m7.768s
sys 0m0.847s


Mac Intel-optimized mencoder binary

$ time ./mencoder -af volume=13:1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -demuxer lavf -lavfdopts probesize=128 -oac lavc -ovc lavc -lavcopts keyint=15:aglobal=1:vglobal=1:coder=1:vcodec=mpeg4:acodec=aac:vbitrate=1800:abitrate=128 -vf pp=lb,scale=640:480,harddup -o ~/Desktop/clip.custom.mp4 ~/Desktop/clip.mpg

real 0m29.061s
user 0m27.210s
sys 0m0.743s


and here are the file sizes

$ ls -ltr clip.*
-rw-r--r-- 1 xxx xxx 12654193 Mar 22 01:59 clip.mpg
-rw-r--r-- 1 xxx xxx 20839638 Mar 23 01:50 clip.tdm.mp4
-rw-r--r-- 1 xxx xxx 20859165 Mar 23 01:51 clip.custom.mp4


and just for fun, I lowered the bitrate down to 600kbs so that it actually does compression and here are the times and filesizes.

TDM:

real 1m7.573s
user 0m59.340s
sys 0m0.904s

Intel-optimized

real 0m31.287s
user 0m25.143s
sys 0m0.787s


$ ls -ltr clip*
-rw-r--r-- 1 xxx xxx 12654193 Mar 22 01:59 clip.mpg
-rw-r--r-- 1 xxx xxx 8135459 Mar 23 02:26 clip.custom.mp4
-rw-r--r-- 1 xxx xxx 8131077 Mar 23 02:27 clip.tdm.mp4


And well if you've managed to wade through all that I guess I'll leave you with some installation instructions for the mencoder binary.
1. Download
2. Backup old mencoder binary
mv /Applications/TiVoDecode\ Manager.app/Contents/Resources/mencoder /Applications/TiVoDecode\ Manager.app/Contents/Resources/mencoder.old

3. Copy in new mencoder binary
cp mencoder /Applications/TiVoDecode\ Manager.app/Contents/Resources/mencoder

4. Enjoy (Did I mention this probably only works for the Core2Duo??)
5. Digg this

Thursday, March 22, 2007

Simple performance boost for TivoDecode Manager

With the release of AppleTV I started playing around with the TivoDecode Manager again tonight and started converting content from my Tivo. While playing around with the latest version of TDM (2.1), I noticed that the version of mencoder bundled with TDM was completely unoptimized. Here is the output from their build of mencoder

$ /Applications/TiVoDecode\ Manager.app/Contents/Resources/mencoder
MEncoder dev-SVN-r21629-4.0.1 (C) 2000-2006 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T7600 @ 2.33GHz (Family: 6, Model: 15, Stepping: 6)
MMX supported but disabled
MMX2 supported but disabled
SSE supported but disabled
SSE2 supported but disabled
CPUflags: Type: 6 MMX: 0 MMX2: 0 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled for x86 CPU with extensions:


Now compare this output to the version recommended by ffmpegX from the sourceforge build

$ /Applications/ffmpegX.app/Contents/Resources/mencoder
MEncoder dev-CVS-060307-04:23-4.0.1 (C) 2000-2006 MPlayer Team
Mac OSX static build for ffmpegX
CPU: Intel (Family: 6, Stepping: 6)
FIXME:Hardenabling SSE and SSE2 without detection
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2


Notice anything missing? Yeah. TDM is completely ignoring the MMX and SSE registers!

So a quick timing on a 87 second video clip yielded the following with TDM's mencoder

real 1m10.966s
user 1m8.981s
sys 0m0.565s


The same timing with identical options on ffmpeg's mencoder yielded a result of

real 0m24.834s
user 0m23.379s
sys 0m0.443s


That's about a 50% reduction in encoding time!

Of course the -lavfdopts probesize=128 -lavcopts aglobal:1:acodec:aac options did not work and had to be stripped or changed to compatible options in both, but the data is somewhat clear that TDM needs to recompile their mencoder with SSE and MMX extensions enabled.

So last night I decided to undertake the task of doing all that and BLEH. It's harder than it sounds. Apparently I'm missing the faac library among other things and compiling the libfaac on the Mac isn't the most straight-forward task. It looks like I'll be pushing this task to another day, but the findings so far are interesting to say the least.

Wednesday, March 21, 2007

The Apple TV debate continues

Well, if you haven't read Walt Mossberg's review of AppleTV yet, this is a good place to start. Of course many people will argue that the AppleTV is a niche product, or has limited content, or doesn't have DVR functionality or this or that. Personally, I've already come up with a great use for the AppleTV that fits my needs and possibly the needs of millions of people.

Tivo. But wait a second, AppleTV isn't a DVR. That's not my point. My focus is the subset of people out there who have a Mac, already have Tivo service, and have two or more TVs, but have only one Tivo. Now Tivo is great, but is made better by TivoDecode Manager(TDM) for the Mac. For most TV owners, the TV content is stuck on your Tivo and one TV unless of course you don't mind watching your TV shows on your computer. But that is exactly what AppleTV is here to solve. Moving content away from your computer and to your TV.

With TDM I can batch queue all the new shows on my Tivo to have them converted to an iTunes compatible TV show or movie while I am asleep or at work, ready to be watched in a different room at my leisure. Now I don't have to fight over what's on the Tivo and be limited to watching it on the one TV that it is hooked up to. Of course I could always take the plunge and purchase another Tivo and record even more shows, but in reality, there aren't enough TV shows to keep a Dual-Tuner Tivo busy. Plus, by the time I purchase another Tivo and then the monthly service, I've already sunk another $350 into Tivo.

Of course there are plenty of other ways to use the new AppleTV, and everyone will find a way to make it work for them, but as always, this is just my $0.02.