I'm running a complicated numerical simulation and would like to send frames calculated for a movie to ffmpeg on the fly, e.g., during the calculation. Storing all the data and processing later is impractical since the data would be too large. Is it possible to use the ffmpeg package to achieve this?
In pseudo-code, I want to do something like this:
from ffmpeg import FFmpeg
ffmpeg = (
FFmpeg()
.option("y")
.input("pipe:0")
.output("output.mp4")
)
ffmpeg.execute() # Is this necessary in this case?
for i in range(...):
# this would be a much more complicated simulation that would calculate a frame
frame = ... # a NxMx3 array of color values
ffmpeg.add_frame(frame)
ffmpeg.finalize() # might be necessary?
I'm running a complicated numerical simulation and would like to send frames calculated for a movie to ffmpeg on the fly, e.g., during the calculation. Storing all the data and processing later is impractical since the data would be too large. Is it possible to use the
ffmpeg
package to achieve this?In pseudo-code, I want to do something like this: