Can you “stream” images to ffmpeg to construct a video, instead of saving them to disk?

前端 未结 2 659
离开以前
离开以前 2020-11-28 02:37

My work recently involves programmatically making videos. In python, the typical workflow looks something like this:

import subprocess, Image, ImageDraw

for         


        
2条回答
  •  佛祖请我去吃肉
    2020-11-28 03:01

    imageio supports this directly. It uses FFMPEG and the Video Acceleration API, making it very fast:

    import imageio
    
    writer = imageio.get_writer('video.avi', fps=fps)
    for i in range(frames_per_second * video_duration_seconds):
        img = createFrame(i)
        writer.append_data(img)
    writer.close()
    

提交回复
热议问题