Scripting for VLC

Dear Anyone,
I would appreciate any advice that you could give regarding scripting of VLC.
I have written a Script to run several video streams in sync, and although I intially designed it to work through Quicktime, QT doesn’t seem to be able to handle some Video_TS folders (seems to have problems with the timecodes, and skips through a 2-hour video in about 45 secs).
VLC handles thesse files beautifully, but I am unable to do more than control stop/start. Is it possible to forward/rewind VLC video? And how to obtain a unified timescale for the entire Video_TS folder? (At the moment, VLC only displays the time for each .VOB file) And lastly, even the timecodes on these videos appear to be wrong: the video plays fine, but the time counter in VLC progresses about 0.4x the correct rate (i.e. for every 10secs of real time that passes, the time counter on VLC measures only 4 secs, but the video runs at normal speed, so that a video that last 10 minutes will only have a time counter of 4mins on VLC).
Does this make sense? Any ideas how to solve? Many thanks in advance for any suggestions.

I am wrestling with similar issues (scripting VLC and/or QuickTime to run Video_TS files). One solution, and it’s not brilliant, is to use Handbrake ( ), freeware that rips Video_TS into mpeg4 files. The drawback is that the high quality conversion of a feature length film literally takes hours, and the potential for a crash or some other problem is significant. Handbrake is nonetheless easy to use and allows you to convert individual chapters to smaller mpeg files (I use it to make clips for my film class). If you can convert to mpeg4, I assume that (some of) your problems are (somewhat) resolved.

Another approach that I hope to tackle in the near future (possibly even this millenium), would be to script some gui tasks to select menu and sub menu items. If one could pull this off, then you might automate playback in VLC or, even better, DVD Player, since the latter’s Go menu allows you to jump around in the chapters.

If you wouldn’t mind sharing any scripts that work for you, I would be moost grateful. As soon as I have something that works for me, I’ll post it.

It’s good to know that I am not alone in my attempts to script to be able to play DVD’s / Video_TS folders.
I do use Handbrake, and it works well for me - I can even get queues of files running well on an overnight basis.
Quicktime is able to play these files OK, but - as they are compressed .mp4’s - it seems to find them harder to play than DV movies.
The project that I am conducting requires me to watch several video streams simultaneously. Quicktime can manage this if they are DV movies, but not if they are .mp4’s (I assume that more decoding / processing is required with compressed files such as /mp4).
I have tried going straight from DVD to DV by using DVDxDV. It’s OK, but fairly basic, and certainly doesn’t let me queue a number of Video_TS folders.
Therefore, in order to play a DVD using QT, I need to:

  1. Rip it to .mp4 using Handbrake
  2. Convert this to DV using Quicktime’s export function.
    There’s a nice script for this at:
    I modified this script to wait for Handbrake to finish its queue before starting the conversion, so that in effect I have a 1-step process from DVD to DV, which can operate on batches for both steps.

As for VLC, I have come to develop something of a love-hate relationship with it. I love the fact that it can handle all kinds of video formats with ease, and plays them back in excellent quality. Also, it doesn’t have the same kind of stutter that QT does when trying to play files at the same time as other video streams are running.
On the other hand, I hate the difficulty in scripting for it, and the somewhat meaningless timecodes that are given during playback.

The scripting that I have managed so far for VLC include (and I apologise for any redundant code - I’m a surgical fellow, not a programmer):

  1. Play / pause, which is sensitive to the state of play of VLC
    (Can anyone explain why someone decided that VLC should take the same command ‘play’ for playing as ‘play’ for pausing?!)
		tell application "System Events" to tell process "VLC" to tell menu bar 1 to tell menu bar item "Controls" to tell menu "Controls"
			set VLCList to name of every menu item
		end tell
		if VLCList contains "Play" then --Change this to 'Pause' if you wish to Pause the video
			tell application "VLC"
			end tell

  1. Speed up / slow down video
		set VLCKey to "=" --To Speed up video
			set VLCKey to "-" --To Slow down video
set VLCTimes to 2 -- Can be a number from 1 to 3
		VLCKeyPress(VLCTimes, VLCKey)
on VLCKeyPress(VLCTimes, VLCKey)
	tell application "System Events" to tell process "VLC"
			repeat VLCTimes times
				keystroke VLCKey using command down
			end repeat
	end tell
end VLCKeyPress

  1. Jump forward / back in a number of 10 second jumps
    Note: 10 seconds in VLC timescale approximates to 20 seconds in realtime (at least on my machine - don’t ask me why!)
			tell application "VLC" to activate
			-- if you want to Rewind then
				set VLCDir to 28
			-- if you want to Forward wind then
				set VLCDir to 29
			repeat with i from 1 to NoOfSteps
				tell application "System Events"
					keystroke (ASCII character VLCDir) using {command down, option down}
				end tell
			end repeat

That’s all I’ve got at the moment, I’m afraid.
If anyone cracks the timecode problem, and in particular, if you can tell VLC to jump to… [a give timepoint], you shall have my undying thanks.

Here’s an update to the previous posting on scripting for VLC.
As before, it’s fairly basic, and involves making calls to VLC’s menu’s and buttons, but it works.
This routine extracts the current VOB number and the Timepoint of the current track.
In order to jump to a specified timepoint, I use the second routine to go to previous / next VOB
This is then refined with the previous routine to move within the current track, updating (item 3 of VLCData) until it matches the desired timepoint.

--VLCData is in format {VOB, "DisplayTime as 00:00", DisplayTimsAsSecs}
set VLCData to {0,"",0}
tell application "VLC" to activate
tell application "System Events"
	tell process "VLC" to tell menu bar 1 to tell menu bar item "Window" to tell menu "Window"
		click menu item "Controller"
	end tell
		tell process "VLC" to tell window 1
			set (item 2 of VLCData) to name of static text 1
			set VLCTrack to name of static text 2
		end tell
	end try
end tell
if VLCTrack = "VLC media player" then
	display dialog "No media present in VLC player" & return & "Please open media then press OK" buttons {"OK", "Cancel"} default button "OK"
	-- ConvertStringToTime is an external subroutine, which sets delimiters to ':', and calculates Time In Seconds (routine available if req.)
	set (item 3 of VLCData) to ConvertStringToTime(item 2 of VLCData)
	set OldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "."
	set VLCTrack to text item 1 of VLCTrack
	set AppleScript's text item delimiters to "_"
	set (item 1 of VLCData) to (text item 3 of VLCTrack) as integer
	set AppleScript's text item delimiters to OldDelims
end if

Use this to move from one VOB to another:

if TargetVOB is not equal to (item 1 of VLCData) then
	set DiffInVOB to TargetVOB - (item 1 of VLCData)
	set VLCPress to (DiffInVOB ^ 2) ^ 0.5 as integer
	repeat with i from 1 to VLCPress
		if DiffInVOB is greater than 0 then
			set PrevNext to 8 -- Sets Target key to 'Fast Forward'
			set PrevNext to 11 -- Sets Target key to 'Rewind'
		end if
		tell application "System Events" to tell process "VLC"
			tell menu bar 1 to tell menu bar item "Window" to tell menu "Window"
				click menu item "Controller"
			end tell
			tell window 1 to click button PrevNext
		end tell
	end repeat
end if

Hope that helps anyone else in a similar predicament to mine.
I am sure that there are better ways to script VLC, but this is the best I can do at present.

Hi Guys,

I see this is a relatively old thread, so I hope I am not giving redundant information that you have discovered since posting.

I have just discovered VLC, and am trying to interface Filemaker Pro 8 to it.
I looked at the VLC preferences, and Holy Cow!! There are controls for EVERYTHING in there!

Someone was frustrated with the Play/Pause toggle, but I found in (Advanced box clicked) Preferences → Interface → Hotkey Settings, you can create a Play Only and a Pause Only key command.

I also found numerous settings for delays and sync tweeks. There is a brief description of each if you hover over the field itself.
Make sure you click to open all triangles in pref list.

I saw something about a remote control interface, something I would like to persue. Anyone know how to use it?


Hi, yeah this thread may be old, but making FileMakerP talk with VLC is actually still very cutting edge.
And have to say that PJWilson ans SoCalMacDude are both right, all I have to add is that the easiest way I have found to skip ahead and backwards as well as most everything else is basically a combination of the approaches each of you already said. What do I mean?

Using “System Events” to send key presses to VLC. Thats it.

I would recommend first setting the “hot keys” for the events you want to script to be simple (one-key, not key with modifiers) like “f” for jump ahead 5 secs or whatever. Once you have done that then you just have your script send the ‘press f key’ command to the right object in VLC. Also I recommend using a program called UI Browser that makes it much easier for track objects using “System Events” and find what you want to get at in a program like VLC.

I would include some code to elaborate, but thats on another computer, sorry. Maybe later…