Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about adding an option to use ffmpeg for videowriting #1

Open
AiueoABC opened this issue Sep 3, 2021 · 0 comments
Open

How about adding an option to use ffmpeg for videowriting #1

AiueoABC opened this issue Sep 3, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@AiueoABC
Copy link
Owner

AiueoABC commented Sep 3, 2021

Maybe ffmpeg-python helps(Ref: kkroening/ffmpeg-python#246)
just import ffmpeg and add/replace videowriting with these;

def vidwrite(fn, images, framerate=60, vcodec='libx264'):
    if not isinstance(images, np.ndarray):
        images = np.asarray(images)
    n,height,width,channels = images.shape
    process = (
        ffmpeg
            .input('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(width, height))
            .output(fn, pix_fmt='yuv420p', vcodec=vcodec, r=framerate)
            .overwrite_output()
            .run_async(pipe_stdin=True)
    )
    for frame in images:
        process.stdin.write(
            frame
                .astype(np.uint8)
                .tobytes()
        )
    process.stdin.close()
    process.wait()
@AiueoABC AiueoABC added the enhancement New feature or request label Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant