Skip to content

Commit ba74643

Browse files
committed
filter for -inf
1 parent f0f4fed commit ba74643

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

audioqc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,19 @@ class QcTarget
198198
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.1.Peak_level,lavfi.astats.2.Peak_level,lavfi.astats.1.Peak_level,lavfi.astats.Overall.Mean_difference,lavfi.astats.Overall.Peak_level,lavfi.r128.I -f lavfi -i "amovie=' + "\\'" + @input_path + "\\'" + ',astats=reset=1:metadata=1,ebur128=metadata=1"'
199199
@ffprobe_out = JSON.parse(`#{ffprobe_command}`)
200200
@ffprobe_out['frames'].each do |frame|
201-
channel_one_vol << frame['tags']['lavfi.astats.1.Peak_level'].to_f
202-
channel_two_vol << frame['tags']['lavfi.astats.2.Peak_level'].to_f
203-
@channel_one_max = channel_one_vol.max
204-
@channel_two_max = channel_two_vol.max
205-
channel_dif = (channel_one_vol.max - channel_two_vol.max).abs.to_s
206-
if channel_two_vol.max < channel_one_vol.max
207-
@volume_command = ' -filter_complex "[0:a]channelsplit[a][b],[b]volume=volume=' + channel_dif + 'dB:precision=fixed[c],[a][c]amerge[out1]" -map [out1] '
201+
if frame['tags']['lavfi.astats.1.Peak_level'] == '-inf' || frame['tags']['lavfi.astats.2.Peak_level'] == 'inf'
202+
next
208203
else
209-
@volume_command = ' -filter_complex "[0:a]channelsplit[a][b],[a]volume=volume=' + channel_dif + 'dB:precision=fixed[c],[c][b]amerge[out1]" -map [out1] '
204+
channel_one_vol << frame['tags']['lavfi.astats.1.Peak_level'].to_f
205+
channel_two_vol << frame['tags']['lavfi.astats.2.Peak_level'].to_f
206+
@channel_one_max = channel_one_vol.max
207+
@channel_two_max = channel_two_vol.max
208+
channel_dif = (channel_one_vol.max - channel_two_vol.max).abs.to_s
209+
if channel_two_vol.max < channel_one_vol.max
210+
@volume_command = ' -filter_complex "[0:a]channelsplit[a][b],[b]volume=volume=' + channel_dif + 'dB:precision=fixed[c],[a][c]amerge[out1]" -map [out1] '
211+
else
212+
@volume_command = ' -filter_complex "[0:a]channelsplit[a][b],[a]volume=volume=' + channel_dif + 'dB:precision=fixed[c],[c][b]amerge[out1]" -map [out1] '
213+
end
210214
end
211215
end
212216
get_ffprobe_phase_normalized(@volume_command)

0 commit comments

Comments
 (0)