33 lines · 1018 B · Python
RawDownload
#!/usr/bin/env python2 import sys, subprocess if len(sys.argv) > 2:    ifile  = sys.argv[1]    encopt = sys.argv[2:-1]    ofile  = sys.argv[-1]else:    print 'usage: %s <input> [encode_options] <output>' % sys.argv[0]    sys.exit(1) analysis_cmd  = 'ffprobe -v error -of compact=p=0:nk=1 'analysis_cmd += '-show_entries frame_tags=lavfi.r128.I -f lavfi 'analysis_cmd += "amovie='%s',ebur128=metadata=1" % ifiletry:    probe_out = subprocess.check_output(analysis_cmd, shell=True)except subprocess.CalledProcessError, e:    sys.exit(e.returncode)loudness = ref = -23for line in probe_out.splitlines():    sline = line.rstrip()    if sline:        loudness = slineadjust = ref - float(loudness)if abs(adjust) < 0.0001:    print 'No normalization needed for ' + ifileelse:    print "Adjust %s by %.1fdB" % (ifile, adjust)    norm_cmd  = ['ffmpeg', '-i', ifile, '-af', 'volume=%fdB' % adjust]    norm_cmd += encopt + [ofile]    print ' => %s' % ' '.join(norm_cmd)    subprocess.call(norm_cmd)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t