#!/bin/sh parts=( ) if [ $# -lt 5 ]; then printf "usage: %s input output [start duration [start duration ...]]\n" $0 2>&1 exit 1 fi input=$1 output=$2 shift shift while [ "x$1" != "x" -a "x$2" != "x" ] do tmp=`mktemp --tmpdir=. --suffix=.mpg` start=$1 echo $tmp ffmpeg -y -i "$input" -sameq -ss "$1" -t "$2" "$tmp" parts=( $parts $tmp ) shift shift done ffmpeg -y -i concat:$(printf "|%s" "${parts[@]}" | sed 's/^|//') -vcodec copy -acodec copy "$output"