Could be faster by not saving PNG frames
Is your feature request related to a problem? Please describe. The program could be faster by outputting the frames directly to ffmpeg, via a pipe, instead of saving PNG files and then reading them again. In my machine, doing this got me a 4x speedup for a 640x800 video.
I already modified video_to_slowmo.py
to achieve this. Would you like me to open a pull request? I can do that maybe tomorrow.
Describe the solution you'd like
Use ffmpeg-python in the video_to_slowmo.py
script to save the output video in one go, instead of saving PNG images. Specifically, something like
# Prepare output stream
outputProcess = (
ffmpeg
.input('pipe:', format='rawvideo', pix_fmt='rgb24', r=args.fps, s='{}x{}'.format(width, height))
.output(args.output, pix_fmt='yuv420p', r=args.fps)
.run_async(pipe_stdin=True)
)
...
# Save reference/intermediate frames
outputProcess.stdin.write((TP(frame0[batchIndex].detach())).resize(videoFrames.origDim, Image.BILINEAR).tobytes())
I have ffmpeg
in my PATH, so by default that's what's used, but it can probably be modified to use the --ffmpeg_dir
argument that video_to_slowmo already uses.
Describe alternatives you've considered N/A
Additional context N/A