This commit is contained in:
Hannes
2026-06-01 15:56:34 +02:00
parent 4ad09533f7
commit 7114cb3c12
3 changed files with 39 additions and 0 deletions
+2
View File
@@ -1,4 +1,6 @@
output/
*.gif
*.mp4
# ---> Python
+37
View File
@@ -0,0 +1,37 @@
from PIL import Image
import imageio.v2 as imageio
import numpy as np
import os
import re
frame_folder = "./output"
output_mp4 = "output.mp4"
fps = 4
def frame_number(filename):
m = re.search(r"frame_(\d+)\.png", filename)
return int(m.group(1))
files = sorted(
[
f for f in os.listdir(frame_folder)
if f.startswith("frame_") and f.endswith(".png")
],
key=frame_number,
)
with imageio.get_writer(
output_mp4,
fps=fps,
codec="libx264",
pixelformat="yuv420p",
) as writer:
for f in files:
path = os.path.join(frame_folder, f)
img = Image.open(path).convert("RGB")
frame = np.asarray(img)
writer.append_data(frame)
print(f"Saved {output_mp4}")
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB