youtube-dl 每 5 分钟下载一分钟(在 twitch 视频上,但如果更容易的话,我也保存了本地文件)

youtube-dl download one minute per every 5 minutes (on a twitch video, but i have the local file saved too if easier)

我想按照标题说的去做

这是一个 ffmpeg 命令,用于从视频中的特定时间离线或在线下载。

ffmpeg -ss (停止时间) -i (直接视频link) -t (开始时间) -c:v copy -c:a copy (title.mp4)

我将在 OSX 上下载这个。 我不在乎标题是什么。

我认为*有一个 bash 命令允许我将此命令中的时间更改为特定数量(每个 +300 秒,开始和停止时间的计数器以原始秒为单位)

因此,bash 运行该命令但将开始和停止时间递增 300(停止时间提前 60+ 秒)的脚本,下载,然后重复。

这里是:

youtube-dl:

的内容
#!/usr/bin/env bash

# set start to 0, 300, 600... up to 72000 (20 hours)
for start in `seq 0 300 72000`; do

  # set the outfile name
  file=".$start.60.mp4"

  ffmpeg -ss $start -i "" -t 60 -c:v copy -c:a copy "$file"

  # get the duration of the last outfile
  last_duration=`ffprobe -i "$file" -show_entries format=duration -v quiet -of csv="p=0"`
  # if last outfile's duration isn't greater than a second, delete it and stop
  [[ ! "$last_duration" -gt 1 ]] && rm -f $file && exit

done

然后做:

chmod +x youtube-dl

用法:

./youtube-dl "http://your/movie.flv" title

ps:我发现你的 ffmpeg 命令有点问题:它是 -t (duration),而不是 -t (start time)

参考文献:

ffmpeg usage (slhck, 2012)

ffprobe usage (ivan-neeson, 2014)