File size: 786 Bytes
369c1c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from moviepy.editor import VideoFileClip

def convert_gif_to_video(gif_path):
    try:
        # Load the GIF file as a video clip
        clip = VideoFileClip(gif_path)
        
        # Create a temporary file for saving the video file
        video_path = "temp_video.mp4"
        
        # Write the clip as a video file
        clip.write_videofile(video_path, codec='libx264')
        
        return video_path
    except Exception as e:
        raise gr.Error(f"An error occurred during conversion: {str(e)}")

# Create a Gradio interface
iface = gr.Interface(
    fn=convert_gif_to_video,
    inputs="file",
    outputs="video",
    title="GIF to Video Converter",
    description="Convert GIF file to video file."
)

# Launch the interface
iface.launch()