Wednesday, February 2, 2022

 Python script I found on stack exchange that was hard to understand so I modified it to make it better.

This script adds the glob feature from ffmpeg *.jpg or *.png etc image sequences to windows.


import subprocess
import glob
import os

filenames = glob.glob("path/to/folder*.jpg")
duration = 0.05

with open("ffmpeg_input.txt", "wb") as outfile:
for filename in filenames:
outfile.write(f"file '{filename}'\n".encode())
outfile.write(f"duration {duration}\n".encode())

command_line = f"ffmpeg -y -r 60 -f concat -safe 0 -i ffmpeg_input.txt out.mp4"
print(command_line)

pipe = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE).stdout
output = pipe.read().decode()
pipe.close()

No comments:

Post a Comment