带有开始和结束时间的视频播放列表

带有开始和结束时间的视频播放列表

Linux 上是否有一个好的 GUI 应用程序(例如 mplayer GUI 或类似 banshee 的东西),允许创建和编辑播放列表(对于视频文件),列表中每个视频具有不同的开始和停止时间?

添加:

目前我手动制作包含类似内容的文件:

video.avi -ss 2440 -endpos 210
#some comment

video2.mp4 -ss 112 -endpos 2112

然后我有一个包装脚本:mplayer -fs $(grep -v "^ #" $1)

此外,我还编写了一些 emacs 函数,可以稍微简化此类文件的编辑。 (就像根据 -endpos 的要求将开始和结束时间从 hh:mm:ss 格式转换为秒,将结束时间转换为相对位置(结束时间 - 开始时间)(如果有人感兴趣,我可以发布宏)。但是,这仍然太不舒服。所以我的问题是是否有一个很好的 GUI 来执行此操作(例如,它允许您在视频时间轴中标记播放列表的开始和结束时间等)。

答案1

也许我问错了,因为英语不是我的母语,但如果你用像这样的工具编辑视频不是更好吗奇诺而不是制作这样的播放列表?

你可以根据需要调整开始和停止时间,我认为这不会那么困难。

答案2

UPDATE-2:提交以下脚本后,我突然意识到设置时间位置(在 GUI 中)的另一种方法是使用字幕编辑器(例如gnome-subtitles)。您只需点击即可标记“幻影字幕”的开始和结束位置;实际上,您可以将文件路径和注释作为“字幕”...某些格式不适合(例如使用帧编号)..“ViPlay 字幕文件”、Power DivX 和“Adobe Encore DVD”外观好的。

更新-1;一个新脚本... 该脚本不会为您提供集成播放列表功能,但它允许您在 Smplayer 中选择、保存和修改开始和结束时间,而无需输入任何内容。

此信息保存在一个配置文件中,该文件的文件路径可以单独“播放”,也可以通过另一个脚本按顺序分组(类似于我的“播放”脚本,或者像您的 Emacs 脚本)。

它的工作原理是利用 Smplayer 的Seek对话框...xmacro操纵对话框(我发现它需要sleep .3在 xmacro 命令之间)...时间以 HH:MM:SS 格式存储在文件中~/.config/smplayer...第一行是开始时间,第二行是结束时间,第三行用于指定根目录...第三行被后续脚本用作可选路径指示符,该脚本通过以下方式修改 smplayer 配置设置用-ssand -endpos... 启动它 时间戳配置文件的命名与媒体文件相同,带有后缀.smplay...

所以这不是您想要的一切,但它可能有助于设置时间而无需任何打字......

这是“获取时间戳”脚本:

#!/bin/bash
# Bind this script to a key-combination of your choice..
# It currently responds only to an Smplayer window.  

id=$(xdotool getactivewindow)
title="$(xwininfo -id "$id" |
  sed -n "2s/^xwininfo: Window id: \(0x[[:xdigit:]]\+\) \x22\(.*\)\x22$/\2/p")"

if [[ $title =~ ^.*\ -\ SMPlayer$ ]] ; then
  smplayer_d="$HOME/.config/smplayer"
  clip_d="$smplayer_d/clips"
  [[ ! -d "$clip_d" ]] && mkdir -p "$clip_d"
  bname="${title% - SMPlayer}"
  clip_f="$clip_d/$bname.smplay" # Same name as video, with '.smplay' suffix

  if [[ ! -f "$clip_f" \
      || "$(<"$clip_f" wc -l)" != "3" ]]
  then     # Prime with three defaults
           # FROM     TO      ROOT-dir
    echo -e "0:00:00\n0:00:00\n"     >"$clip_f"
  fi

  # Get timestamp, in seconds, of current stream position (from the current window)
  #   using the "Smplayer - seek" dialog, via  Ctrl+j
  sleep .3; echo -n "KeyStrPress Control_L  KeyStrPress j       KeyStrRelease j       KeyStrRelease Control_L" | xmacroplay -d 10 :0.0 &>/dev/null 
  sleep .3; echo -n "                       KeyStrPress Home    KeyStrRelease Home                           " | xmacroplay -d 10 :0.0 &>/dev/null 
  sleep .3; echo -n "KeyStrPress Shift_L    KeyStrPress End     KeyStrRelease End     KeyStrRelease Shift_L  " | xmacroplay -d 10 :0.0 &>/dev/null 
  sleep .3; echo -n "KeyStrPress Control_L  KeyStrPress c       KeyStrRelease c       KeyStrRelease Control_L" | xmacroplay -d 10 :0.0 &>/dev/null
  sleep .3; echo -n "                       KeyStrPress Escape  KeyStrRelease Escape                         " | xmacroplay -d 10 :0.0 &>/dev/null 
    seekHMS="$(xsel -o -b)"
  # Now set config times to defaults (in case of malformed times)
      ssHMS="0:00:00"
  endposHMS="0:00:00"
  # Now get config data from config file
  eval "$( sed -ne "1s/^\([0-9]\+\):\([0-5][0-9]\):\([0-5][0-9]\)$/    ssHMS=\"&\"/p" \
                -e "2s/^\([0-9]\+\):\([0-5][0-9]\):\([0-5][0-9]\)$/endposHMS=\"&\"/p" \
                -e "3s/.*/   root_d=\"&\"/p" "$clip_f" )"

  # Present dialog to set specifick  items.
  REPLY=$(zenity \
   --list --height=310 --width=375 \
   --title="Set Clip Start / End Time" \
   --text=" Select Clip Start / End  for time:  $seekHMS\n\
       or choose another option\n\
       \tthen click OK" \
   --column="Position" --column=" " --column="Current Setting  "  \
            "Clip Start"        " "          "$ssHMS" \
            "Clip End"          " "          "$endposHMS" \
            "UNSET Start"       " "          " " \
            "UNSET End"         " "          " " \
            "* Open directory"  " of"        "config files *" 
  ); 
  [[ "$REPLY" == "Clip Start"       ]] && sed -i -e "1 s/.*/$seekHMS/" "$clip_f"
  [[ "$REPLY" == "Clip End"         ]] && sed -i -e "2 s/.*/$seekHMS/" "$clip_f"
  [[ "$REPLY" == "UNSET Start"      ]] && sed -i -e "1 s/.*/0:00:00/"  "$clip_f"
  [[ "$REPLY" == "UNSET End"        ]] && sed -i -e "2 s/.*/0:00:00/"  "$clip_f"
  [[ "$REPLY" == "* Open directory" ]] && nautilus "$clip_d"
fi  

以下脚本是我原来的“播放”脚本。它独立于 avove Timestamp 脚本,但让它们一起工作并不需要太多...

它将“驱动”Smplayer,它在内部使用 mplayer.. 它至少是一个普通的 GUI,但您的播放列表需要位于文本编辑器中.. 并且您显然已经知道该方法了:)

几年前我尝试过这个,但我已经忘记了它,因为我不经常需要这样的东西,但保留“书签”是件好事......我很高兴你复活了这个想法。这是脚本...它实际上只做与您所做的相同的事情,但是针对 Smplayer(一个 mplayer GUI)

#
# Summary: 
#   Play one video (only) in 'smplayer', passing -ss and -endpos values to 'mplayer'
#   It uses 'locate' to get the path of the video (by just its basename)
#
# eg:
#     $1                              $2   $3       $4 
#     basename                       -ss  -endpos   root 
#     "Titus - The Gorilla King.mp4"  240  30      "$HOME"  # A fascinating documentary of the long reign of a silver-back gorialla
#

[[ "$2" == "" ]] && set "$1"  0   "$3"   "$4"
[[ "$3" == "" ]] && set "$1" "$2"  36000 "$4"  # 36000 is arbitary (24 hours) 
[[ "$4" == "" ]] && root="$HOME" || root="$4"

file=( "$(locate -er "^$root/\(.*/\)*\+$1$")" )

# 1) Tweak 'smplayer.ini' to run 'mplayer' with the specified -ss and -endpos  times
# 2) Run 'smplayer' to play one video only. The time settings will hold afer exit,  
#                         so the script waits (backgrounded) for smplayer to exit
# 3) When 'smplayer' exits, set values to extreme limits:  -ss 0 -endpos 3600 
#                           or(?): TODO remove the settings enitrely, 
#                                       but that requires a different regex
a=0 z=36000     
# 
# -ss <time> (also see -sb)
# -ss 56       # Seeks to 56 seconds.
# -ss 01:10:00 #Seeks to 1 hour 10 min.
#
# -endpos <[[hh:]mm:]ss[.ms]|size[b|kb|mb]> (also see -ss and -sb)
#         Stop at given time or byte position.
#         NOTE: Byte position is enabled only for MEncoder and will not be accurate, as it can only stop at a frame boundary.  
#         When used in conjunction  with -ss option, -endpos time will shift forward by seconds specified with -ss.
#        -endpos 56        # Stop at 56 seconds.
#        -endpos 01:10:00  # Stop at 1 hour 10 minutes.
# -ss 10 -endpos 56        # Stop at 1 minute 6 seconds.
#        -endpos 100mb     # Encode only 100 MB.
#
#                                                        -ss       0                -endpos       36000                                     
#              \1                              \2      \3        \4        \5     \6            \7            \8                 
 sed -i -e "s/^\(mplayer_additional_options.*\)\( \|=\)\(-ss \+\)\([^ ]\+\)\( .*\)\(-endpos \+\)\([0-9:mb]\+\)\(.*\)/\1\2\3${2}\5\6${3}\8/"  $HOME/.config/smplayer/smplayer.ini
(smplayer "$file" 
 sed -i -e "s/^\(mplayer_additional_options.*\)\( \|=\)\(-ss \+\)\([^ ]\+\)\( .*\)\(-endpos \+\)\([0-9:mb]\+\)\(.*\)/\1\2\3${a}\5\6${z}\8/"  $HOME/.config/smplayer/smplayer.ini
)
exit

答案3

我添加了第二个答案,因为它像普通播放列表一样工作在 SMPlayer 中,为了清晰起见,这里更好......

我已经通过播放列表完美地工作了......

这种方法需要重新编译SMPlayer,以及特定的文件命名方法...只修改了SMPlayer源代码中的一个函数,并且在同一个源文件中添加了3个头文件...我已经smplayer_0.6.8为Lucid编译了.. Maveric 和 Meerkat 使用smplayer_0.6.9.. 后续版本中的一行有所不同,但这不会影响任何内容... 这是修改后的函数和标头smplayer_0.6.8

顺便说一句,我之前的答案中的 zenity 对话框仍然可用于捕获开始和结束时间......

提醒- 以下源段用于smplayer_0.6.8...要修改的文件是:../smplayer-0.6.9/src/findsubtitles/osparser.cpp...“0.6.8”和“0.6.9”的新段相同,但原始段相差一行(非常接近结束;就在决赛之前return hexhash;


将第一行块添加到现有#include标题的 正下方

// ====================
// fred mod begin block  
#include <QFileInfo>
#include <QRegExp>
#include <QSettings>
#include "paths.h"
// fred mod end block
// ==================

这是修改后的函数

QString OSParser::calculateHash(QString filename) {
    QFile file(filename);

    if (!file.exists()) {
        qWarning("OSParser:calculateHash: error hashing file. File doesn't exist.");
        return QString();
    }

    file.open(QIODevice::ReadOnly);
    QDataStream in(&file);
    in.setByteOrder(QDataStream::LittleEndian);
    quint64 size=file.size ();
    quint64 hash=size; 
    quint64 a;
    for(int i = 0; i < 8192; i++) {
        in >> a ; hash += a;
    };
    file.seek(size-65536);
    for(int i = 0; i < 8192; i++) {
        in >> a ; hash += a;
    };

  // =====================================================================
  // fred mod begin block
  //  
  // A mod to enable unique smplayer .ini files to be created for  
  //        content-identical media files whose file-names match
  //        a specific pattern based on two timestamps. 
  //        This is the naming pattern:

  //          
  //           name.[00:11:22].[33.44.55].mkv
  //              
  //        The two time stamps indicate the start and end  points of a 
  //         clip to be played according to  settings in the unique .ini
  //            
  //        The so named files can be, and typically will be, soft (or hard) links.   
  //        The "original" file can also named in this manner, if you like,    
  //        but that would make the "original" start playing as a clip,
  //          NOTE: soft links become invalid when you rename the original file.  
  //
  //  Note: For this system to work, you need to enable the following:
  //        In SMPlayer's GUI, open the Options dialog...
  //        In the  "General" tab... "Media settings"... 
  //          enable: 〼 "Remember settings for all files (audio track, subtitles...)" 
  //                     "Remember time position"   can be 'on' or 'off'; it is optional1
  //                                                but it is disabled for these clips.    
  //                     "Store setings in" must be: "multiple ini files" 
  //
  QFileInfo fi(filename);
  QString name = fi.fileName();
  //
  // ===================================================================
  // This RegExp expects a name-part, 
  //             followed by 2 .[timestamps]  (Begin-time and End-time)
  //             followed by a .extension
  //              
  //              .[ Begin  ].[  End   ]  
  //      eg. name.[00:11:22].[33.44.55].mkv
  //
  //    Note: The delimiter between each numeric value can be any non-numeric character.
  //          The leading dot '.' and square brackets '[]' must be as shown        
  //          HH, MM, and SS must each be 2 valid time-digits    
  //
  QRegExp rx("^.+"                      // NAME
             "\\.\\[([0-9][0-9])[^0-9]" // .[HH.
                   "([0-5][0-9])[^0-9]" //   mm.
                   "([0-5][0-9])\\]"    //   ss]
             "\\.\\[([0-9][0-9])[^0-9]" // .[HH.
                   "([0-5][0-9])[^0-9]" //   mm.
                   "([0-5][0-9])\\]"    //   ss]
             "\\.([^0-9]+)$");          // .EXTN
  //
  QString qstrIni;
  rx.setPatternSyntax(QRegExp::RegExp);
  if(rx.exactMatch(name)) {
      bool ok;
      QString qstrDlm(".");
      QString qstrBegEnd = rx.cap(1) + rx.cap(2) + rx.cap(3)
                         + rx.cap(4) + rx.cap(5) + rx.cap(6);
      hash += qstrBegEnd.toLongLong(&ok,10); // The UNIQUE-FIER
      //
      quint32 quiBegSec=(rx.cap(1).toULong(&ok,10)*3600)
                       +(rx.cap(2).toULong(&ok,10)*  60)
                       +(rx.cap(3).toULong(&ok,10));
      quint32 quiEndSec=(rx.cap(4).toULong(&ok,10)*3600)
                       +(rx.cap(5).toULong(&ok,10)*  60)
                       +(rx.cap(6).toULong(&ok,10));
      quint32 quiDifSec=(quiEndSec-quiBegSec);
      // 
      QString qstrBegIni = "-ss "     + QString::number(quiBegSec);
      QString qstrEndIni = "-endpos " + QString::number(quiDifSec);
              qstrIni    = qstrBegIni + " " + qstrEndIni;
  }
  // fred mod end block
  // =====================================================================
  // fred NOTE: the following 2 lines are a single line in smplayer-0.6.9

    QString hexhash("");
    hexhash.setNum(hash,16);

  // =====================================================================
  // fred mod begin block  
    if( !qstrIni.isEmpty() ) {
      // ** The next code line is not ideal, but should be okay so long 
      //    as SMPlayer's options are set to use Multiple .ini files.  
      //       The literal "file_settings" is HARDCODED, as It wasnt' straight
      //       forward to get the value, The rest of the path was easily available 
      //       without any significant mods, which "file_settings" would require.    
      // TODO: Check for Multiple .ini Option being enabled.
      //  
      QString  dir_settings = Paths::configPath() + "/file_settings";
      QString fqfn_settings = dir_settings + "/" + hexhash[0] + "/" + hexhash + ".ini";

      QSettings set(fqfn_settings, QSettings::IniFormat);
      set.beginGroup("file_settings");
      set.setValue(  "starting_time", "0" );
      set.setValue(  "mplayer_additional_options", qstrIni );
    }
  // fred mod end block
  // =====================================================================

    return hexhash;
}

答案4

我没能找到这些是否真的可以应用于播放列表,但您可以查看编辑决策列表(EDL)。以下是一些可帮助您入门的链接:

  1. 关于 EDL 支持的 MPlayer 手册

  2. MPlayer EDL 教程

  3. 从命令行编辑视频Linux公报文章

  4. 明智的电影项目

如果您不介意视频之间的小停顿,您可以每次使用不同的 EDL 文件从脚本运行 mplayer 几次。如果暂停是禁忌,那么也许您应该像 varrtto 建议的那样创建一个新视频。

相关内容