-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplot-bitrate
More file actions
executable file
·49 lines (43 loc) · 1.07 KB
/
plot-bitrate
File metadata and controls
executable file
·49 lines (43 loc) · 1.07 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
#!/bin/sh
# plot-bitrate
check_file() {
if [ ! -s "${1}" ]
then
echo "ERROR: \"${1}\" does not exist or is empty"
exit 1
fi
}
media_file="${1}"
check_file "${media_file}"
width="${2:-1920}"
height="${3:-1080}"
media_name="$(basename "${media_file}")"
data_file="${HOME}/.plot-bitrate_"${media_name}"_data.$$"
streams_file="${HOME}/.plot-bitrate_"${media_name}"_streams.$$"
libav-bitrate -P -e -I 1 "${media_file}" 2>&1 > "${data_file}"|tee /dev/tty|\
sed -n -e '/^[[:space:]]*Stream/s|^[[:space:]]*||p' > "${streams_file}"
for i in "${data_file}" "${streams_file}"
do
check_file "${i}"
done
{
echo "
set title \"${media_name}\"
set xdata time
set timefmt '%s'
set format x '%R'
set xlabel 'time'
set ylabel 'bitrate (Kb/s)'
set style data lines
set terminal qt size ${width},${height}
"
echo -n 'plot "'"${data_file}"'" using 1:($2/1024) title "Total"'
stream_n='2'
while read line
do
stream_n="$((${stream_n}+1))"
echo -n ', "'"${data_file}"'" using 1:($'"${stream_n}"'/1024) title "'"${line}"'"'
done < "${streams_file}"
echo
}|gnuplot --persist
rm "${data_file}" "${streams_file}"