Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.1k stars 1.51k forks source link

Concatenating VideoClip and ImageClip of different resolutions #2016

Closed stnbu closed 4 months ago

stnbu commented 11 months ago

I've tried many things to do this and the output consistently is ...garbled. I can elaborate on the following code and how I got there. The code:

from moviepy.editor import *
from PIL import Image
import numpy as np
video_clip = VideoFileClip("video.mov").subclip(0, 5).set_fps(24)
img = Image.open("image.jpg")
img.thumbnail(video_clip.size, Image.LANCZOS)
image_clip = ImageClip(np.array(img)).set_duration(5).set_fps(24)
result = concatenate_videoclips([video_clip, image_clip])
result.write_videofile("output.mp4", codec='libx264', fps=24)

I posted the output here.

Also know/tried:

I appreciate any help. This would suit all my simple "slideshow" needs.

stnbu commented 11 months ago

And a link to the script I'm working on if it's of interest.

Also, the goal is to have the image clip scaled maximally inside the target/result video's size, whatever it is. I feel like there is probably an easier way I haven't found it yet.

keikoro commented 4 months ago

Closing this as duplicate of #2072, which seems to be the only ticket referencing the library's actual release notes.