I'm trying to create a program that I can give it a source folder (that contains for example jpeg images) and a destination folder (that the mp4 will go to) I want to be able to set a specific delay between every image so for example, the first image would be shown for 1 second and the second for 4 seconds
I don't want to use FFmpeg I want to edit the image in the process so I'd rather have a for loop or something like that so I can edit every image
I have tried using FFmpeg and moviepy I couldn't figure out how to do it any ideas?
Another thing if someone knows how i can take an image that is not the right size and kinda duplictae it to the backround of the image make it bigger and blur it? So the image has its original size with a blurry backround that is its duplicate
If you want to do it manually, and assuming you have bunch of .jpeg
files and you know the duration of each file, then using opencv.VideoWriter()
, you can repeat the frames based one the frame rate and then write all frames into the output.
import cv2
# Each video has a frame per second which is number of frames in every second
frame_per_second = 15
files_and_duration = [
('file1.jpeg', 4),
('file2.jpeg', 1),
('file3.jpeg', 2)
]
w, h = None, None
for file, duration in files_and_duration:
frame = cv2.imread(file)
if w is None:
# Setting up the video writer
h, w, _ = frame.shape
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
writer = cv2.VideoWriter('output.mp4', fourcc, frame_per_second, (w, h))
# Repating the frame to fill the duration
for repeat in range(duration * frame_per_second):
writer.write(frame)
writer.release()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With