7 encopt = sys.argv[2:-1]
10 print 'usage: %s <input> [encode_options] <output>' % sys.argv[0]
13 analysis_cmd =
'ffprobe -v error -of compact=p=0:nk=1 ' 14 analysis_cmd +=
'-show_entries frame_tags=lavfi.r128.I -f lavfi ' 15 analysis_cmd +=
"amovie='%s',ebur128=metadata=1" % ifile
17 probe_out = subprocess.check_output(analysis_cmd, shell=
True)
18 except subprocess.CalledProcessError, e:
19 sys.exit(e.returncode)
21 for line
in probe_out.splitlines():
25 adjust = ref - float(loudness)
26 if abs(adjust) < 0.0001:
27 print 'No normalization needed for ' + ifile
29 print "Adjust %s by %.1fdB" % (ifile, adjust)
30 norm_cmd = [
'ffmpeg',
'-i', ifile,
'-af',
'volume=%fdB' % adjust]
31 norm_cmd += encopt + [ofile]
32 print ' => %s' %
' '.join(norm_cmd)
33 subprocess.call(norm_cmd)