Yaroslav
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,9 @@ import cv2
|
|
2 |
import subprocess
|
3 |
import gradio as gr
|
4 |
|
5 |
-
def interpolate_video(
|
6 |
# Проверка пути к входному видео
|
7 |
-
cap = cv2.VideoCapture(
|
8 |
if not cap.isOpened():
|
9 |
return False, "Ошибка: не удалось открыть входное видео."
|
10 |
|
@@ -25,9 +25,9 @@ def interpolate_video(input_path, output_path):
|
|
25 |
# Команда для FFmpeg
|
26 |
command = [
|
27 |
'ffmpeg',
|
28 |
-
'-i',
|
29 |
'-filter:v', f'fps={new_fps}',
|
30 |
-
|
31 |
]
|
32 |
|
33 |
try:
|
@@ -38,21 +38,36 @@ def interpolate_video(input_path, output_path):
|
|
38 |
if result.returncode != 0:
|
39 |
return False, f"Ошибка FFmpeg: {result.stderr}"
|
40 |
|
41 |
-
return True, "Интерполяция завершена успешно!"
|
42 |
except Exception as e:
|
43 |
return False, f"Произошла ошибка: {str(e)}"
|
44 |
|
45 |
# Интерфейс Gradio
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
gr.
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
if __name__ == "__main__":
|
58 |
iface.launch()
|
|
|
2 |
import subprocess
|
3 |
import gradio as gr
|
4 |
|
5 |
+
def interpolate_video(input_file, output_file):
|
6 |
# Проверка пути к входному видео
|
7 |
+
cap = cv2.VideoCapture(input_file)
|
8 |
if not cap.isOpened():
|
9 |
return False, "Ошибка: не удалось открыть входное видео."
|
10 |
|
|
|
25 |
# Команда для FFmpeg
|
26 |
command = [
|
27 |
'ffmpeg',
|
28 |
+
'-i', input_file,
|
29 |
'-filter:v', f'fps={new_fps}',
|
30 |
+
output_file
|
31 |
]
|
32 |
|
33 |
try:
|
|
|
38 |
if result.returncode != 0:
|
39 |
return False, f"Ошибка FFmpeg: {result.stderr}"
|
40 |
|
41 |
+
return True, f"Интерполяция завершена успешно! Видео сохранено в {output_file}"
|
42 |
except Exception as e:
|
43 |
return False, f"Произошла ошибка: {str(e)}"
|
44 |
|
45 |
# Интерфейс Gradio
|
46 |
+
with gr.Blocks() as iface:
|
47 |
+
gr.Markdown("# Интерполяция видео до 60 FPS")
|
48 |
+
|
49 |
+
with gr.Row():
|
50 |
+
input_file = gr.File(label="Выберите входное видео")
|
51 |
+
output_file = gr.Textbox(label="Введите имя выходного файла (с .mp4)")
|
52 |
+
|
53 |
+
with gr.Row():
|
54 |
+
submit_button = gr.Button("Отправить")
|
55 |
+
clear_button = gr.Button("Очистить")
|
56 |
+
|
57 |
+
success_output = gr.Checkbox(label="Успешно")
|
58 |
+
message_output = gr.Textbox(label="Сообщение")
|
59 |
+
|
60 |
+
submit_button.click(
|
61 |
+
fn=interpolate_video,
|
62 |
+
inputs=[input_file, output_file],
|
63 |
+
outputs=[success_output, message_output]
|
64 |
+
)
|
65 |
+
|
66 |
+
clear_button.click(
|
67 |
+
fn=lambda: (False, ""),
|
68 |
+
inputs=[],
|
69 |
+
outputs=[success_output, message_output]
|
70 |
+
)
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
iface.launch()
|