diff --git a/README.md b/README.md index 1b117ca..fc78757 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,25 @@ If you are in a multicard environment, see Appendix A. ## Test hardware accelerated FFMPEG media operations +First download test content into ./media, then launch +the Docker container mounting that path to the /media +volume, running the 'test' command. + +NOTE: The test media stream is currently hard coded to +expect the name AUD_WM_E.264 in the container. + ```bash -scripts/test +mkdir $(pwd)/media +wget -O $(pwd)/media/AUD_MW_E.264 \ + https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264 +docker run \ + --rm \ + --device=/dev/dri \ + -e QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128} \ + --volume $(pwd)/media:/media \ + -it \ + intel-media-ffmpeg \ + test ``` The above will: diff --git a/assets/commands/test b/assets/commands/test new file mode 100755 index 0000000..e02c276 --- /dev/null +++ b/assets/commands/test @@ -0,0 +1,136 @@ +#!/bin/bash +PARAM=$0 +# Strip path from command name +PARAM=${PARAM##*/} + +short() { + echo "Execute GPU offload of decode, encode, and transcode." +} + +help() { +cat << EOF +$(short) + +$(info) +EOF +} + +details() { +cat << EOF +$(short) + +This script provides a quick test of decode, encode, and transcode using +GPU offload. It is equivelant to manually running the following test +cases: + + decode AUD_MW_E.264 AUD_MW.yuv + encode AUD_MW.yuv AUD_MW_E.h264 + transcode AUD_MW_E.264 AUD_MW_E.hevc + 1N_transcode AUD_MW_E.264 AUD_1N + +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 +EOF +} + +QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128} + +[ ${#arguments[*]} != 0 ] && { + info + exit 1 +} + +[ ! -d /media/. ] && { + cat << EOF +Error: '/media/' 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 +} + +[ ! -e "/media/AUD_MW_E.264" ] && { + cat << EOF + +Error: Test file h264 (AVC) not found. Is /media mounted? + +You can download a test stream via: + + mkdir -p \$(pwd)/media + wget -O \$(pwd)/media/AUD_MW_E.264 \\ + 'https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264' + +Once downloaded, re-run this test. When you launch the Docker +container, make sure you mount the '\$(pwd)/media' path as +the /media volume via: + + docker ... --volume \$(pwd)/media:/media ... + +EOF + + exit 3 +} + +tests=( + "decode AUD_MW_E.264 AUD_MW.yuv" + "encode AUD_MW.yuv AUD_MW_E.h264" + "transcode AUD_MW_E.264 AUD_MW_E.hevc" + "1N_transcode AUD_MW_E.264 AUD_1N" +) +for test in "${tests[@]}"; do + test=($test) + /assets/commands/${test[*]} || { + echo "Error: Test failed: ${test[*]}" + exit 5 + } +done + diff --git a/scripts/test b/scripts/test deleted file mode 100755 index ac2d707..0000000 --- a/scripts/test +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -HOST_MEDIA=$(pwd)/media -[ ! -e "${HOST_MEDIA}/AUD_MW_E.264" ] && { - mkdir -p ${HOST_MEDIA} - wget -q -O ${HOST_MEDIA}/AUD_MW_E.264 \ - https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264 -} -tests=( - "decode AUD_MW_E.264 AUD_MW.yuv" - "encode AUD_MW.yuv AUD_MW_E.h264" - "transcode AUD_MW_E.264 AUD_MW_E.hevc" - "1N_transcode AUD_MW_E.264 AUD_1N" -) -for test in "${tests[@]}"; do - test=($test) - docker run --rm \ - --volume ${HOST_MEDIA}:/media -it \ - --device=/dev/dri -e QSV_DEVICE=${QSV_DEVICE:-/dev/dri/renderD128} \ - intel-media-ffmpeg ${test[*]} || { - echo "Error: Test failed: ${test[*]}" - break - } -done -