File size: 1,272 Bytes
e194969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
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()