File size: 682 Bytes
a4c28ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import ffmpeg
import os

def convert_to_mp4(input_video):
    output_filename = "output.mp4"

    # Convert video to mp4 using FFmpeg
    stream = ffmpeg.input(input_video.name)
    stream = ffmpeg.output(stream, output_filename, vcodec='libx264', acodec='aac')
    ffmpeg.run(stream)

    return output_filename

# Gradio interface
iface = gr.Interface(
    fn=convert_to_mp4,
    inputs=gr.inputs.File(type="file", label="Upload Video"),
    outputs=gr.outputs.Video(label="Converted MP4 Video"),
    title="Video to MP4 Converter",
    description="A simple tool to convert videos to MP4 format using FFmpeg."
)

if __name__ == "__main__":
    iface.launch()