-
Notifications
You must be signed in to change notification settings - Fork 27
/
audiotest
executable file
·46 lines (38 loc) · 3.76 KB
/
audiotest
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
#!/bin/bash
echo "Package Name,First Object File Name,Count of Object Files,Count of Image Files,integrated loudness,loudness range,true peak,threshold,\
target_offset,cuny loudness adjustment,silent ranges,phase issues,interstitial,duration,samplerate,channels,codec,peak level ch1,peak level ch2,peak level diff,bitscope,dcoffset,flatfactor,peakcount,bwfmetaedit"
while [[ "${@}" != "" ]] ; do
PACKAGE="$1"
shift
FILECOUNT=$(find "${PACKAGE}/objects" -maxdepth 2 -type f ! -name .DS_Store | wc -l | sed 's/ //g')
find "${PACKAGE}/objects" -maxdepth 2 -type f ! -name .DS_Store | while read FILENAME ; do
ffmpeg -nostdin -i "${FILENAME}" -vn -filter_complex "silencedetect,astats,loudnorm=print_format=json,agate=attack=0.01:release=0.01:ratio=9000,aphasemeter=r=0.2:video=0,ametadata=mode=print:key=lavfi.aphasemeter.phase:value=-0.18:function=less" -f null - 2>&1 | tr "\r" "\n" > /tmp/loud
image_count=$(find "${PACKAGE}/metadata/depictions" -maxdepth 2 -type f ! -name .DS_Store | wc -l | sed 's/ //g')
measured_I=$(cat /tmp/loud | grep "input_i" | awk -F\" '{print $4}')
measured_LRA=$(cat /tmp/loud | grep "input_lra" | awk -F\" '{print $4}')
measured_TP=$(cat /tmp/loud | grep "input_tp" | awk -F\" '{print $4}')
measured_thresh=$(cat /tmp/loud | grep "input_thresh" | awk -F\" '{print $4}')
target_offset=$(cat /tmp/loud | grep "target_offset" | awk -F\" '{print $4}')
LOUD_ADJ=$(echo "($measured_I - -24)*-1" | bc)
DURATION=$(ffprobe "$FILENAME" -show_entries format=duration -of default=nw=1:nk=1 2>/dev/null)
SAMPLERATE=$(ffprobe "$FILENAME" -show_entries stream=sample_rate -of default=nw=1:nk=1 2>/dev/null)
CHANNELS=$(ffprobe "$FILENAME" -show_entries stream=channels -of default=nw=1:nk=1 2>/dev/null)
CODEC=$(ffprobe "$FILENAME" -show_entries stream=codec_name -of default=nw=1:nk=1 2>/dev/null)
PEAKLEVEL1=$(cat /tmp/loud | grep "Peak level dB:" | tail -n +1 | head -n 1 | cut -d ":" -f 2 | sed 's/ //g')
PEAKLEVEL2=$(cat /tmp/loud | grep "Peak level dB:" | tail -n +2 | head -n 1 | cut -d ":" -f 2 | sed 's/ //g')
PEAKLEVELDIFF=$(echo "scale=3; $PEAKLEVEL1 - $PEAKLEVEL2" | bc)
BITSCOPE=$(cat /tmp/loud | grep "Bit depth: " | tail -n +3 | head -n 1 | cut -d ":" -f 2 | sed 's/ //g')
DCOFFSET=$(cat /tmp/loud | grep "DC offset: " | tail -n +3 | head -n 1 | cut -d ":" -f 2 | sed 's/ //g')
FLATFACTOR=$(cat /tmp/loud | grep "Flat factor: " | tail -n +3 | head -n 1 | cut -d ":" -f 2 | sed 's/ //g')
PEAKCOUNT=$(cat /tmp/loud | grep "Peak count: " | tail -n +3 | head -n 1 | cut -d ":" -f 2 | sed 's/ //g')
bwfmetaedit=$(bwfmetaedit "$FILENAME" 2>&1 | awk '{printf "%s+",$0} END {print ""}')
SILENCE=$(cat /tmp/loud | grep " silence_end: " | while read line ; do
silence_duration=$(echo "$line" | awk '{print $8}')
silence_end=$(echo "$line" | awk '{print $5}')
echo -n "$silence_end ($silence_duration);"
done)
PHASEERROR=$(grep Parsed_ametadata /tmp/loud | paste - - | sed "s/lavfi.aphasemeter.phase=//g" | cut -d ":" -f 4 | awk '{print $1 "(" $5 ")"}' | xargs)
INTERSTITIAL=$(ffprobe -f lavfi -i "amovie=${FILENAME},loudnorm=tp=0,astats=metadata=1:reset=1" -show_entries frame=pkt_pts_time:frame_tags=lavfi.astats.Overall.Max_difference -of csv 2>/dev/null | awk -F "," '$3>=0.07' | awk -F "," '{print $2 "(" $3 ")"}' | xargs)
echo "$(basename "$PACKAGE"),$(basename "$FILENAME"),$FILECOUNT,$image_count,$measured_I,$measured_LRA,$measured_TP,$measured_thresh,$target_offset,$LOUD_ADJ,$SILENCE,$PHASEERROR,$INTERSTITIAL,$DURATION,$SAMPLERATE,$CHANNELS,$CODEC,$PEAKLEVEL1,$PEAKLEVEL2,$PEAKLEVELDIFF,$BITSCOPE,$DCOFFSET,$FLATFACTOR,$PEAKCOUNT,$bwfmetaedit"
done
done