Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,14 +17,14 @@ def merge_videos(video1_path, video2_path):
|
|
| 17 |
desired_height = 1280
|
| 18 |
desired_width = 720
|
| 19 |
|
| 20 |
-
# Comando ffmpeg ajustado para
|
| 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[v0];'
|
| 25 |
f'[1:v]scale={desired_width}:{desired_height}:force_original_aspect_ratio=decrease,pad={desired_width}:{desired_height}:(ow-iw)/2:(oh-ih)/2[v1];'
|
| 26 |
f'[v0][v1]vstack=inputs=2[v]" '
|
| 27 |
-
f'-map "[v]" -c:v
|
| 28 |
)
|
| 29 |
|
| 30 |
subprocess.run(ffmpeg_cmd, shell=True, check=True)
|
|
@@ -32,7 +32,6 @@ def merge_videos(video1_path, video2_path):
|
|
| 32 |
return output_filename
|
| 33 |
|
| 34 |
def gradio_interface(video1, video2):
|
| 35 |
-
# Os vídeos já são passados como caminhos de arquivo temporário, então não precisamos abrir e salvar
|
| 36 |
output_video = merge_videos(video1, video2)
|
| 37 |
return output_video
|
| 38 |
|
|
|
|
| 17 |
desired_height = 1280
|
| 18 |
desired_width = 720
|
| 19 |
|
| 20 |
+
# Comando ffmpeg ajustado para usar h264_nvenc para aceleração por hardware
|
| 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[v0];'
|
| 25 |
f'[1:v]scale={desired_width}:{desired_height}:force_original_aspect_ratio=decrease,pad={desired_width}:{desired_height}:(ow-iw)/2:(oh-ih)/2[v1];'
|
| 26 |
f'[v0][v1]vstack=inputs=2[v]" '
|
| 27 |
+
f'-map "[v]" -c:v h264_nvenc -preset fast {output_filename}'
|
| 28 |
)
|
| 29 |
|
| 30 |
subprocess.run(ffmpeg_cmd, shell=True, check=True)
|
|
|
|
| 32 |
return output_filename
|
| 33 |
|
| 34 |
def gradio_interface(video1, video2):
|
|
|
|
| 35 |
output_video = merge_videos(video1, video2)
|
| 36 |
return output_video
|
| 37 |
|