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

123 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
PARAM=$0
# Strip path and cmd_ prefix from command name
PARAM=${PARAM##*/cmd_}
short() {
echo "Encode 10 frames from YUV420 raw input as H264 with 5Mbps using VBR mode"
}
help() {
cat << EOF
$(short)
$(info)
INFILE Must 720p raw
OUTFILE Will be encoded as H264 w/ 5Mbps using VBR
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 -loglevel debug \
-init_hw_device qsv=hw \
-filter_hw_device hw \
-f rawvideo -pix_fmt yuv420p \
-s:v 176x144 \
-i /media/INFILE \
-vf hwupload=extra_hw_frames=64,format=qsv \
-c:v h264_qsv \
-b:v 5M \
-frames:v 10 \
-y /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
}
INFILE="${arguments[0]}"
OUTFILE="${arguments[1]}"
ffmpeg -loglevel debug -init_hw_device qsv=hw \
-filter_hw_device hw -f rawvideo -pix_fmt \
yuv420p -s:v 176x144 -i /media/"${INFILE}" -vf \
hwupload=extra_hw_frames=64,format=qsv \
-c:v h264_qsv -b:v 5M -frames:v 10 \
-y /media/"${OUTFILE}"