建立播放列表以播放VLC中媒体文件的选定部分 [英] Building a playlist to play selected portion of media files in vlc

查看:563
本文介绍了建立播放列表以播放VLC中媒体文件的选定部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a list of media files (DVD VOB files) and I want to watch only a portion of the video from a list of files.

#! /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
#... and so on ...

我想到了上面的脚本,该脚本启动一个vlc实例并播放指定的start-timestop-time中的每个文件.效果很好,但是在每个vlc --play-and-exit语句中启动了一个新的vlc实例,并且文件之间由此可见中断.

I came up with the above script that starts up a vlc instance and plays each file from a specified start-time and stop-time. This works fine but spins up a new instance of vlc at every vlc --play-and-exit statement, and there is visible interruption as a result between files.

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

Is there a way to integrate a playlist rule into vlc so a single instance can keep playing all the videos in the script file?

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

It can be assumed that I know the start-time and stop-time values for each file

推荐答案

我能够按照

I was able to make this work by following the instructions here. VLC has lua scripting support. Below is the script I came up with, it takes in a file ending in .fixedseek extension. The playlist file is a csv file with three columns containing file_path_url, start_time, stop_time e.g.

file:///path/to/dvds/dvd1/VIDEO_TS/VTS_01_3.VOB,348,355
file:///path/to/dvds/dvd2/VIDEO_TS/VTS_01_3.VOB,548,855
... and so on ...

脚本分析文件并播放从start_timestop_time

The script parses the file and plays each row from start_time to stop_time

-- fixedseek.lua
-- A compiled version of this file (.luac) should be put into the proper VLC playlist parsers directory.
-- In my ubuntu 14.04 vlc installation, it was: /usr/lib/vlc/lua/playlist/
-- For details, refer to:
-- http://wiki.videolan.org/Documentation:Play_HowTo/Building_Lua_Playlist_Scripts
--
-- The play list file format consists of three comma separated parts:
-- (file_path_url, start_time, stop_time)
-- e.g.
-- file:///path/to/dvds/dvd1/VIDEO_TS/VTS_01_3.VOB,348,355

-- The script below opens the file, seeks to start_time and plays until stop_time
-- and then moves on to next file in the playlist

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

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

    while true do
       playlist_item = {}

       line = vlc.readline()

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

-- parse playlist line into three tokens splitting on comma
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("  Start is '"..tostring(start_time).."'")
     vlc.msg.info("  Stop is '"..tostring(stop_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

这篇关于建立播放列表以播放VLC中媒体文件的选定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆