Update encode_audio.py

* Allow ffmpeg to show its progress without outputing all of its junk
* Add a TO-DO. If you know of a reliable way to do this, please send in a PR!
This commit is contained in:
LightArrowsEXE 2019-07-24 01:19:23 +02:00
parent ec41783606
commit cd7dd63761

View file

@ -28,12 +28,13 @@ else:
filelist = glob.glob('*')
for f in filelist:
print(f)
if not re.search(r'\.(wav|m4a|flac|lwi)$', f):
subprocess.call(["ffmpeg", "-hide_banner", "-loglevel", "panic", "-i", f,"-vn", f"{os.path.splitext(f)[0]}.wav"])
# TO-DO: Figure out a reliable way to only loop through audio files, but ignore the following three. Maybe messing with MIME recognition?
if not re.search(r'\.(wav|m4a|flac)$', f):
print(f)
subprocess.call(["ffmpeg", "-loglevel", "panic", "-stats", "-i", f,"-vn", f"{os.path.splitext(f)[0]}.wav"])
if not os.path.exists(f'{f[0]}.m4a') or os.path.exists(f'{f[0]}.flac'):
if args.flac:
subprocess.call(["ffmpeg", "-hide_banner", "-i", f"{os.path.splitext(f)[0]}.wav", "-vn", "-c:a flac", "-sample_fmt s16","compression_level 12", f"{os.path.splitext(f)[0]}.flac"])
subprocess.call(["ffmpeg", "-i", f"{os.path.splitext(f)[0]}.wav", "-vn", "-c:a flac", "-sample_fmt s16","compression_level 12", f"{os.path.splitext(f)[0]}.flac"])
else:
subprocess.call(["qaac", f"{os.path.splitext(f)[0]}.wav", "-V 127"])
else: