Python synthesizes multiple pictures into one video

Reference python + opencv to save the picture as video – 2016 update,
code example is:

def imgs2video(imgs_dir, save_name):
    fps = 24
    fourcc = cv2.VideoWriter_fourcc(*'MJPG')
    video_writer = cv2.VideoWriter(save_name, fourcc, fps, (1920, 1080))
    # no glob, need number-index increasing
    imgs = glob.glob(os.path.join(imgs_dir, '*.png'))

    for i in range(len(imgs)):
        imgname = os.path.join(imgs_dir, 'core-{:02d}.png'.format(i))
        frame = cv2.imread(imgname)
        video_writer.write(frame)

    video_writer.release()

Reference python opencv VideoWriter: opencv:frame size mismatched video size,

    1. Error
"mMovieWriter.status: 3. Error: Cannot Save"

Because I already have a file with the same name, I can’t overwrite it, so just delete it and convert it.

      1. Warning:
OpenCV: Frame size does not match video size.
      1. warning:
WARNING: -finishWriting should not be called on the main thread.

Read More: