1
0
intel-media-ffmpeg/assets/cmd_1N_transcode
James P. Ketrenos 1434d551c2 Default to -y for 1N_transcode example
Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
2019-09-19 18:37:29 -07:00

129 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
PARAM=$0
# Strip path and cmd_ prefix from command name
PARAM=${PARAM##*/cmd_}
short() {
echo "Transcode AVC (H.264) to to streams: 1280x720@5Mbps and 60FPS@4Mbps"
}
help() {
cat << EOF
$(short)
$(info)
IN_FILE AVC (H.264) format input stream
OUT_FILE Base filename. "-5M.mp4" and "-4M60FPS.h264" will be added.
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/"\${IN_FILE}" \
-filter_complex "split=2[s1][s2]; \
[s1]scale_qsv=1280:720[o1]; \
[s2]vpp_qsv=framerate=60[o2]" \
-y \
-map [o1] -c:v h264_qsv -b:v 5M /media/"\${OUT_FILE}-5M.mp4" \
-map [o2] -c:v h264_qsv -b:v 4M /media/"\${OUT_FILE}-4M60FPS.h264"
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} \
-c:v h264_qsv \
-i /media/"${IN_FILE}" \
-filter_complex "split=2[s1][s2]; \
[s1]scale_qsv=1280:720[o1]; \
[s2]vpp_qsv=framerate=60[o2]" \
-y \
-map [o1] -c:v h264_qsv -b:v 5M /media/"${OUT_FILE}-5M.mp4" \
-map [o2] -c:v h264_qsv -b:v 4M /media/"${OUT_FILE}-4M60FPS.h264"