| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # script for checking which of the FFmpeg output formats
|
|---|
| 4 | # are supported (with scaling) by given driver
|
|---|
| 5 |
|
|---|
| 6 | usage ()
|
|---|
| 7 | {
|
|---|
| 8 | echo "Usage: ${0##*/} <ffmpeg path> <HEVC input video file>"
|
|---|
| 9 | echo
|
|---|
| 10 | echo "ERROR: $1!"
|
|---|
| 11 | exit 1
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | if [ $# -ne 2 ]; then
|
|---|
| 15 | usage "wrong number of arguments"
|
|---|
| 16 | fi
|
|---|
| 17 |
|
|---|
| 18 | errlog=ffmpeg-error.log
|
|---|
| 19 | ffmpeg=$1
|
|---|
| 20 | input=$2
|
|---|
| 21 |
|
|---|
| 22 | if [ \! -x "$ffmpeg" ]; then
|
|---|
| 23 | usage "FFmpeg binary '$ffmpeg' missing or not executable"
|
|---|
| 24 | fi
|
|---|
| 25 | if [ \! -f "$input" ]; then
|
|---|
| 26 | usage "input video file '$input' missing"
|
|---|
| 27 | fi
|
|---|
| 28 | if [ "${input%.h265}" = "${input}" ]; then
|
|---|
| 29 | usage "input file '$input' not (*.h265) HEVC video"
|
|---|
| 30 | fi
|
|---|
| 31 |
|
|---|
| 32 | formats=$($ffmpeg -pix_fmts | awk '/^.O... [^=]/ {print $2}' | sort 2> $errlog)
|
|---|
| 33 |
|
|---|
| 34 | vaapi="-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi"
|
|---|
| 35 | qsv="-hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v hevc_qsv"
|
|---|
| 36 |
|
|---|
| 37 | # size for test scale
|
|---|
| 38 | wd=1920
|
|---|
| 39 | ht=540
|
|---|
| 40 |
|
|---|
| 41 | old_x=" "
|
|---|
| 42 | old_o=" "
|
|---|
| 43 | vaapi_x=" "
|
|---|
| 44 | vaapi_o=" "
|
|---|
| 45 | qsv_x=" "
|
|---|
| 46 | qsv_o=" "
|
|---|
| 47 | echo "Testing format:"
|
|---|
| 48 | for format in $formats; do
|
|---|
| 49 | echo "- $format"
|
|---|
| 50 | export LIBVA_DRIVER_NAME=i965
|
|---|
| 51 | $ffmpeg $vaapi -i $input -vf scale_vaapi=w=$wd:h=$ht:format=$format,hwdownload,format=$format -f null - 2>> $errlog
|
|---|
| 52 | if [ $? -eq 0 ]; then
|
|---|
| 53 | old_x="$old_x $format "
|
|---|
| 54 | else
|
|---|
| 55 | # VA-API output without GPU side format conversion
|
|---|
| 56 | $ffmpeg $vaapi -i $input -vf scale_vaapi=w=$wd:h=$ht,hwdownload,format=$format -f null - 2>> $errlog
|
|---|
| 57 | if [ $? -eq 0 ]; then
|
|---|
| 58 | old_o="$old_o $format "
|
|---|
| 59 | fi
|
|---|
| 60 | fi
|
|---|
| 61 | export LIBVA_DRIVER_NAME=iHD
|
|---|
| 62 | $ffmpeg $vaapi -i $input -vf scale_vaapi=w=$wd:h=$ht:format=$format,hwdownload,format=$format -f null - 2>> $errlog
|
|---|
| 63 | if [ $? -eq 0 ]; then
|
|---|
| 64 | vaapi_x="$vaapi_x $format "
|
|---|
| 65 | else
|
|---|
| 66 | # VA-API output without GPU side format conversion
|
|---|
| 67 | $ffmpeg $vaapi -i $input -vf scale_vaapi=w=$wd:h=$ht,hwdownload,format=$format -f null - 2>> $errlog
|
|---|
| 68 | if [ $? -eq 0 ]; then
|
|---|
| 69 | vaapi_o="$vaapi_o $format "
|
|---|
| 70 | fi
|
|---|
| 71 | fi
|
|---|
| 72 | $ffmpeg $qsv -i $input -vf scale_qsv=w=$wd:h=$ht:format=$format,hwdownload,format=$format -f null - 2>> $errlog
|
|---|
| 73 | if [ $? -eq 0 ]; then
|
|---|
| 74 | qsv_x="$qsv_x $format "
|
|---|
| 75 | else
|
|---|
| 76 | # QSV output without GPU side format conversion
|
|---|
| 77 | $ffmpeg $qsv -i $input -vf scale_qsv=w=$wd:h=$ht,hwdownload,format=$format -f null - 2>> $errlog
|
|---|
| 78 | if [ $? -eq 0 ]; then
|
|---|
| 79 | qsv_o="$qsv_o $format "
|
|---|
| 80 | fi
|
|---|
| 81 | fi
|
|---|
| 82 | done
|
|---|
| 83 | echo
|
|---|
| 84 |
|
|---|
| 85 | printf "\ti965:\tVA-API:\tQSV:\tFormat:\n"
|
|---|
| 86 | for format in $formats; do
|
|---|
| 87 | old='-'
|
|---|
| 88 | qsv='-'
|
|---|
| 89 | vaapi='-'
|
|---|
| 90 | echo $old_x | grep -q -w $format
|
|---|
| 91 | if [ $? -eq 0 ]; then
|
|---|
| 92 | old='X'
|
|---|
| 93 | else
|
|---|
| 94 | echo $old_o | grep -q -w $format
|
|---|
| 95 | if [ $? -eq 0 ]; then
|
|---|
| 96 | old='O'
|
|---|
| 97 | fi
|
|---|
| 98 | fi
|
|---|
| 99 | echo $qsv_x | grep -q -w $format
|
|---|
| 100 | if [ $? -eq 0 ]; then
|
|---|
| 101 | qsv='X'
|
|---|
| 102 | else
|
|---|
| 103 | echo $qsv_o | grep -q -w $format
|
|---|
| 104 | if [ $? -eq 0 ]; then
|
|---|
| 105 | qsv='O'
|
|---|
| 106 | fi
|
|---|
| 107 | fi
|
|---|
| 108 | echo $vaapi_x | grep -q -w $format
|
|---|
| 109 | if [ $? -eq 0 ]; then
|
|---|
| 110 | vaapi='X'
|
|---|
| 111 | else
|
|---|
| 112 | echo $vaapi_o | grep -q -w $format
|
|---|
| 113 | if [ $? -eq 0 ]; then
|
|---|
| 114 | vaapi='O'
|
|---|
| 115 | fi
|
|---|
| 116 | fi
|
|---|
| 117 | printf "\t$old\t$vaapi\t$qsv\t$format\n"
|
|---|
| 118 | done
|
|---|
| 119 |
|
|---|
| 120 | echo "X = format conversion before download, O = format conversion only after it, - = no support."
|
|---|
| 121 | echo
|
|---|
| 122 | echo "Note: FFmpeg stderr output was logged into $errlog."
|
|---|