可能最简单的方法是创建一个编辑决策列表 (EDL),然后您可以使用它来编写您的最终视频。我不知道 ffmpeg/avconv,但mplayer/mencoder
会处理这些,请参阅文档。
要创建 EDL,请使用如下函数:
make_edl() {
DUR=$1
PRE=$2
SLICES=$3
POST=$4
## get the duration of the cut-up pieces
SNIPPET=$(((DUR-PRE-POST)/SLICES))
START=$PRE
STOP=$((DUR-POST))
curr=$START
while [ $curr -lt $STOP ]; do
currstop=$((cur+SNIPPET))
if [ $currstop -gt $STOP ]; then
currstop=$STOP
fi
echo "${curr} $((curr+SNIPPET)) 0"
curr=$((curr+2*SNIPPET))
done
}
# ...
## the following create an EDL for a 923sec movie,
## where we have 120sec of intro, than 31 alternating slices
## and 120sec of outro
make_edl 923 120 31 120 > myedl.txt
## apply the EDL
mencoder -edl myedl.txt input923.mov -o output923.mov
由于 bash 算术的限制(仅限整数),这不是很珍贵