Update app.py
Browse files
app.py
CHANGED
@@ -27,16 +27,17 @@ def enhance_video(input_file):
|
|
27 |
# Kết hợp các bộ lọc thành chuỗi
|
28 |
filter_chain = ",".join(filters)
|
29 |
|
30 |
-
# Xây dựng lệnh ffmpeg
|
31 |
command = [
|
32 |
"ffmpeg",
|
33 |
-
"-
|
34 |
-
"-
|
35 |
-
"-
|
36 |
-
"-
|
37 |
-
"-
|
38 |
-
"-
|
39 |
-
|
|
|
40 |
]
|
41 |
|
42 |
try:
|
@@ -48,14 +49,14 @@ def enhance_video(input_file):
|
|
48 |
|
49 |
# Tạo giao diện Gradio
|
50 |
with gr.Blocks() as demo:
|
51 |
-
gr.Markdown("#
|
52 |
-
gr.Markdown("
|
53 |
|
54 |
with gr.Row():
|
55 |
-
input_video = gr.File(label="
|
56 |
-
output_video = gr.Video(label="Video
|
57 |
|
58 |
-
submit_button = gr.Button("
|
59 |
submit_button.click(enhance_video, inputs=input_video, outputs=output_video)
|
60 |
|
61 |
# Khởi chạy ứng dụng
|
|
|
27 |
# Kết hợp các bộ lọc thành chuỗi
|
28 |
filter_chain = ",".join(filters)
|
29 |
|
30 |
+
# Xây dựng lệnh ffmpeg với tùy chọn -y để ghi đè file đầu ra
|
31 |
command = [
|
32 |
"ffmpeg",
|
33 |
+
"-y", # Tự động ghi đè file đầu ra
|
34 |
+
"-i", input_path, # File đầu vào
|
35 |
+
"-vf", filter_chain, # Áp dụng các bộ lọc
|
36 |
+
"-c:v", "libx265", # Codec HEVC (hiệu quả hơn H.264)
|
37 |
+
"-crf", "23", # Chất lượng video (thấp hơn = tốt hơn)
|
38 |
+
"-preset", "medium", # Tốc độ mã hóa (medium là cân bằng)
|
39 |
+
"-c:a", "copy", # Sao chép âm thanh nguyên bản
|
40 |
+
output_path # File đầu ra
|
41 |
]
|
42 |
|
43 |
try:
|
|
|
49 |
|
50 |
# Tạo giao diện Gradio
|
51 |
with gr.Blocks() as demo:
|
52 |
+
gr.Markdown("# Video Enhancement with FFmpeg")
|
53 |
+
gr.Markdown("Upload a video and get an enhanced version with improved quality.")
|
54 |
|
55 |
with gr.Row():
|
56 |
+
input_video = gr.File(label="Upload Video")
|
57 |
+
output_video = gr.Video(label="Enhanced Video")
|
58 |
|
59 |
+
submit_button = gr.Button("Enhance Video")
|
60 |
submit_button.click(enhance_video, inputs=input_video, outputs=output_video)
|
61 |
|
62 |
# Khởi chạy ứng dụng
|