Spaces:
Running
on
T4
Running
on
T4
Commit
•
0b5347b
1
Parent(s):
f6d1363
Update app.py
Browse files
app.py
CHANGED
@@ -21,14 +21,22 @@ def merge_videos(video1_path, video2_path):
|
|
21 |
ffmpeg_cmd = (
|
22 |
f'ffmpeg -i "{video1_path}" -i "{video2_path}" '
|
23 |
f'-filter_complex '
|
24 |
-
f'"[0:v]scale={desired_width}:{desired_height}:force_original_aspect_ratio=decrease,pad={desired_width}:{desired_height}:(ow-iw)/2:(oh-ih)/2
|
25 |
-
f'
|
|
|
|
|
26 |
f'[v0][v1]vstack=inputs=2[v]" '
|
27 |
f'-map "[v]" -c:v h264_nvenc -preset fast {output_filename}'
|
28 |
)
|
29 |
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
return output_filename
|
33 |
|
34 |
def gradio_interface(video1, video2):
|
|
|
21 |
ffmpeg_cmd = (
|
22 |
f'ffmpeg -i "{video1_path}" -i "{video2_path}" '
|
23 |
f'-filter_complex '
|
24 |
+
f'"[0:v]scale={desired_width}:{desired_height}:force_original_aspect_ratio=decrease,pad={desired_width}:{desired_height}:(ow-iw)/2:(oh-ih)/2,'
|
25 |
+
f'fps=fps=30[v0];'
|
26 |
+
f'[1:v]scale={desired_width}:{desired_height}:force_original_aspect_ratio=decrease,pad={desired_width}:{desired_height}:(ow-iw)/2:(oh-ih)/2,'
|
27 |
+
f'fps=fps=30[v1];'
|
28 |
f'[v0][v1]vstack=inputs=2[v]" '
|
29 |
f'-map "[v]" -c:v h264_nvenc -preset fast {output_filename}'
|
30 |
)
|
31 |
|
32 |
+
try:
|
33 |
+
subprocess.run(ffmpeg_cmd, shell=True, check=True, capture_output=True)
|
34 |
+
except subprocess.CalledProcessError as e:
|
35 |
+
print(f"Erro ao executar o ffmpeg: {e.stderr.decode()}")
|
36 |
+
if "Cannot load libnvidia-encode.so.1" in e.stderr.decode():
|
37 |
+
print("NVENC não disponível. Verifique a instalação dos drivers da NVIDIA e se sua GPU suporta NVENC.")
|
38 |
+
raise
|
39 |
+
|
40 |
return output_filename
|
41 |
|
42 |
def gradio_interface(video1, video2):
|