Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,13 +27,12 @@ def split_video_into_chunks(video_path, chunk_duration=6, output_dir="video_chun
|
|
| 27 |
start_time = i * chunk_duration
|
| 28 |
output_file = os.path.join(output_dir, f"chunk_{i+1}.mp4")
|
| 29 |
|
| 30 |
-
# FFmpeg command to extract the chunk
|
| 31 |
command = [
|
| 32 |
"ffmpeg", "-i", video_path,
|
| 33 |
"-ss", str(start_time),
|
| 34 |
"-t", str(chunk_duration),
|
| 35 |
-
"-c
|
| 36 |
-
"-c:a", "aac",
|
| 37 |
output_file
|
| 38 |
]
|
| 39 |
subprocess.run(command, check=True)
|
|
@@ -53,8 +52,11 @@ def process_video(video, chunk_duration):
|
|
| 53 |
return chunk_files
|
| 54 |
|
| 55 |
# Gradio Interface
|
| 56 |
-
def gradio_interface(video, chunk_duration):
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# Define Gradio app
|
| 60 |
iface = gr.Interface(
|
|
|
|
| 27 |
start_time = i * chunk_duration
|
| 28 |
output_file = os.path.join(output_dir, f"chunk_{i+1}.mp4")
|
| 29 |
|
| 30 |
+
# FFmpeg command to extract the chunk (using -c copy for speed)
|
| 31 |
command = [
|
| 32 |
"ffmpeg", "-i", video_path,
|
| 33 |
"-ss", str(start_time),
|
| 34 |
"-t", str(chunk_duration),
|
| 35 |
+
"-c", "copy", # Directly copy video and audio streams (no re-encoding)
|
|
|
|
| 36 |
output_file
|
| 37 |
]
|
| 38 |
subprocess.run(command, check=True)
|
|
|
|
| 52 |
return chunk_files
|
| 53 |
|
| 54 |
# Gradio Interface
|
| 55 |
+
def gradio_interface(video, chunk_duration, progress=gr.Progress()):
|
| 56 |
+
progress(0, desc="Starting...")
|
| 57 |
+
chunk_files = process_video(video, chunk_duration)
|
| 58 |
+
progress(1.0, desc="Done!")
|
| 59 |
+
return chunk_files
|
| 60 |
|
| 61 |
# Define Gradio app
|
| 62 |
iface = gr.Interface(
|