A simple little script

I recently started watching some anime again. I’ll admit it’s a little weird after being away for ~10 years, but it’s still fun.  As always, I prefer watching it with the original Japanese audio and English subtitles.  My Japanese was never the best, but it beats dealing with the ugly lip-syncing issues.

Anyway, as my PVR software of choice (still) does not handle internal subtitles in a Matroska container, I’m forced to launch mplayer to play back the files.  As far as I’m aware, mplayer won’t automatically detect if there is a multi-channel audio track and output said track to the receiver.  In my experience, without telling it to, it just plays back in stereo.

As most of the videos I’ve ripped contain a surround sound track (AC3 or DTS) and my HTPC is connected to a receiver that decodes those tracks, I’m fairly keen on playing them back.  Again, if MythTV supported embedded SRT files, I wouldn’t have this problem.

My solution was to write a simple script that checks if there is an AC3 or DTS track and force mplayer to use and output that track to the receiver.  I’m positive there are more elegant solutions out there, but my 1.5 second Google search didn’t come across anything.  🙂

Hopefully, this will help someone else out.  If not, feel free to point out what would work better.

[cc lang=”bash” tab_size=”5″ lines=”60″]

CODEC=`midentify $SOURCE | grep ID_AUDIO_CODEC | cut -b 16-30`

if [ $CODEC = “ffdca” ]; then
mplayer -lavdopts threads=2 -ac hwdts $SOURCE
elif [ $CODEC = “ffac3” ]; then
mplayer -lavdopts threads=2 -ac hwac3 $SOURCE
mplayer -lavdopts threads=2 $SOURCE

~ by praetor on June 11, 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: