Page 1 of 1

How to make sure Lua playlists are used

Posted: 22 May 2011 05:36
by Schrijver
Hello,

I just started scripting Lua playlists. I can’t get a basic example to work on either Mac OSX or Ubuntu. Is there some kind of Hello World script that I could try that is bound to work?

This is what I did now:

Code: Select all

-- Probe function. function probe() return true end -- Parse function. function parse() msg.dbg("test") return { { path = "http://schr.fr/tlkng/MVI_3303_edt_h264.mov"; name = "test" } } end
I called this aaa.lua — the way I read the documentation, now, with every video I try to play in VLC I should instead get the movie MVI_3303_edt_h264.mov
But nothing happens!

I thought the script should run always when a video is played, because probe() always returns true?
I’m running 1.1.9 Intel 64 bit on Mac OS X 10.6.7 and the script is in /Applications/VLC.app/Contents/MacOS/share/lua/playlist/

FWIW, what I want to achieve is that I want to read a random movie file from a directory and return a random 6 seconds from it. I would find the filename and the offsets through shell commands called in the parse() function and then simply return the result as the playlist item. I think I have a reasonable idea of how to achieve this, if I can get the basics to work first!

Thanks! for your help,

Eric

Re: How to make sure Lua playlists are used

Posted: 25 May 2011 01:19
by Schrijver
This is what I did now, in Python—

This script is supposed to operate on a folder with movies. It generates an
automatic montage, using the avarage shot length of a Hollywood movie (6
seconds).

obviously it’s not ideal, as I launch and quit VLC every time,
which gives a very noticable delay.

I’d like to do it the other way around, so that inside of VLC a script determines the right parameters for the next playlist item.

Code: Select all

import os import subprocess import re from random import randint, choice while True: # get all movie file names movies = [i for i in os.listdir('/home/e/hypermap-movies') if 'MOV' in i] movie = '/home/e/hypermap-movies/' + choice(movies) print movie # get metadata with ffmpeg # ffmpeg exits with 1 when not given an output file, so we read STDERR metadata = subprocess.Popen(['ffmpeg','-i',movie], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1].strip() # find the duration in hours, minutes, seconds in the metadata regex = re.compile("Duration: ([^.]*).",re.MULTILINE) # convert to a list of ints duration = map(int, regex.findall(metadata)[0].split(':')) # convert to total seconds seconds = 3600 * duration[0] + 60 * duration[1] + duration[2] # choose a 6 second snippet if seconds > 6: start = randint(0,(seconds - 6)) stop = start + 6 else: start = 0 stop = seconds # launch vlc with these variables pipe = subprocess.Popen(['vlc', "--start-time=%s" % start, "--stop-time=%s" % stop, "--fullscreen", movie, "vlc://quit"]) pipe.wait()
But I can’t the LUA playlist thing to work. If someone would be so kind as to provide debugging instructions? So I can figure out what’s not working in my setup?
Thanks!!!!

PS, The way we use it, while a live event is taking place, movies of the event are
continuously added to the folder, so that the characteristics of the montage
change over time.

Re: How to make sure Lua playlists are used

Posted: 25 May 2011 11:40
by Jean-Baptiste Kempf
The lua script will work, if the previous demuxer didn't work. Lua playlist has a score of 10, I think.

Re: How to make sure Lua playlists are used

Posted: 26 May 2011 15:28
by ale5000
The score of the lua playlist is 2