| 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() |