1
0
James P. Ketrenos 6285d1ea75 Improved entry point scripts (sort of)
Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
2019-09-19 14:17:44 -07:00

115 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
PARAM=$0
# Strip path and cmd_ prefix from command name
PARAM=${PARAM##*/cmd_}
short() {
echo "Decode H264 video and save as raw file"
}
help() {
cat << EOF
$(short)
$(info)
INFILE Input stream must be H264 video
OUTFILE Will be decoded and saved as YUV420P
NOTE: Above paths are read from the container volume /media.
EOF
}
details() {
cat << EOF
$(short)
This script provides a quick reference example using the following
ffmpeg command:
ffmpeg \
-hwaccel qsv \
-qsv_device ${QSV_DEVICE} \
-c:v h264_qsv \
-i /media/INFILE \
-vf hwdownload,format=nv12 \
-pix_fmt yuv420p \
/media/OUTFILE
EOF
}
arguments=()
for arg in $*; do
[[ $arg =~ ^-- ]] && {
command=${arg/--}
case $command in
short) short
exit 0
;;
help) help
exit 0
;;
details) details
exit 0
;;
*) echo "Unrecognized command."
exit 1
;;
esac
} || {
arguments+=("$arg")
}
done
info() {
cat << EOF
usage: $PARAM INPUT-FILE OUTPUT-FILE
EOF
}
QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128}
[ "${arguments[0]}" == "" ] || [ "${arguments[1]}" == "" ] && {
info
exit 1
}
[ ! -e /media/"${arguments[0]}" ] && {
cat << EOF
Error: '${arguments[0]}' not found.
Was the volume /media mounted when launching the container?
docker ... --volume \$(pwd)/media:/media ...
or similar?
EOF
exit 1
}
[ ! -e ${QSV_DEVICE} ] && {
cat << EOF
Error: '${QSV_DEVCIE}' not found.
Did you pass /dev/dri to Docker?
docker ... --device=/dev/dri ...
or similar?
EOF
exit 2
}
ffmpeg -hwaccel qsv -qsv_device ${QSV_DEVICE} \
-c:v h264_qsv -i /media/"${arguments[0]}" \
-vf hwdownload,format=nv12 -pix_fmt yuv420p \
/media/"${arguments[1]}"