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:
- Check is VLC is running
- If VLC is running close it and sleep for 1 second
- 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.
- Sleep for another second.
- 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.