@@ -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