Ticket #7691: ffmpeg-format-support.sh

File ffmpeg-format-support.sh, 2.9 KB (added by eero-t, 7 years ago)

FFmpeg format support test script

Line 
1#!/bin/sh
2#
3# script for checking which of the FFmpeg output formats
4# are supported (with scaling) by given driver
5
6usage ()
7{
8 echo "Usage: ${0##*/} <ffmpeg path> <HEVC input video file>"
9 echo
10 echo "ERROR: $1!"
11 exit 1
12}
13
14if [ $# -ne 2 ]; then
15 usage "wrong number of arguments"
16fi
17
18errlog=ffmpeg-error.log
19ffmpeg=$1
20input=$2
21
22if [ \! -x "$ffmpeg" ]; then
23 usage "FFmpeg binary '$ffmpeg' missing or not executable"
24fi
25if [ \! -f "$input" ]; then
26 usage "input video file '$input' missing"
27fi
28if [ "${input%.h265}" = "${input}" ]; then
29 usage "input file '$input' not (*.h265) HEVC video"
30fi
31
32formats=$($ffmpeg -pix_fmts | awk '/^.O... [^=]/ {print $2}' | sort 2> $errlog)
33
34vaapi="-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi"
35qsv="-hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v hevc_qsv"
36
37# size for test scale
38wd=1920
39ht=540
40
41old_x=" "
42old_o=" "
43vaapi_x=" "
44vaapi_o=" "
45qsv_x=" "
46qsv_o=" "
47echo "Testing format:"
48for 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
82done
83echo
84
85printf "\ti965:\tVA-API:\tQSV:\tFormat:\n"
86for 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"
118done
119
120echo "X = format conversion before download, O = format conversion only after it, - = no support."
121echo
122echo "Note: FFmpeg stderr output was logged into $errlog."