Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
import os
|
4 |
-
|
5 |
|
6 |
def get_file_size(file_path):
|
7 |
"""Get file size in a human-readable format"""
|
@@ -16,7 +16,7 @@ def get_file_size(file_path):
|
|
16 |
return f"{size_bytes:.2f} {unit}"
|
17 |
size_bytes /= 1024
|
18 |
|
19 |
-
|
20 |
def compress_video(video_file):
|
21 |
"""Compresses the uploaded video using FFmpeg and returns the output video path and file sizes."""
|
22 |
if video_file is None:
|
@@ -37,8 +37,8 @@ def compress_video(video_file):
|
|
37 |
# Execute ffmpeg command
|
38 |
command = [
|
39 |
"ffmpeg",
|
40 |
-
|
41 |
-
|
42 |
"-i", input_path,
|
43 |
"-vcodec", "libx264",
|
44 |
"-crf", "28",
|
@@ -118,4 +118,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
118 |
outputs=[input_size_display]
|
119 |
)
|
120 |
|
121 |
-
app.launch(
|
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
import os
|
4 |
+
import spaces
|
5 |
|
6 |
def get_file_size(file_path):
|
7 |
"""Get file size in a human-readable format"""
|
|
|
16 |
return f"{size_bytes:.2f} {unit}"
|
17 |
size_bytes /= 1024
|
18 |
|
19 |
+
@spaces.GPU(duration=120)
|
20 |
def compress_video(video_file):
|
21 |
"""Compresses the uploaded video using FFmpeg and returns the output video path and file sizes."""
|
22 |
if video_file is None:
|
|
|
37 |
# Execute ffmpeg command
|
38 |
command = [
|
39 |
"ffmpeg",
|
40 |
+
"-hwaccel",
|
41 |
+
"cuda",
|
42 |
"-i", input_path,
|
43 |
"-vcodec", "libx264",
|
44 |
"-crf", "28",
|
|
|
118 |
outputs=[input_size_display]
|
119 |
)
|
120 |
|
121 |
+
app.launch(debug=True, show_error=True)
|