-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·80 lines (70 loc) · 2.47 KB
/
test.sh
File metadata and controls
executable file
·80 lines (70 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
SAMPLE_VIDEO="${HOME}/Videos/input.mp4"
TEST_LIBX264=0
function title() {
TITLE="${1}"
echo -e "\n## ${TITLE}\n"
}
function encode() {
FFMPEG="${1}"
VCODEC="${2}"
PACKAGE="${3}"
OUTPUT="${HOME}/test_${PACKAGE}_${VCODEC}.mp4"
title "${FFMPEG} is encoding ${SAMPLE_VIDEO} using ${VCODEC}"
if [[ ${VCODEC} = *"nvenc"* ]]; then
# Do we have NVENC capable hardware?
NVENC=$(nvidia-smi -q | grep Encoder | wc -l)
if [ ${NVENC} -ge 1 ]; then
/usr/bin/time --format=" - elapsed time: %e" ${FFMPEG} -hide_banner -loglevel error -y -i ${SAMPLE_VIDEO} -vcodec ${VCODEC} -acodec copy ${OUTPUT}
else
echo " - incompatible hardware skipping ${VCODEC} test."
fi
elif [[ ${VCODEC} = *"vaapi"* ]]; then
# Do we have VA-API capable hardware?
VAINFO=$(vainfo 2>/dev/null)
VAAPI=$?
if [ ${VAAPI} -eq 0 ]; then
/usr/bin/time --format=" - elapsed time: %e" ${FFMPEG} -hide_banner -loglevel error -y -vaapi_device /dev/dri/renderD128 -i ${SAMPLE_VIDEO} -vf 'format=nv12,hwupload' -vcodec ${VCODEC} -acodec copy ${OUTPUT}
else
echo " - incompatible hardware skipping ${VCODEC} test."
fi
else
/usr/bin/time --format=" - elapsed time: %e" ${FFMPEG} -hide_banner -loglevel error -y -i ${SAMPLE_VIDEO} -vcodec ${VCODEC} -acodec copy ${OUTPUT}
fi
}
sudo apt install -y ffmpeg 2>/dev/null
sudo apt install -y vainfo 2>/dev/null
# Make sure the correct version of nvidia-smi is installed
for NV_VER in 390 396 410 415 418 440; do
dpkg -s nvidia-driver-${NV_VER} &> /dev/null
if [ $? -eq 0 ]; then
echo "nvidia $NV_VER is installed"
sudo apt install -y nvidia-utils-${NV_VER} 2>/dev/null
break
fi
done
sudo snap install ffmpeg
sudo snap connect ffmpeg:camera
sudo snap connect ffmpeg:hardware-observe
for LOCATION in usr snap; do
title "ffmpeg ${LOCATION} features"
/${LOCATION}/bin/ffmpeg -hide_banner -hwaccels
for FEATURE in encoders decoders filters; do
echo ${FEATURE}:; /${LOCATION}/bin/ffmpeg -hide_banner -${FEATURE} | egrep -i "cuda|cuvid|mmal|npp|nvdec|nvenc|omx|vaapi|vdpau"
done
done
# CPU Encode
for LOCATION in usr snap; do
if [ ${TEST_LIBX264} -eq 1 ]; then
encode /${LOCATION}/bin/ffmpeg libx264 ${LOCATION}
fi
done
# NVENC/HEVC Encode
for LOCATION in usr snap; do
encode /${LOCATION}/bin/ffmpeg h264_nvenc ${LOCATION}
encode /${LOCATION}/bin/ffmpeg hevc_nvenc ${LOCATION}
done
# VA-API Encode
for LOCATION in usr snap; do
encode /${LOCATION}/bin/ffmpeg h264_vaapi ${LOCATION}
done