Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prores -> prores work #648

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions auto_editor/cmds/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,15 @@ def edit_negative_tests():
def yuv442p():
return run.main(["resources/test_yuv422p.mp4"], [])

def prores():
run.main(["resources/testsrc.mp4", "-c:v", "prores", "-o", "out.mkv"], [])
assert fileinfo("out.mkv").videos[0].pix_fmt == "yuv422p10le"

run.main(["out.mkv", "-c:v", "prores", "-o", "out2.mkv"], [])
assert fileinfo("out2.mkv").videos[0].pix_fmt == "yuv422p10le"

return "out.mkv", "out2.mkv"

# Issue 280
def SAR():
out = run.main(["resources/SAR-2by3.mp4"], [])
Expand Down Expand Up @@ -735,6 +744,7 @@ def palet_scripts():
premiere,
SAR,
yuv442p,
prores,
edit_negative_tests,
edit_positive_tests,
audio_norm_f,
Expand Down
36 changes: 4 additions & 32 deletions auto_editor/render/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,7 @@ class VideoFrame:
src: FileInfo


# From: github.com/PyAV-Org/PyAV/blob/main/av/video/frame.pyx
allowed_pix_fmt = {
"yuv420p",
"yuvj420p",
"yuv444p",
"yuvj444p",
"rgb48be",
"rgb48le",
"rgb64be",
"rgb64le",
"rgb24",
"bgr24",
"argb",
"rgba",
"abgr",
"bgra",
"gray",
"gray8",
"gray16be",
"gray16le",
"rgb8",
"bgr8",
"pal8",
}

allowed_pix_fmt = av.video.frame.supported_np_pix_fmts

def make_solid(width: int, height: int, pix_fmt: str, bg: str) -> av.VideoFrame:
hex_color = bg.lstrip("#").upper()
Expand Down Expand Up @@ -132,15 +108,14 @@ def render_av(

codec = av.Codec(args.video_codec, "w")

if args.video_codec == "gif":
if codec.id == 97: # gif
if codec.video_formats is not None and target_pix_fmt in (
f.name for f in codec.video_formats
):
target_pix_fmt = target_pix_fmt
else:
target_pix_fmt = "rgb8"

elif args.video_codec == "prores":
elif codec.id == 147: # prores
target_pix_fmt = "yuv422p10le"
else:
target_pix_fmt = (
Expand Down Expand Up @@ -336,10 +311,7 @@ def render_av(
frame = scale_graph.vpull()

if frame.format.name != target_pix_fmt:
if target_pix_fmt == "yuv422p10le": # workaround for prores
frame = frame.reformat(format="yuv444p16le")
else:
frame = frame.reformat(format=target_pix_fmt)
frame = frame.reformat(format=target_pix_fmt)
bar.tick(index)
elif index % 3 == 0:
bar.tick(index)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [{ name = "WyattBlue", email = "[email protected]" }]
requires-python = ">=3.10,<3.14"
dependencies = [
"numpy>=1.24,<3.0",
"pyav==14.*",
"pyav==14.2.0rc1",
]
keywords = [
"video", "audio", "media", "editor", "editing",
Expand Down
Loading