From b8f5cbe0a73d85720e8a694493ef6e1955f8af79 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sun, 17 Sep 2023 00:24:53 -0400 Subject: [PATCH] Add all h264, h265 encoders --- auto_editor/lang/palet.py | 13 ++-- auto_editor/utils/container.py | 117 +++++++++++++++++++-------------- 2 files changed, 74 insertions(+), 56 deletions(-) diff --git a/auto_editor/lang/palet.py b/auto_editor/lang/palet.py index e409fc3d2..a4f90b90d 100644 --- a/auto_editor/lang/palet.py +++ b/auto_editor/lang/palet.py @@ -492,7 +492,8 @@ def check_args( for i, val in enumerate(values): check = cont[-1] if i >= len(cont) else cont[i] if not check_contract(check, val): - raise MyError(f"{o} expected a {print_str(check)}, got {print_str(val)}") + exp = f"{check}" if callable(check) else print_str(check) + raise MyError(f"{o} expected a {exp}, got {print_str(val)}") is_cont = Contract("contract?", is_contract) @@ -923,7 +924,7 @@ def syn_define(env: Env, node: list) -> None: terms = node[2][1] body = node[2][2:] - parms: list[str] = [] + parms = [] for item in terms: if type(item) is not Sym: raise MyError(f"{node[0]}: must be an identifier") @@ -938,7 +939,6 @@ def syn_define(env: Env, node: list) -> None: env[n] = my_eval(env, node[-1]) - def syn_definec(env: Env, node: list) -> None: if len(node) < 3: raise MyError(f"{node[0]}: too few terms") @@ -1554,7 +1554,8 @@ def my_eval(env: Env, node: object) -> Any: def interpret(env: Env, parser: Parser) -> list: result = [] while parser.current_token.type != EOF: - if type(parsed := my_eval(env, parser.expr())) is Keyword: - raise MyError(f"Keyword misused in expression. `{parsed}`") - result.append(parsed) + result.append(my_eval(env, parser.expr())) + + if type(result[-1]) is Keyword: + raise MyError(f"Keyword misused in expression. `{result[-1]}`") return result diff --git a/auto_editor/utils/container.py b/auto_editor/utils/container.py index 9e9e3520a..9b503291e 100644 --- a/auto_editor/utils/container.py +++ b/auto_editor/utils/container.py @@ -41,25 +41,40 @@ class Container: samplerate: list[int] | None = None # Any samplerate is allowed -# Define aliases +h264_en = [ + "h264", + "libx264", + "libx264rgb", + "libopenh264", + "h264_videotoolbox", + "h264_amf", + "h264_nvenc", + "h264_qsv", +] +hevc_en = ["hevc", "libx265", "hevc_videotoolbox", "hevc_amf", "hevc_nvenc", "hevc_qsv"] +av1_en = ["av1", "libaom-av1", "av1_nvenc", "av1_amf"] +prores_en = ["prores", "prores_videotoolbox", "prores_aw", "prores_ks"] +aac_en = ["aac", "aac_at", "libfdk_aac"] + + h265: DictContainer = { "name": "H.265 / High Efficiency Video Coding (HEVC) / MPEG-H Part 2", "allow_video": True, - "vcodecs": ["hevc", "mpeg4", "h264"], + "vcodecs": hevc_en + ["mpeg4"] + h264_en, } h264: DictContainer = { "name": "H.264 / Advanced Video Coding (AVC) / MPEG-4 Part 10", "allow_video": True, - "vcodecs": ["h264", "mpeg4", "hevc"], + "vcodecs": h264_en + ["mpeg4"] + hevc_en, } aac: DictContainer = { "name": "Advanced Audio Coding", "allow_audio": True, "max_audios": 1, - "acodecs": ["aac"], + "acodecs": aac_en, } ass: DictContainer = { - "name": "SubStation Alpha", + "name": "Advanced SubStation Alpha", "allow_subtitle": True, "scodecs": ["ass", "ssa"], "max_subtitles": 1, @@ -71,10 +86,9 @@ class Container: "allow_audio": True, "allow_subtitle": True, "allow_image": True, - "vcodecs": ["h264", "hevc", "vp9", "av1", "mpeg4", "mpeg2video", "mjpeg"], - "acodecs": ["aac", "mp3", "opus", "flac", "vorbis", "libvorbis", "ac3", "mp2"], + "vcodecs": h264_en + hevc_en + av1_en + ["vp9", "mpeg4", "mpeg2video", "mjpeg"], + "acodecs": aac_en + ["mp3", "opus", "flac", "vorbis", "libvorbis", "ac3", "mp2"], "vstrict": True, - # "disallow_v": ["prores", "apng", "gif", "msmpeg4v3", "flv1", "vp8", "dvvideo", "rawvideo"], } ogg: DictContainer = { "allow_video": True, @@ -85,28 +99,29 @@ class Container: "vstrict": True, } -mka_audio = [ - "libvorbis", - "vorbis", - "aac", - "mp3", - "opus", - "flac", - "ac3", - "mp2", - "wmav2", - "pcm_s16le", - "pcm_alaw", - "pcm_f32le", - "pcm_f64le", - "pcm_mulaw", - "pcm_s16be", - "pcm_s24be", - "pcm_s24le", - "pcm_s32be", - "pcm_s32le", - "pcm_u8", -] +mka_audio = ( + ["libvorbis", "vorbis"] + + aac_en + + [ + "mp3", + "opus", + "flac", + "ac3", + "mp2", + "wmav2", + "pcm_s16le", + "pcm_alaw", + "pcm_f32le", + "pcm_f64le", + "pcm_mulaw", + "pcm_s16be", + "pcm_s24be", + "pcm_s24le", + "pcm_s32be", + "pcm_s32le", + "pcm_u8", + ] +) containers: dict[str, DictContainer] = { # Aliases section @@ -187,7 +202,7 @@ class Container: "allow_video": True, "allow_audio": True, "allow_subtitle": True, - "vcodecs": ["vp9", "vp8", "av1", "libaom-av1"], + "vcodecs": ["vp9", "vp8"] + av1_en, "acodecs": ["opus", "vorbis", "libvorbis"], "scodecs": ["webvtt"], "vstrict": True, @@ -211,10 +226,10 @@ class Container: "name": "Audio Video Interleave", "allow_video": True, "allow_audio": True, - "vcodecs": ["mpeg4", "h264", "prores", "mjpeg", "mpeg2video", "rawvideo"], - "acodecs": [ - "mp3", - "aac", + "vcodecs": ["mpeg4"] + h264_en + ["prores", "mjpeg", "mpeg2video", "rawvideo"], + "acodecs": ["mp3"] + + aac_en + + [ "flac", "vorbis", "libvorbis", @@ -229,16 +244,18 @@ class Container: "pcm_s32le", "pcm_u8", ], - "disallow_v": ["hevc", "apng", "gif"], + "disallow_v": hevc_en + ["apng", "gif"], }, "wmv": { "name": "Windows Media Video", "allow_video": True, "allow_audio": True, - "vcodecs": ["msmpeg4v3", "h264", "mpeg4", "mpeg2video", "mjpeg", "rawvideo"], - "acodecs": [ - "wmav2", - "aac", + "vcodecs": ["msmpeg4v3"] + + h264_en + + ["mpeg4", "mpeg2video", "mjpeg", "rawvideo"], + "acodecs": ["wmav2"] + + aac_en + + [ "mp3", "flac", "vorbis", @@ -262,12 +279,12 @@ class Container: "allow_audio": True, "allow_subtitle": True, "allow_image": True, - "vcodecs": [ - "h264", - "hevc", + "vcodecs": h264_en + + hevc_en + + prores_en + + [ "vp9", "vp8", - "prores", "mpeg4", "mpeg2video", "msmpeg4v3", @@ -288,10 +305,10 @@ class Container: "allow_video": True, "allow_audio": True, "allow_subtitle": True, - "vcodecs": [ - "h264", - "hevc", - "prores", + "vcodecs": h264_en + + hevc_en + + prores_en + + [ "mpeg4", "mpeg2video", "msmpeg4v3", @@ -301,8 +318,8 @@ class Container: "dvvideo", "rawvideo", ], - "acodecs": [ - "aac", + "acodecs": aac_en + + [ "mp3", "vorbis", "libvorbis",