Change VLC cache preference with a Finder plugin using Automator

Over on MacOSXHints.com there is a great tip showing how to use Automator to set VLC caching delays. Something like this is great (actually essential) for anyone who watches videos or listens to music over a network share (Samba, NFS, AFP). I do this almost daily and before it was annoying because the video would be very jaggy because VLC was not caching enough of the video ahead of time. The solution to this was to change the following preference in VLC: Input / Codecs -> Access Modules -> File -> (click Advanced) -> Caching value in ms. This is a huge hassle so nclark42 wrote an automator action that changed the preference for you (that is the workflow given on macosxhints). To run that script you must first run either the network workflow or the local workflow depending on where your video is located and then open the video file which is fine but my roommate suggested that it would be nice if you could just open the file in finder and have the script set the correct preference for you.

And thus I cooked up this alternative Automator action. One is scripted in Ruby and the other is done in Applescript. They do the same thing I am just providing both is case anyone has a preference. Each script takes the following actions:

  1. Check is VLC is running
  2. If VLC is running close it and sleep for 1 second
  3. Check the path of the file, if it starts with “/Volumes” then change the caching preference to 5000 ms, otherwise set it to the default 300 ms.
  4. Sleep for another second.
  5. Launch VLC and play the video.

According to MaxOSXHints, the pauses are necessary to allow VLC to write out to the vlcrc file before we make our changes. To use the workflow, open it Automator then select File -> Save as Plugin. Make sure Finder plugin is selected and give it a name like “Open in VLC and change cache”. Finally open finder, right click on a video and select More -> Automator -> Open in VLC and change cache.

I wrote the script twice, once using Ruby and once using Applescript.  Both do exactly the same thing so just pick one and use it. I am making both available in case someone wants to look at them. I tested the scripts in OS X 10.5 but they should work with 10.4 as well.

VLC w/ Ruby.workflow VLC Cache Modifier
Ruby version. See instructions above. Updated December 6, 2007
VLC w/ Applescript.workflow VLC Cache Modifier 2
Applescript version. See instructions above. Works exactly the same as the one above. Updated December 6, 2007

6 thoughts on “Change VLC cache preference with a Finder plugin using Automator

  1. kal

    Thanks for the tip, been looking for how to do this for a while. Now I can actually play videos off of my bonjour drive without first copying it to my local HD.

  2. Kevin Kershaw

    This sure is a delayed response but I’m wondering – why not just have VLC run with the cache at 5000ms by default for local and networked files? Is there an adverse effects to permantly raising the buffer?

  3. Rob Olson

    @Kevin Kershaw- The adverse effect is that with the 5000ms cache in place VLC takes 5 seconds to start, pause, and stop a video! It definitely makes the VLC feel less responsive and I prefer the default values.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>