Spaces:
Sleeping
Sleeping
Synced repo using 'sync_with_huggingface' Github Action
Browse files- gradio_app.py +13 -2
gradio_app.py
CHANGED
@@ -125,7 +125,13 @@ def embed_video(
|
|
125 |
width = int(video_info['width'])
|
126 |
height = int(video_info['height'])
|
127 |
fps = float(video_info['r_frame_rate'].split('/')[0]) / float(video_info['r_frame_rate'].split('/')[1])
|
128 |
-
num_frames = int(video_info
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
# Open the input video
|
131 |
process1 = (
|
@@ -241,7 +247,12 @@ def embed_audio(
|
|
241 |
sample_rate = int(audio_info['sample_rate'])
|
242 |
sample_fmt = audio_info['sample_fmt']
|
243 |
channels = int(audio_info['channels'])
|
244 |
-
duration = float(audio_info
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
# CASE 1 Read audio all at once
|
247 |
|
|
|
125 |
width = int(video_info['width'])
|
126 |
height = int(video_info['height'])
|
127 |
fps = float(video_info['r_frame_rate'].split('/')[0]) / float(video_info['r_frame_rate'].split('/')[1])
|
128 |
+
num_frames = int(video_info.get('nb_read_frames', 0))
|
129 |
+
|
130 |
+
# fallback using tags
|
131 |
+
if not num_frames and 'DURATION' in video_info.get('tags', {}):
|
132 |
+
h, m, s = video_info['tags']['DURATION'].split(':')
|
133 |
+
duration = int(h) * 3600 + int(m) * 60 + float(s)
|
134 |
+
num_frames = int(duration * fps)
|
135 |
|
136 |
# Open the input video
|
137 |
process1 = (
|
|
|
247 |
sample_rate = int(audio_info['sample_rate'])
|
248 |
sample_fmt = audio_info['sample_fmt']
|
249 |
channels = int(audio_info['channels'])
|
250 |
+
duration = float(audio_info.get('duration', 0))
|
251 |
+
|
252 |
+
# fallback using tags
|
253 |
+
if not duration and 'DURATION' in audio_info.get('tags', {}):
|
254 |
+
h, m, s = audio_info['tags']['DURATION'].split(':')
|
255 |
+
duration = int(h) * 3600 + int(m) * 60 + float(s)
|
256 |
|
257 |
# CASE 1 Read audio all at once
|
258 |
|