awacke1 commited on
Commit
f9840f5
1 Parent(s): 1088040

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from moviepy.editor import VideoFileClip, CompositeVideoClip, TextClip, vfx
3
+
4
+ def edit_video(video_path, text, start_time, duration):
5
+ # Load the video
6
+ video = VideoFileClip(video_path)
7
+
8
+ # Create text clip
9
+ txt_clip = TextClip(text, fontsize=70, color='white', font='Amiri-Bold')
10
+ txt_clip = txt_clip.set_position(('center', 'bottom')).set_duration(duration)
11
+
12
+ # Set the text clip to start at the specified time
13
+ txt_clip = txt_clip.set_start(start_time)
14
+
15
+ # Composite the video with text
16
+ final_clip = CompositeVideoClip([video, txt_clip])
17
+
18
+ # Apply a simple effect (e.g., speed up)
19
+ final_clip = final_clip.fx(vfx.speedx, 1.5)
20
+
21
+ # Write the result
22
+ final_clip.write_videofile("output.mp4", fps=video.fps)
23
+
24
+ return "output.mp4"
25
+
26
+ # Interface setup
27
+ iface = gr.Interface(
28
+ fn=edit_video,
29
+ inputs=[
30
+ gr.Video(label="Input Video"),
31
+ gr.Textbox(label="Text to Overlay"),
32
+ gr.Number(label="Start Time (seconds)"),
33
+ gr.Number(label="Duration of Text (seconds)")
34
+ ],
35
+ outputs=gr.Video(label="Edited Video"),
36
+ title="Simple Video Editor",
37
+ description="Add text to your video with a simple effect!"
38
+ )
39
+
40
+ # Launch the interface
41
+ iface.launch()