aboutsummaryrefslogtreecommitdiffstats
path: root/ffuse-frame
blob: 2541e7c2d7a09b7e8cc7141a606ffb10f870d417 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# See LICENSE file for copyright and license details.

set -e

usage () {
	printf 'usage %s: [-t time] [-y] in-file out-file\n' "$0" >&2
	exit 1
}

ffmpeg_flag_y=
ss=10

while getopts t:y flag; do
	case "$flag" in
	t)
		ss="${OPTARG}";;
	y)
		ffmpeg_flag_y=-y;;
	?)
		usage;;
	esac
done
shift $(( ${OPTIND} - 1 ))

if test ! $# = 2; then
	usage
fi

in_file="$1"
if test -z "${in_file}"; then
	usage
elif test ! "${in_file}" = -; then
	in_file="file:${in_file}"
else
	printf '%s: - is not supported for in-file\n' "$0" >&2
	exit 1
fi

out_file="$2"
if test -z "${out_file}"; then
	usage
elif test ! "${out_file}" = -; then
	out_file="file:${out_file}"
else
	printf '%s: - is not supported for out-file\n' "$0" >&2
	exit 1
fi

ffmpeg -i "${in_file}" -ss "${ss}" -update 1 -frames:v 1 -c:v png -f image2pipe - | \
	ffmpeg -f image2pipe -i - -i "${in_file}" -map 0:v:0 -map 1:a:0 -c:v png ${ffmpeg_flag_y} -- "${out_file}"