Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,16 @@ ip_access_records = defaultdict(lambda: {
|
|
31 |
'last_access_time': None
|
32 |
})
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
'''
|
35 |
AUTHORIZED_API_KEY = os.getenv("HF_API_KEY")
|
36 |
|
|
|
31 |
'last_access_time': None
|
32 |
})
|
33 |
|
34 |
+
def truncate_video(video_file):
|
35 |
+
"""Truncates video to 30 seconds and saves it as a temporary file."""
|
36 |
+
clip = VideoFileClip(video_file)
|
37 |
+
truncated_clip = clip.subclip(0, min(30, clip.duration)) # Change 15 to 30 for 30 seconds
|
38 |
+
truncated_video_file = "temp_truncated_video.mp4"
|
39 |
+
truncated_clip.write_videofile(truncated_video_file, codec="libx264", audio_codec="aac")
|
40 |
+
clip.close()
|
41 |
+
truncated_clip.close()
|
42 |
+
return truncated_video_file
|
43 |
+
|
44 |
'''
|
45 |
AUTHORIZED_API_KEY = os.getenv("HF_API_KEY")
|
46 |
|