mv cmd_encode => cmd_decode and added cmd_encode helper
Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
parent
ffe90bd671
commit
773600fb03
12
Dockerfile
12
Dockerfile
@ -144,6 +144,13 @@ RUN ./configure --arch=x86_64 --disable-yasm --enable-vaapi --enable-libmfx \
|
|||||||
&& make \
|
&& make \
|
||||||
&& make install
|
&& make install
|
||||||
|
|
||||||
|
# ffmpeg is installed; the build and source trees are no longer needed
|
||||||
|
# RUN rm -rf /home/agama/ffmpeg
|
||||||
|
|
||||||
|
COPY assets/* /assets/
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/assets/entry" ]
|
||||||
|
|
||||||
#
|
#
|
||||||
# Standard ending begins here (from templates/ending.in)
|
# Standard ending begins here (from templates/ending.in)
|
||||||
#
|
#
|
||||||
@ -152,6 +159,11 @@ RUN ./configure --arch=x86_64 --disable-yasm --enable-vaapi --enable-libmfx \
|
|||||||
# changes,) causing all subsequent layers to be
|
# changes,) causing all subsequent layers to be
|
||||||
# regenerated.
|
# regenerated.
|
||||||
|
|
||||||
|
# Clean up APT content that might still be around
|
||||||
|
#RUN apt-get clean autoclean \
|
||||||
|
# && apt-get autoremove -y \
|
||||||
|
# && rm -rf /var/lib/${apt,dpkg,cache,log}
|
||||||
|
|
||||||
# Ensure that each Docker container self-documents the
|
# Ensure that each Docker container self-documents the
|
||||||
# versions included in it
|
# versions included in it
|
||||||
|
|
||||||
|
@ -36,3 +36,10 @@ WORKDIR /home/agama/ffmpeg
|
|||||||
RUN ./configure --arch=x86_64 --disable-yasm --enable-vaapi --enable-libmfx \
|
RUN ./configure --arch=x86_64 --disable-yasm --enable-vaapi --enable-libmfx \
|
||||||
&& make \
|
&& make \
|
||||||
&& make install
|
&& make install
|
||||||
|
|
||||||
|
# ffmpeg is installed; the build and source trees are no longer needed
|
||||||
|
# RUN rm -rf /home/agama/ffmpeg
|
||||||
|
|
||||||
|
COPY assets/* /assets/
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/assets/entry" ]
|
||||||
|
114
assets/cmd_decode
Executable file
114
assets/cmd_decode
Executable file
@ -0,0 +1,114 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PARAM=$0
|
||||||
|
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]}"
|
||||||
|
|
121
assets/cmd_encode
Executable file
121
assets/cmd_encode
Executable file
@ -0,0 +1,121 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PARAM=$0
|
||||||
|
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}"
|
95
assets/entry
Executable file
95
assets/entry
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
request=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
commands=(info help version ffmpeg)
|
||||||
|
commands+=(cmd_*)
|
||||||
|
|
||||||
|
cd /assets
|
||||||
|
|
||||||
|
. SOLUTION
|
||||||
|
. MANIFEST
|
||||||
|
|
||||||
|
name() {
|
||||||
|
cat << EOF
|
||||||
|
Intel Accelerated Graphics and Media Access container
|
||||||
|
Copyright (C) 2019 Intel Corporation
|
||||||
|
-----
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
[ "$1" == "--short" ] && {
|
||||||
|
echo "Information about running container environment"
|
||||||
|
} || {
|
||||||
|
cat << EOF
|
||||||
|
$(name)
|
||||||
|
|
||||||
|
Detected base OS: Ubuntu 19.04
|
||||||
|
Detected hardware: None
|
||||||
|
Detected Agama version: ${AGAMA_VERSION}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
version() {
|
||||||
|
[ "$1" == "--short" ] && {
|
||||||
|
echo "Show container version information"
|
||||||
|
} || {
|
||||||
|
cat << EOF
|
||||||
|
$CONTAINER built using Agama $AGAMA_VERSION.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ffmpeg() {
|
||||||
|
[ "$1" == "--short" ] && {
|
||||||
|
echo "Run ffmpeg commands."
|
||||||
|
} || {
|
||||||
|
/usr/local/bin/ffmpeg $*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
help() {
|
||||||
|
[ "$1" == "--short" ] && {
|
||||||
|
echo "This help information"
|
||||||
|
} || {
|
||||||
|
cat << EOF
|
||||||
|
$(name)
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
EOF
|
||||||
|
# Change cmd_foo to ./cmd_foo in expansion below
|
||||||
|
for cmd in ${commands[@]}; do
|
||||||
|
printf " %-15s %s\n" ${cmd/cmd_} "$(${cmd/cmd_/./cmd_} --short)"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case $request in
|
||||||
|
info)
|
||||||
|
info $*
|
||||||
|
;;
|
||||||
|
|
||||||
|
ffmpeg)
|
||||||
|
ffmpeg $*
|
||||||
|
;;
|
||||||
|
|
||||||
|
version)
|
||||||
|
version $*
|
||||||
|
;;
|
||||||
|
|
||||||
|
help|"")
|
||||||
|
help $*
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
[ ! -f ./cmd_$request ] && {
|
||||||
|
echo "'${request}' is not a recognized command."
|
||||||
|
} || {
|
||||||
|
./cmd_$request $*
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
esac
|
@ -3,6 +3,11 @@
|
|||||||
# changes,) causing all subsequent layers to be
|
# changes,) causing all subsequent layers to be
|
||||||
# regenerated.
|
# regenerated.
|
||||||
|
|
||||||
|
# Clean up APT content that might still be around
|
||||||
|
#RUN apt-get clean autoclean \
|
||||||
|
# && apt-get autoremove -y \
|
||||||
|
# && rm -rf /var/lib/${apt,dpkg,cache,log}
|
||||||
|
|
||||||
# Ensure that each Docker container self-documents the
|
# Ensure that each Docker container self-documents the
|
||||||
# versions included in it
|
# versions included in it
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user