ChangeFps / app.py
kader1997's picture
Upload 3 files
e194969 verified
import gradio as gr
import subprocess
import uuid
import os
def process_video(video_path):
if video_path is None:
return None, "❌ الرجاء رفع فيديو"
output_file = f"output_{uuid.uuid4().hex}.mp4"
command = [
"ffmpeg",
"-i", video_path,
"-filter:v", "fps=30",
"-c:a", "copy",
"-vsync", "cfr",
output_file,
"-y"
]
try:
subprocess.run(command, check=True)
return output_file, "✅ تم تجهيز الفيديو بنجاح (30FPS ثابت)"
except subprocess.CalledProcessError:
return None, "❌ حدث خطأ أثناء المعالجة"
with gr.Blocks(title="FFmpeg 30FPS Converter") as demo:
gr.Markdown("## 🎬 تحويل الفيديو إلى 30FPS ثابت")
gr.Markdown("ارفع الفيديو وسيتم تجهيزه تلقائيًا")
video_input = gr.Video(label="📤 رفع الفيديو")
btn = gr.Button("⚙️ تجهيز الفيديو")
output_file = gr.File(label="📥 تحميل الفيديو")
status = gr.Textbox(label="الحالة", interactive=False)
btn.click(process_video, inputs=video_input, outputs=[output_file, status])
demo.launch()