Skip to content

Commit deefb8f

Browse files
authored
Merge pull request #9 from amiaopensource/add-phase
add integrated loudness column for signal analysis
2 parents c4748e7 + 19198c0 commit deefb8f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

audioqc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class QcTarget
152152
end
153153
end
154154

155-
def find_peaks_n_phase
155+
def find_peaks_loudness_n_phase
156156
high_db_frames = []
157157
out_of_phase_frames = []
158158
phase_frames = []
@@ -193,12 +193,13 @@ class QcTarget
193193
@average_levels = (@levels.reduce(:+) / @levels.size).round(2)
194194
@average_phase = (phase_frames.reduce(:+) / phase_frames.size).round(2)
195195
end
196+
@integratedLoudness = @ffprobe_out['frames'][@ffprobe_out.length - 3]['tags']['lavfi.r128.I']
196197
@warnings << 'LEVEL WARNING' if @high_level_count > 0
197198
@warnings << 'PHASE WARNING' if @phasey_frame_count > 50
198199
end
199200

200201
def get_ffprobe
201-
ffprobe_command = 'ffprobe -print_format json -threads auto -show_entries frame_tags=lavfi.astats.Overall.Number_of_samples,lavfi.astats.Overall.Peak_level,lavfi.astats.Overall.Max_difference,lavfi.astats.Overall.Mean_difference,lavfi.astats.Overall.Peak_level,lavfi.aphasemeter.phase -f lavfi -i "amovie=' + "\\'" + @input_path + "\\'" + ',astats=reset=1:metadata=1,aphasemeter=video=0"'
202+
ffprobe_command = 'ffprobe -print_format json -threads auto -show_entries frame_tags=lavfi.astats.Overall.Number_of_samples,lavfi.astats.Overall.Peak_level,lavfi.astats.Overall.Max_difference,lavfi.astats.Overall.Mean_difference,lavfi.astats.Overall.Peak_level,lavfi.aphasemeter.phase,lavfi.r128.I -f lavfi -i "amovie=' + "\\'" + @input_path + "\\'" + ',astats=reset=1:metadata=1,aphasemeter=video=0,ebur128=metadata=1"'
202203
@ffprobe_out = JSON.parse(`#{ffprobe_command}`)
203204
@total_frame_count = @ffprobe_out['frames'].size
204205
end
@@ -240,7 +241,7 @@ class QcTarget
240241
line << @possible_drops
241242
end
242243
if options.include?('signal')
243-
line += [@average_levels, @max_level, @high_level_count, @average_phase, @phasey_frame_count]
244+
line += [@average_levels, @max_level, @high_level_count, @average_phase, @phasey_frame_count, @integratedLoudness]
244245
end
245246
if options.include?('meta')
246247
line += [@wave_conformance] unless TARGET_EXTENSION != 'wav'
@@ -325,7 +326,7 @@ file_inputs.each do |fileinput|
325326
if options.include?('signal') || options.include?('dropouts')
326327
target.get_ffprobe
327328
if options.include?('signal')
328-
target.find_peaks_n_phase
329+
target.find_peaks_loudness_n_phase
329330
end
330331
if options.include?('dropouts')
331332
target.check_dropouts
@@ -355,7 +356,7 @@ CSV.open(output_csv, 'wb') do |csv|
355356
end
356357

357358
if options.include?('signal')
358-
headers += ['Average Level', 'Peak Level', 'Number of Frames w/ High Levels', 'Average Phase', 'Number of Phase Warnings']
359+
headers += ['Average Level', 'Peak Level', 'Number of Frames w/ High Levels', 'Average Phase', 'Number of Phase Warnings', 'Integrated Loudness']
359360
end
360361

361362
if options.include?('meta')

0 commit comments

Comments
 (0)