Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Could be faster by not saving PNG frames #97

Open
artur-ag opened this issue May 4, 2021 · 0 comments
Open

Could be faster by not saving PNG frames #97

artur-ag opened this issue May 4, 2021 · 0 comments

Comments

@artur-ag
Copy link

artur-ag commented May 4, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant