126 lines
1.8 KiB
Bash
Executable File
126 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
PARAM=$0
|
|
# Strip path from command name
|
|
PARAM=${PARAM##*/}
|
|
|
|
short() {
|
|
echo "Transcode AVC (H.264) to HEVC (H.265) with 5Mbps using VBR"
|
|
}
|
|
|
|
help() {
|
|
cat << EOF
|
|
$(short)
|
|
|
|
$(info)
|
|
|
|
IN_FILE AVC (H.264) format input stream
|
|
OUT_FILE HEVC (H.265) output stream
|
|
|
|
NOTE: Above paths are read from the container volume /data.
|
|
|
|
EOF
|
|
}
|
|
|
|
details() {
|
|
cat << EOF
|
|
$(short)
|
|
|
|
This script provides a quick reference example using the following
|
|
ffmpeg command:
|
|
|
|
ffmpeg \
|
|
-loglevel debug \
|
|
-hwaccel qsv \
|
|
-qsv_device \${QSV_DEVICE:-/dev/dri/renderD128} \
|
|
-c:v h264_qsv \
|
|
-i /data/"\${IN_FILE}" \
|
|
-c:v hevc_qsv \
|
|
-b:v 5M \
|
|
-y \
|
|
/data/"\${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 /data/"${arguments[0]}" ] && {
|
|
cat << EOF
|
|
Error: '${arguments[0]}' not found.
|
|
|
|
Was the volume /data mounted when launching the container?
|
|
|
|
docker ... --volume \$(pwd)/data:/data ...
|
|
|
|
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 \
|
|
-loglevel debug \
|
|
-hwaccel qsv \
|
|
-qsv_device ${QSV_DEVICE:-/dev/dri/renderD128} \
|
|
-c:v h264_qsv \
|
|
-i /data/"${IN_FILE}" \
|
|
-c:v hevc_qsv \
|
|
-b:v 5M \
|
|
-y \
|
|
/data/"${OUT_FILE}"
|