1
0
James P. Ketrenos 7ff2fdf343 Moved assets/cmd_* to assets/commands/*
Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
2019-09-23 19:24:15 -07:00

122 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
PARAM=$0
# Strip path from command name
PARAM=${PARAM##*/}
short() {
echo "Decode AVC (H.264) video and save as YUV 420P raw file"
}
help() {
cat << EOF
$(short)
$(info)
IN_FILE Input stream must be AVC (H.264) video
OUT_FILE Output stream as YUV 420P
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:-/dev/dri/renderD128} \
-c:v h264_qsv \
-i /media/"\${IN_FILE}" \
-vf hwdownload,format=nv12 -pix_fmt yuv420p \
-y \
/media/"\${OUT_FILE}"
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_DEVICE}' not found.
Did you pass /dev/dri to Docker?
docker ... --device=/dev/dri ...
or similar?
EOF
exit 2
}
IN_FILE="${arguments[0]}"
OUT_FILE="${arguments[1]}"
ffmpeg \
-hwaccel qsv \
-qsv_device ${QSV_DEVICE:-/dev/dri/renderD128} \
-c:v h264_qsv \
-i /media/"${IN_FILE}" \
-vf hwdownload,format=nv12 -pix_fmt yuv420p \
-y \
/media/"${OUT_FILE}"