#!/usr/bin/env python3 import glob, os, os.path, argparse parser = argparse.ArgumentParser() parser.add_argument('fileglob') args = parser.parse_args() # The mapping selects all audio, then deselects all English language parts, selecting Japanese positively is harder # Obviously this is only really useful for anime globglogabgalab = glob.glob(args.fileglob) for f in globglogabgalab: fns = f fss = f[:f.rfind(".")] fnse = fns.replace("[", r"\[").replace("]", r"\]").replace(" ", r"\ ") prefix = "vita/" if os.path.exists(f"{prefix}{fss}.mp4"): continue if fns[-3:]=="mkv": subpath = fnse substring = f',subtitles={subpath}' elif os.path.exists(fnse[:-3] + "srt"): subpath = fnse[:-3] + "srt" substring = f',subtitles={subpath}' else: substring = "" os.system(f"""ffmpeg \ -i "{fns}" \ -map v \ -map a -map -0:m:language:eng \ -vf "scale='-1':'min(ih,720)'{substring}" \ -crf 25 \ -vcodec libx264 -pix_fmt yuv420p \ -strict -2 \ -map_chapters -1 \ "{prefix}{fss}.mp4";""")