summaryrefslogtreecommitdiff
path: root/src/cutint.sh
blob: f294b6c1306b0646cd484c4b8109b818ebf8205e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
# ! /usr/local/bin/bash

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" ]
do
#	tmp=`mktemp --tmpdir=. --suffix=.mpg`
	tmp=`mktemp -p . XXXXX`
	tmp=${tmp}.mpg
	start=$1
	echo $tmp
	duration=""
	[[ "x$2" != "x" ]] && duration="-t $2"
	
	ffmpeg -y -i "$input" -sameq -ss "$1" $duration "$tmp"

	parts=$(printf "%s|%s" "$parts" "$tmp")

	shift
	shift
done

ffmpeg -y -i concat:$(echo "$parts" | sed 's/^|//') -vcodec copy -acodec copy "$output"
rm $(echo $parts | sed 's/|/ /g')