Skip to content

Commit

Permalink
Add all h264, h265 encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Sep 17, 2023
1 parent 00d036c commit b8f5cbe
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 56 deletions.
13 changes: 7 additions & 6 deletions auto_editor/lang/palet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
117 changes: 67 additions & 50 deletions auto_editor/utils/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -301,8 +318,8 @@ class Container:
"dvvideo",
"rawvideo",
],
"acodecs": [
"aac",
"acodecs": aac_en
+ [
"mp3",
"vorbis",
"libvorbis",
Expand Down

0 comments on commit b8f5cbe

Please sign in to comment.