The best media player money can't buy

May 19, 2007

It turns out that for my needs, the best x-format media player out there right now is the command-line version of MPlayer. It plays anything, is infinitely customisable, has proper support for subtitles (with live interactive retiming!) and most importantly, allows me to easily create the perfect UI for it, tailored exactly to my needs. In most cases this means “play this file” or “play this file and use this other file for the subtitles”.

So I created an Automator action (just unpack to ~/Library/Workflows/Applications/Finder) which, after a “Get Selected Finder Items”, runs this little AppleScript:

on run {input, parameters}

  set args to ""

  if length of input > 1 then
    repeat with i in input
      if name extension of i is in {"avi", "mp4", "ogg", "divx", "mkv"} then
        set video to i as string
        set subs to quoted form of POSIX path of (i as string)
      end if
    end repeat

    set args to " -sub " & subs & " -subfont-text-scale 4"
    set video to (input as string)
  end if

  set video to quoted form of POSIX path of video
  do shell script "/usr/local/bin/mplayer -framedrop -mc 0.001 -af volnorm=2 " & video & args & " &> /dev/null &"

  return true
end run

Now I simply select the file(s) in the Finder and Ctrl-click > Automator > Play in MPlayer.