Spaces:
Running
on
Zero
Running
on
Zero
Update
#4
by
deleted
- opened
app.py
CHANGED
|
@@ -43,8 +43,8 @@ def process_video(input_video_path, temp_dir="temp_dir"):
|
|
| 43 |
output_video_path = os.path.join(temp_dir, f"cropped_{input_file_name}")
|
| 44 |
|
| 45 |
# Crop the video to 10 seconds if necessary
|
| 46 |
-
if video.duration >
|
| 47 |
-
video = video.subclip(0,
|
| 48 |
|
| 49 |
# Write the cropped video to the output path
|
| 50 |
video.write_videofile(output_video_path, codec="libx264", audio_codec="aac")
|
|
@@ -57,7 +57,7 @@ def process_audio(file_path, temp_dir):
|
|
| 57 |
audio = AudioSegment.from_file(file_path)
|
| 58 |
|
| 59 |
# Check and cut the audio if longer than 4 seconds
|
| 60 |
-
max_duration =
|
| 61 |
if len(audio) > max_duration:
|
| 62 |
audio = audio[:max_duration]
|
| 63 |
|
|
|
|
| 43 |
output_video_path = os.path.join(temp_dir, f"cropped_{input_file_name}")
|
| 44 |
|
| 45 |
# Crop the video to 10 seconds if necessary
|
| 46 |
+
if video.duration > 60:
|
| 47 |
+
video = video.subclip(0, 60)
|
| 48 |
|
| 49 |
# Write the cropped video to the output path
|
| 50 |
video.write_videofile(output_video_path, codec="libx264", audio_codec="aac")
|
|
|
|
| 57 |
audio = AudioSegment.from_file(file_path)
|
| 58 |
|
| 59 |
# Check and cut the audio if longer than 4 seconds
|
| 60 |
+
max_duration = 6 * 10000 # 4 seconds in milliseconds
|
| 61 |
if len(audio) > max_duration:
|
| 62 |
audio = audio[:max_duration]
|
| 63 |
|