scherroman / mugen

A command-line music video generator based on rhythm
MIT License
224 stars 39 forks source link

Feature request - Photos instead of video #26

Open kahwoo opened 3 years ago

kahwoo commented 3 years ago

It would be great if there was a way to import photos / images as well as videos and cut on the beat.

Is this something that has been concidered for the project?

scherroman commented 3 years ago

That's a great idea! Will think on this

kahwoo commented 2 years ago

I found a kinda messy way to do this using moviepy.

import os
import glob
from natsort import natsorted
from moviepy.editor import *
from pathlib import Path    

base_dir = os.path.realpath("D:\\images")
print(base_dir)

fps = 24

file_list = glob.glob('D:\\images\\*.*')  # Get all the files in the current directory (Only tested on jpgs and pngs)
file_list_sorted = natsorted(file_list,reverse=False)  # Sort the images

for image in file_list_sorted:
    print(image)
    filename = Path(image).name
    print(filename)
    clips = [ImageClip(image).set_duration(15)]
    concat_clip = concatenate_videoclips(clips, method="compose")
    outputname = 'D:\\images\\outputz\\' + filename + 'output_video.mp4'
    concat_clip.write_videofile(outputname, fps=fps)

There's probably a better way though.