Separated ffmpy arguments into dicts. (use later to include covers)
This commit is contained in:
parent
c14fc5a77d
commit
b145688b6b
@ -121,31 +121,36 @@ def loudness_info(inputfile) -> dict[str, str]:
|
|||||||
|
|
||||||
def convert(inputfile, outputfile, loudness):
|
def convert(inputfile, outputfile, loudness):
|
||||||
print("Working on ", os.path.basename(inputfile))
|
print("Working on ", os.path.basename(inputfile))
|
||||||
|
# coverpath = os.path.join(os.path.dirname(inputfile), "cover.jpg")
|
||||||
|
# NOTE including covers into ogg/opus containers currently doesn't work
|
||||||
|
# https://trac.ffmpeg.org/ticket/4448
|
||||||
|
inputcmd = {inputfile: None}
|
||||||
|
outputcmd = {
|
||||||
|
outputfile: "-pass 2"
|
||||||
|
" "
|
||||||
|
"-filter:a"
|
||||||
|
" "
|
||||||
|
"loudnorm=I=-30.0:"
|
||||||
|
"measured_I={input_i}:"
|
||||||
|
"measured_LRA={input_lra}:"
|
||||||
|
"measured_tp={input_tp}:measured_thresh={input_thresh}"
|
||||||
|
" "
|
||||||
|
"-c:a libopus"
|
||||||
|
" "
|
||||||
|
"-b:a 320k".format(
|
||||||
|
input_i=loudness["input_i"],
|
||||||
|
input_lra=loudness["input_lra"],
|
||||||
|
input_tp=loudness["input_tp"],
|
||||||
|
input_thresh=loudness["input_thresh"],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
ff = ffmpy.FFmpeg(
|
ff = ffmpy.FFmpeg(
|
||||||
inputs={inputfile: None},
|
inputs=inputcmd,
|
||||||
outputs={
|
outputs=outputcmd,
|
||||||
outputfile: "-pass 2"
|
|
||||||
" "
|
|
||||||
"-filter:a"
|
|
||||||
" "
|
|
||||||
"loudnorm=I=-30.0:"
|
|
||||||
"measured_I={input_i}:"
|
|
||||||
"measured_LRA={input_lra}:"
|
|
||||||
"measured_tp={input_tp}:measured_thresh={input_thresh}:"
|
|
||||||
"print_format=json"
|
|
||||||
" "
|
|
||||||
"-c:a libopus"
|
|
||||||
" "
|
|
||||||
"-b:a 320k".format(
|
|
||||||
input_i=loudness["input_i"],
|
|
||||||
input_lra=loudness["input_lra"],
|
|
||||||
input_tp=loudness["input_tp"],
|
|
||||||
input_thresh=loudness["input_thresh"],
|
|
||||||
)
|
|
||||||
},
|
|
||||||
global_options=("-y", "-v error"),
|
global_options=("-y", "-v error"),
|
||||||
)
|
)
|
||||||
# print(ff.cmd)
|
print(ff.cmd)
|
||||||
ff.run()
|
ff.run()
|
||||||
|
|
||||||
|
|
||||||
@ -179,12 +184,15 @@ def main(inputfile: str):
|
|||||||
# print(os.path.basename(inputfile))
|
# print(os.path.basename(inputfile))
|
||||||
# print(outputfile)
|
# print(outputfile)
|
||||||
|
|
||||||
remove_picture(inputfile=inputfile)
|
# remove_picture(inputfile=inputfile)
|
||||||
loudness = loudness_info(inputfile=inputfile)
|
loudness = loudness_info(inputfile=inputfile)
|
||||||
convert(inputfile=inputfile, outputfile=outputfile, loudness=loudness)
|
convert(inputfile=inputfile, outputfile=outputfile, loudness=loudness)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# start time of program
|
||||||
|
starttime = time.time()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="")
|
parser = argparse.ArgumentParser(description="")
|
||||||
|
|
||||||
# Input directory
|
# Input directory
|
||||||
@ -251,4 +259,4 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# write this run's time into file
|
# write this run's time into file
|
||||||
with open(timefile, "w") as file:
|
with open(timefile, "w") as file:
|
||||||
file.write(str(time.time()))
|
file.write(str(starttime))
|
||||||
|
Loading…
Reference in New Issue
Block a user