2011-05-16 9 views
18

ऐसा लगता है कि यह आसान होना चाहिए, लेकिन मैं यहां खाली हाथ आ रहा हूं। मैं एक साधारण वीएलसी स्क्रिप्ट बनाने की कोशिश कर रहा हूं जो जांचता है कि "यादृच्छिक" बटन चालू है या नहीं, और यदि ऐसा होता है तो यह एक यादृच्छिक फ़ाइल पर कूदता है, समय = 0 से शुरू करने के बजाय, यह एक यादृच्छिक समय से शुरू होता है।लुआ के साथ वीएलसी स्क्रिप्टिंग: फ़ाइल में एक विशिष्ट समय पर कूदें?

अभी तक, यह मुझे लगता है कि यह एक प्लेलिस्ट स्क्रिप्ट होना चाहिए और मुझे प्लेलिस्ट ऑब्जेक्ट से अवधि मिल सकती है, लेकिन this documentation page या Google पर, मुझे किसी विशिष्ट पर कूदने का कोई तरीका नहीं दिख रहा है लुआ लिपि के भीतर से समय। क्या किसी को लुआ के साथ वीएलसी प्लेबैक को नियंत्रित करने के साथ और अधिक अनुभव है?

+0

मैं प्रलेखन और स्रोत कोड में घूमते हैं और यह * लगता है * यह संभव नहीं है। आपको शायद वीडियो लैन मंचों http://forum.videolan.org/viewforum.php?f=29 पर अपनी किस्मत आजमाएं। – ponzao

+1

वीडियोLAN फ़ोरम पर यह प्रश्न, जहां कोई बार-बार 'निश्चित-समय' विकल्प के साथ वीएलसी लॉन्च कर रहा है, संबंधित लगता है: http://forum.videolan.org/viewtopic.php?f=29&t=90656 – HostileFork

उत्तर

21

दरअसल, दस्तावेज़ीकरण कहता है कि आप इसे कर सकते हैं ... हालांकि इतने सारे शब्दों में नहीं। यहां बताया गया है यह प्लेलिस्ट पारसर्स के लिए इंटरफ़ेस के बारे में कहते हैं है:

VLC Lua playlist modules should define two functions: 
    * probe(): returns true if we want to handle the playlist in this script 
    * parse(): read the incoming data and return playlist item(s) 
     Playlist items use the same format as that expected in the 
     playlist.add() function (see general lua/README.txt) 

आप playlist.add() का वर्णन करने के लिए के माध्यम से पालन करें यह कहता है कि आइटम क्षेत्रों प्रदान कर सकते हैं की एक बड़ी सूची है। बहुत सारे विकल्प हैं (.name, .title, .artist, आदि) लेकिन केवल एक ही आवश्यक .path लगता है ... जो "आइटम का पूरा पथ/यूआरएल" है।

जहां तलाश करने के लिए की कोई स्पष्ट उल्लेख नहीं है, लेकिन मानकों प्रदान करने के लिए चुन सकते हैं में से एक .options है, "वीएलसी विकल्प की एक सूची होने के लिए कहा। यह fullscreen एक उदाहरण के रूप देता है। यदि --fullscreen के लिए एक समानांतर ?! काम करता है, --start-time और साथ ही --stop-time काम जैसे अन्य कमांड लाइन विकल्प

अपने सिस्टम वे करते हैं, और यहां स्क्रिप्ट है पर

-- randomseek.lua 
-- 
-- A compiled version of this file (.luac) should be put into the proper VLC 
-- playlist parsers directory for your system type. See: 
-- 
-- http://wiki.videolan.org/Documentation:Play_HowTo/Building_Lua_Playlist_Scripts 
-- 
-- The file format is extremely simple and is merely alternating lines of 
-- filenames and durations, such as if you had a file "example.randomseek" 
-- it might contain: 
-- 
--  foo.mp4 
--  3:04 
--  bar.mov 
--  10:20 
-- 
-- It simply will seek to a random location in the file and play a random 
-- amount of the remaining time in the clip. 

function probe() 
    -- seed the random number since other VLC lua plugins don't seem to 
    math.randomseed(os.time()) 

    -- tell VLC we will handle anything ending in ".randomseek" 
    return string.match(vlc.path, ".randomseek$") 
end 

function parse() 
    -- VLC expects us to return a list of items, each item itself a list 
    -- of properties 
    playlist = {} 

    -- I'll assume a well formed input file but obviously you should do 
    -- error checking if writing something real 
    while true do 
     playlist_item = {} 

     line = vlc.readline() 
     if line == nil then 
      break --error handling goes here 
     end 

     playlist_item.path = line 

     line = vlc.readline() 
     if line == nil then 
      break --error handling goes here 
     end 

     for _min, _sec in string.gmatch(line, "(%d*):(%d*)") 
      do 
       duration = 60 * _min + _sec 
      end 

     -- math.random with integer argument returns an integer between 
     -- one and the number passed in inclusive, VLC uses zero based times 
     start_time = math.random(duration) - 1 
     stop_time = math.random(start_time, duration - 1) 

     -- give the viewer a hint of how long the clip will take 
     playlist_item.duration = stop_time - start_time 

     -- a playlist item has another list inside of it of options 
     playlist_item.options = {} 
     table.insert(playlist_item.options, "start-time="..tostring(start_time)) 
     table.insert(playlist_item.options, "stop-time="..tostring(stop_time)) 
     table.insert(playlist_item.options, "fullscreen") 

     -- add the item to the playlist 
     table.insert(playlist, playlist_item) 
    end 

    return playlist 
end 
+28

मज़ा तथ्य: मैंने इस अनुत्तरित प्रश्न को हल करने के लिए आज रात लूआ सीखा। :) – HostileFork

5

बस इस का उपयोग कर सकते हैं:

vlc.var.set(input, "time", time) 
1

common.lua में एक खोज विधि है।

उपयोग के उदाहरण:

require 'common' 
common.seek(123) -- seeks to 02m03s 
common.seek("50%") -- seeks to middle of video 
संबंधित मुद्दे