-
-
Notifications
You must be signed in to change notification settings - Fork 16.9k
[Bugfix] Fix base64 JPEG video frames returning empty metadata #37301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,9 +80,22 @@ def load_base64( | |
| "image/jpeg", | ||
| ) | ||
|
|
||
| return np.stack( | ||
| [np.asarray(load_frame(frame_data)) for frame_data in data.split(",")] | ||
| ), {} | ||
| frames = np.stack( | ||
| [np.asarray(load_frame(frame_data)) | ||
| for frame_data in data.split(",")] | ||
| ) | ||
| total = int(frames.shape[0]) | ||
| fps = float(self.kwargs.get("fps", 1)) | ||
| duration = total / fps if fps > 0 else 0.0 | ||
| metadata = { | ||
| "total_num_frames": total, | ||
| "fps": fps, | ||
| "duration": duration, | ||
| "video_backend": "jpeg_sequence", | ||
| "frames_indices": list(range(total)), | ||
| "do_sample_frames": False, | ||
| } | ||
| return frames, metadata | ||
|
Comment on lines
+89
to
+97
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous implementation returned an empty dictionary for metadata, which caused a runtime error when |
||
|
|
||
| return self.load_bytes(base64.b64decode(data)) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a regression test at
tests/multimodal/media/test_video.py?