Spaces:
Sleeping
Sleeping
Create app.py
Browse files12345678910111213141516171819202122232425262728293031import osfrom uuid import uuid4import gradio as grfrom moviepy.editor import VideoFileClip, concatenate_videoclipsfrom tempfile import TemporaryDirectory
def concatenate(video_clip_paths, output_path, method="compose"): clips = [VideoFileClip(c) for c in video_clip_paths] if method == "reduce": min_height = min([c.h for c in clips]) min_width = min([c.w for c in clips]) clips = [c.resize(newsize=(min_width, min_height)) for c in clips] final_clip = concatenate_videoclips(clips) elif method == "compose": final_clip = concatenate_videoclips(clips, method="compose") final_clip.write_videofile(output_path)
def merge(dubbed_video, end_video): with TemporaryDirectory() as dir: outpath = os.path.join(dir, f"{uuid4()}.mp4") video_clip_paths = [dubbed_video, end_video] concatenate(video_clip_paths, outpath) return outpath
input_video_file = gr.Video(label="Upload video")end_video_file = gr.Video(label="End video", value="end.mp4")
interface = gr.Interface(merge, [input_video_file, end_video_file], gr.Video("Output Video"), title="Merge Videos")
if __name__=="__main__": interface.queue().launch()app.pyAdded+31