v1.0.2
- Automatically pick first audio track; can override with --track - Create a temp encode file when encoding lossy/FLAC - --noflac and --noaac parameters added to disable one, the other, or both encodes (but why would you do that?) New dependencies: ffmpeg
This commit is contained in:
parent
db3f48407b
commit
521d92e9c1
|
@ -6,6 +6,7 @@
|
|||
- eac3to (https://www.videohelp.com/software/eac3to)
|
||||
- flac (https://xiph.org/flac/index.html)
|
||||
- qaac (https://github.com/nu774/qaac)
|
||||
- ffmpeg (https://www.ffmpeg.org/download.html)
|
||||
|
||||
"""
|
||||
import argparse
|
||||
|
@ -14,10 +15,11 @@ import mimetypes
|
|||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
__author__ = "LightArrowsEXE"
|
||||
__license__ = 'MIT'
|
||||
__version__ = '1.0.1'
|
||||
__version__ = '1.0.2'
|
||||
|
||||
|
||||
ignored_formats = ["audio/opus", "audio/aac"]
|
||||
|
@ -38,17 +40,22 @@ def encode(f):
|
|||
if args.wav_only:
|
||||
if args.track:
|
||||
if args.core:
|
||||
subprocess.call(["eac3to", f, "-log=NUL", f"{args.track}:", f"{os.path.splitext(f)[0]}_Track0{args.track}.wav", "-core"])
|
||||
subprocess.run(["eac3to", f, "-log=NUL", f"{args.track}:", f"{os.path.splitext(f)[0]}_Track0{args.track}.wav", "-core"])
|
||||
else:
|
||||
subprocess.call(["eac3to", f, "-log=NUL", f"{args.track}:", f"{os.path.splitext(f)[0]}_Track0{args.track}.wav"])
|
||||
subprocess.run(["eac3to", f, "-log=NUL", f"{args.track}:", f"{os.path.splitext(f)[0]}_Track0{args.track}.wav"])
|
||||
else:
|
||||
if args.core:
|
||||
subprocess.call(["eac3to", f, "-log=NUL", f"{os.path.splitext(f)[0]}.wav", "-core"])
|
||||
subprocess.run(["eac3to", f, "-log=NUL", f"{os.path.splitext(f)[0]}.wav", "-core"])
|
||||
else:
|
||||
subprocess.call(["eac3to", f, "-log=NUL", f"{os.path.splitext(f)[0]}.wav"])
|
||||
subprocess.run(["eac3to", f, "-log=NUL", f"{os.path.splitext(f)[0]}.wav"])
|
||||
else:
|
||||
subprocess.call(["flac", f, "-8", "-o", f"{os.path.splitext(f)[0]}.flac"])
|
||||
subprocess.call(["qaac", f, "-V 127", "--no-delay"])
|
||||
temp = tempfile.mkstemp(prefix=f"{os.path.splitext(f)[0]}_")
|
||||
subprocess.run(["ffmpeg", "-i", f, "-loglevel", "panic", "-stats", f"{temp[1]}.wav"])
|
||||
if not args.noflac:
|
||||
subprocess.run(["flac", f"{temp[1]}.wav", "-8", "-o", f"{os.path.splitext(f)[0]}.flac"])
|
||||
if not args.noaac:
|
||||
subprocess.run(["qaac", f"{temp[1]}.wav", "-V 127", "--no-delay", "-o", f"{os.path.splitext(f)[0]}.m4a"])
|
||||
os.remove(f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -65,6 +72,12 @@ if __name__ == "__main__":
|
|||
parser.add_argument("-T", "--track",
|
||||
action="store", type=int, default=None,
|
||||
help="Track to trim using eac3to (default: %(default)s)")
|
||||
parser.add_argument("--noflac",
|
||||
action="store_true", default=False,
|
||||
help="Disable FLAC encoding (default: %(default)s)")
|
||||
parser.add_argument("--noaac",
|
||||
action="store_true", default=False,
|
||||
help="Disable AAC encoding (default: %(default)s)")
|
||||
parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue