Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
-
import tempfile
|
| 5 |
-
import shutil
|
| 6 |
|
| 7 |
def compress_video(video_file):
|
| 8 |
if video_file is None:
|
| 9 |
return None, "No video uploaded"
|
| 10 |
|
| 11 |
-
# Create temporary directory
|
| 12 |
-
temp_dir = tempfile.mkdtemp()
|
| 13 |
-
|
| 14 |
try:
|
| 15 |
-
#
|
| 16 |
-
input_path =
|
| 17 |
-
output_path = os.path.join(temp_dir, "output.mp4")
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Execute ffmpeg command
|
| 23 |
command = [
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def compress_video(video_file):
|
| 6 |
if video_file is None:
|
| 7 |
return None, "No video uploaded"
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
try:
|
| 10 |
+
# Get the input file path
|
| 11 |
+
input_path = video_file
|
|
|
|
| 12 |
|
| 13 |
+
# Create output filename - in the same directory as input
|
| 14 |
+
base_dir = os.path.dirname(input_path)
|
| 15 |
+
filename = os.path.basename(input_path)
|
| 16 |
+
name, ext = os.path.splitext(filename)
|
| 17 |
+
output_path = os.path.join(base_dir, f"{name}_compressed{ext}")
|
| 18 |
|
| 19 |
# Execute ffmpeg command
|
| 20 |
command = [
|