import gradio as gr from moviepy.editor import VideoFileClip import tempfile import os def remove_audio(video_file): """ Remove audio from uploaded video file. """ if video_file is None: return None # Create temporary output file temp_dir = tempfile.mkdtemp() output_path = os.path.join(temp_dir, "output_no_audio.mp4") try: # Load and process video video = VideoFileClip(video_file) video_without_audio = video.without_audio() # Write output video_without_audio.write_videofile( output_path, codec='libx264', audio=False, verbose=False, logger=None ) # Clean up video.close() video_without_audio.close() return output_path except Exception as e: return None # Custom CSS for aesthetic styling custom_css = """ .gradio-container { font-family: 'Inter', sans-serif !important; } .main-title { text-align: center; margin-bottom: 0.5em; } .subtitle { text-align: center; color: #6b7280; margin-bottom: 2em; } """ # Create the Gradio interface with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo: gr.Markdown( """ # 🔇 Video Audio Remover ### Remove audio from any video file instantly """, elem_classes=["main-title"] ) gr.Markdown( """ Upload your video, click process, and download the silent version. """, elem_classes=["subtitle"] ) with gr.Row(): with gr.Column(): input_video = gr.Video( label="📤 Upload Video", include_audio=True ) process_btn = gr.Button( "🚀 Remove Audio", variant="primary", size="lg" ) with gr.Column(): output_video = gr.Video( label="📥 Download Processed Video", include_audio=False ) gr.Markdown( """ --- **Supported formats:** MP4, AVI, MOV, MKV, WebM **Note:** Large files may take a moment to process """ ) # Connect the button to the function process_btn.click( fn=remove_audio, inputs=input_video, outputs=output_video ) # Launch the app if __name__ == "__main__": demo.launch()