eienmojiki commited on
Commit
e865705
·
verified ·
1 Parent(s): 18a302e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
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
- # Define input and output paths
16
- input_path = os.path.join(temp_dir, "input.mp4")
17
- output_path = os.path.join(temp_dir, "output.mp4")
18
 
19
- # Save uploaded video to temp directory
20
- shutil.copy(video_file, input_path)
 
 
 
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 = [