File size: 1,263 Bytes
f9840f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()