-
Notifications
You must be signed in to change notification settings - Fork 29
/
sample-multi-transcode-AV1-1080p.sh
executable file
·62 lines (52 loc) · 2.39 KB
/
sample-multi-transcode-AV1-1080p.sh
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
#!/bin/bash
#
# Copyright (c) 2022 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
bitrate=${BITRATE:-3000}
preset=${PRESET:-veryfast}
async=${ASYNC:-1}
stream=bbb_sunflower_1080p_60fps_4Mbps_38kframes_av1.ivf
# process cmdline options
nstreams=$1
if [[ -z "$1" ]]; then
echo $(basename $0) "<num-of-streams> [<stream>]"
exit 0
fi
! [[ -z "$2" ]] && stream=$2
! [[ -e $stream ]] && download-streams.sh $stream
echo "Running 1080p AV1-AV1 1x$nstreams transcoding with SMT for $stream stream..."
# get devices
devices=( $(ls /dev/dri/renderD*) )
ndevs=${#devices[@]}
echo "Number of detected devices: $ndevs"
# set output
output="/dev/null"
[[ $nstreams = 1 ]] && output="$(basename $stream).av1.smt.ivf"
# encode loop
for ((i=0; i<$nstreams; i++)); do
device="${devices[((i % ndevs))]}"
sample_multi_transcode -device $device -i::av1 $stream -hw -async $async -u $preset -n 6000 -gop_size 256 -vbr \
-b $bitrate -NalHrdConformance:off -VuiNalHrdParameters:off -hrd $((bitrate / 2)) -InitialDelayInKB $((bitrate / 4)) -MaxKbps $((bitrate * 2)) \
-lowpower:on -lad 8 -extbrc::implicit -AdaptiveI:on -AdaptiveB:on -bref -dist 8 \
-o::av1 $output 2>&1 | tee $(basename $stream).${nstreams}.${i}.dev$((i % ndevs)).av1.smt.log &
done
wait
echo "Finished 1080p AV1-AV1 1x$nstreams transcoding with SMT for $stream stream"
cat $(basename $stream).${nstreams}.*.dev*.av1.smt.log | grep PASSED | grep fps