aboutsummaryrefslogtreecommitdiffstats
path: root/ffextract-frame
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xffextract-frame53
-rw-r--r--ffextract-frame.161
2 files changed, 114 insertions, 0 deletions
diff --git a/ffextract-frame b/ffextract-frame
new file mode 100755
index 0000000..b946550
--- /dev/null
+++ b/ffextract-frame
@@ -0,0 +1,53 @@
+#!/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 ! $# = 1 && test ! $# = 2; then
+ usage
+fi
+
+removeext () {
+ printf '%s\0' "$1" | tr '\0\n' '\n\0' | sed 's/\.[^.]*$//' | tr '\0' '\n'
+}
+
+in_file="$1"
+if test -z "${in_file}"; then
+ usage
+fi
+
+out_file=""
+if test $# = 2; then
+ out_file="$2"
+ if test -z "${out_file}"; then
+ usage
+ fi
+else
+ out_file="$(removeext "${in_file}").png"
+fi
+
+if test "${out_file}" = -; then
+ exec ffmpeg -i "${in_file}" -ss "${ss}" -update 1 -frames:v 1 -c:v png -f image2pipe -
+else
+ exec ffmpeg -i "${in_file}" -ss "${ss}" -update 1 -frames:v 1 ${ffmpeg_flag_y} -- "${out_file}"
+fi
diff --git a/ffextract-frame.1 b/ffextract-frame.1
new file mode 100644
index 0000000..e048414
--- /dev/null
+++ b/ffextract-frame.1
@@ -0,0 +1,61 @@
+.TH FFEXTRACT-FRAME 1 FFUTILS
+.SH NAME
+ffextract-frame \- create an image file from a video file
+
+.SH SYNOPSIS
+.B ffextract-frame
+[-t
+.IR time ]
+[-y]
+.I in-file
+.RI [ out-file ]
+
+.SH DESCRIPTION
+.B ffextract-frame
+extracts a frame from the video track from
+.I in-file
+and copies it into the new file
+.IR out-file .
+
+.SH OPTIONS
+.TP
+.BR \-t \ \fItime\fP
+The timestamp of the frame to used. The default is 10 seconds.
+.TP
+.BR \-y
+Overwrite output file if it already exists.
+
+.SH OPERANDS
+.TP
+.I in-file
+Video file to extract the frame from.
+.TP
+.I out-file
+The pathname for the new image file.
+
+If omitted,
+.I in-file
+is used with the suffix (if any) removed
+and replaced with \(dq.png\(dq.
+
+If
+.I in-file
+is a dash
+.RB ( - ),
+standard out is used, and the file format will be
+Portable Network Graphics (PNG) otherwise, the format
+is determined by the filename suffix.
+
+.SH EXIT VALUE
+.TP
+0
+Successful completely.
+.TP
+1
+An error occurred.
+
+.SH SEE ALSO
+.BR ffmpeg (1),
+.BR ffextract-audio (1),
+.BR ffget-audio-extension (1),
+.BR ffuse-frame (1)