sundeveloper
commited on
Commit
•
369c1c7
1
Parent(s):
bb16687
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from moviepy.editor import VideoFileClip
|
3 |
+
|
4 |
+
def convert_gif_to_video(gif_path):
|
5 |
+
try:
|
6 |
+
# Load the GIF file as a video clip
|
7 |
+
clip = VideoFileClip(gif_path)
|
8 |
+
|
9 |
+
# Create a temporary file for saving the video file
|
10 |
+
video_path = "temp_video.mp4"
|
11 |
+
|
12 |
+
# Write the clip as a video file
|
13 |
+
clip.write_videofile(video_path, codec='libx264')
|
14 |
+
|
15 |
+
return video_path
|
16 |
+
except Exception as e:
|
17 |
+
raise gr.Error(f"An error occurred during conversion: {str(e)}")
|
18 |
+
|
19 |
+
# Create a Gradio interface
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=convert_gif_to_video,
|
22 |
+
inputs="file",
|
23 |
+
outputs="video",
|
24 |
+
title="GIF to Video Converter",
|
25 |
+
description="Convert GIF file to video file."
|
26 |
+
)
|
27 |
+
|
28 |
+
# Launch the interface
|
29 |
+
iface.launch()
|