TDN-M commited on
Commit
77a112d
·
verified ·
1 Parent(s): 612f411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
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
- "-i", input_path, # File đầu vào
34
- "-vf", filter_chain, # Áp dụng các bộ lọc
35
- "-c:v", "libx265", # Codec HEVC (hiệu quả hơn H.264)
36
- "-crf", "23", # Chất lượng video (thấp hơn = tốt hơn)
37
- "-preset", "medium", # Tốc độ hóa (medium cân bằng)
38
- "-c:a", "copy", # Sao chép âm thanh nguyên bản
39
- output_path # File đầu ra
 
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("# Tăng chất lượng video")
52
- gr.Markdown("Tải lên video của bạn để cải thiện chất lượng hiển thị")
53
 
54
  with gr.Row():
55
- input_video = gr.File(label="Tải lên")
56
- output_video = gr.Video(label="Video đã qua xử lý")
57
 
58
- submit_button = gr.Button("Xử ")
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 độ 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