awacke1's picture
Create app.py
f9840f5 verified
import gradio as gr
from moviepy.editor import VideoFileClip, CompositeVideoClip, TextClip, vfx
def edit_video(video_path, text, start_time, duration):
# Load the video
video = VideoFileClip(video_path)
# Create text clip
txt_clip = TextClip(text, fontsize=70, color='white', font='Amiri-Bold')
txt_clip = txt_clip.set_position(('center', 'bottom')).set_duration(duration)
# Set the text clip to start at the specified time
txt_clip = txt_clip.set_start(start_time)
# Composite the video with text
final_clip = CompositeVideoClip([video, txt_clip])
# Apply a simple effect (e.g., speed up)
final_clip = final_clip.fx(vfx.speedx, 1.5)
# Write the result
final_clip.write_videofile("output.mp4", fps=video.fps)
return "output.mp4"
# Interface setup
iface = gr.Interface(
fn=edit_video,
inputs=[
gr.Video(label="Input Video"),
gr.Textbox(label="Text to Overlay"),
gr.Number(label="Start Time (seconds)"),
gr.Number(label="Duration of Text (seconds)")
],
outputs=gr.Video(label="Edited Video"),
title="Simple Video Editor",
description="Add text to your video with a simple effect!"
)
# Launch the interface
iface.launch()