构建一个播放列表,在vlc中播放所选部分的媒体文件。

我有一个媒体文件列表(DVD VOB文件),我想从一个文件列表中只观看视频的一部分。

#! /bin/bash
export SOURCE_DIR=/path/to/dvds/dir
export DVD1=$SOURCE_DIR/dvd1/VIDEO_TS
export DVD2=$SOURCE_DIR/dvd2/VIDEO_TS
export DVD3=$SOURCE_DIR/dvd3/VIDEO_TS
export DVD4=$SOURCE_DIR/dvd4/VIDEO_TS
export FILE1=VTS_01_1.VOB
export FILE2=VTS_01_2.VOB
export FILE3=VTS_01_3.VOB
export FILE4=VTS_01_4.VOB

vlc --play-and-exit --start-time=348 --stop-time=355 $DVD1/$FILE1
vlc --play-and-exit --start-time=574 --stop-time=594 $DVD1/$FILE2
#...等等...

我想出了上面的脚本,它启动一个 vlc 实例并从指定的 start-timestop-time 播放每个文件。这个工作得很好,但在每个 vlc --play和-exit 语句中都会启动一个新的 vlc 实例,并且由此产生的文件之间有明显的中断。

有没有一种方法将播放列表规则集成到 vlc 中,以便单个实例可以继续播放脚本文件中的所有视频?

可以假定我知道每个文件的 start-timestop-time 值。

点赞
用户2063026
用户2063026

我通过遵循这里的指示成功实现了这个功能。 VLC具有lua脚本支持。下面是我编写的脚本,它需要以.fixedseek结尾的文件。播放列表文件是一个包含三列文件路径_url开始时间结束时间的csv文件,例如:

file:///path/to/dvds/dvd1/VIDEO_TS/VTS_01_3.VOB,348355
file:///path/to/dvds/dvd2/VIDEO_TS/VTS_01_3.VOB,548855
……等等……

脚本解析文件并从开始时间结束时间播放每行。

-- fixedseek.lua
-- 该文件的已编译版本(.luac)应放入适当的VLC播放列表解析器目录中。
-- 在我的ubuntu 14.04 vlc安装中,它是:/usr/lib/vlc/lua/playlist/
-- 有关详细信息,请查阅:
-- http://wiki.videolan.org/Documentation:Play_HowTo/Building_Lua_Playlist_Scripts
--
-- 播放列表文件格式由三个逗号分隔的部分组成:
-- (file_path_url,start_time,stop_time)
-- 例如:
-- file:///path/to/dvds/dvd1/VIDEO_TS/VTS_01_3.VOB,348,355

-- 下面的脚本打开文件,寻找开始时间并播放到停止时间
-- 然后继续播放列表中的下一个文件

function probe()
    -- 告诉VLC我们将处理以“.fixedseek”结尾的所有内容
    return string.match(vlc.path, "%.fixedseek$")
end

function parse()
    -- VLC期望我们返回一个项目列表,每个项目本身都是一个属性列表
    playlist = {}

    while true do
       playlist_item = {}

       line = vlc.readline()

       if line == nil then
           break
    else vlc.msg.info(" 读取行:'"..line.."'")
       end

-- 将播放列表行解析为三个标记,分割逗号
values = {}
i=0
for word in string.gmatch(line, '([^,]+)') do
    values[i]=word
    i=i+1
end

vlc.msg.info(values[0])
vlc.msg.info(values[1])
vlc.msg.info(values[2])

       playlist_item.path = values[0]
       start_time = values[1]
       stop_time = values[2]

     vlc.msg.info("  开始时间是'"..tostring(start_time).."'")
     vlc.msg.info("  停止时间是'"..tostring(stop_time).."'")

       -- 播放列表项具有内部列表,其中包含选项
       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")

       -- 将项目添加到播放列表中
       table.insert( playlist, playlist_item )
    end

    return playlist
end
2015-04-18 21:24:19