How to make sure Lua playlists are used

Discuss your Lua playlist, album art and interface scripts.
Schrijver
New Cone
New Cone
Posts: 2
Joined: 22 May 2011 04:57

How to make sure Lua playlists are used

Postby Schrijver » 22 May 2011 05:36

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

Schrijver
New Cone
New Cone
Posts: 2
Joined: 22 May 2011 04:57

Re: How to make sure Lua playlists are used

Postby Schrijver » 25 May 2011 01:19

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.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37519
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: How to make sure Lua playlists are used

Postby Jean-Baptiste Kempf » 25 May 2011 11:40

The lua script will work, if the previous demuxer didn't work. Lua playlist has a score of 10, I think.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

ale5000
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 03 Mar 2004 16:12
Operating System: Windows
Contact:

Re: How to make sure Lua playlists are used

Postby ale5000 » 26 May 2011 15:28

The score of the lua playlist is 2


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 2 guests