Hi i want to make a video using images. Lets say i have an audio of 60 seconds and 6 images and i want my video to show images with equal durations i.e 10 second per image but i couldn't figure it out how to do it here is my code
import ffmpeg
input_audio = ffmpeg.input('./SARS/SARS.mp3')
input_still = ffmpeg.input('./SARS/*.jpg',t=20, pattern_type='glob', framerate=24)
(
ffmpeg
.concat(input_still, input_audio, v=1, a=1)
.filter('scale', size='hd1080', force_original_aspect_ratio='increase')
.output('./SARS/output.mp4')
.run(overwrite_output=True)
)
any help is appriciated
I'm sure you can achieve this with ffmpeg-python
but you can try one of the following:
Plain CLI
ffmpeg \
-y \
-i './SARS/SARS.mp3' \
-pattern_type glob -framerate 0.1 -i './SARS/*.jpg' \
-vf scale=size=hd1080:force_original_aspect_ratio=increase \
'./SARS/output.mp4'
You can run this in Python using subprocess.run(['ffmpeg','-y',...])
ffmpegio
Package
For a one-time pure transcoding need, ffmpegio
is actually an overkill and directly calling ffmpeg
via subprocess
is more than sufficient and faster, but if you do this kind of operations often you can give it a try.
pip install ffmpegio-core
from ffmpegio.ffmpegprocess import run
run({'inputs': [
('./SARS/SARS.mp3', None)
('./SARS/*.jpg', {'pattern_type':'glob','framerate': 0.1})],
'outputs': [
('./SARS/output.mp4', {'vf':'scale=size=hd1080:force_original_aspect_ratio=increase'})],
overwrite=True)
Essentially, it's like subprocess
counterpart but takes a dict of parameters.