Skip to content

Commit dc26555

Browse files
committed
Video file limit
1 parent d188784 commit dc26555

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

superannotate/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def dump_output(output_dir, platform, classes, files_dict):
244244
save_desktop_format(output_dir, classes, files_dict)
245245

246246

247+
MAX_VIDEO_SIZE = 5 * 1024 * 1024 * 1024 # 5 GB limit
247248
MAX_IMAGE_SIZE = 100 * 1024 * 1024 # 100 MB limit
248249
MAX_IMAGE_RESOLUTION = {
249250
"Vector": 100_000_000,

superannotate/db/projects.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ def upload_video_to_project(
233233
:rtype: list of strs
234234
"""
235235
logger.info("Uploading from video %s.", str(video_path))
236+
file_size = Path(video_path).stat().st_size
237+
if file_size > common.MAX_VIDEO_SIZE:
238+
raise SAVideoSizeTooLarge(file_size)
236239
rotate_code = None
237240
try:
238241
meta_dict = ffmpeg.probe(str(video_path))
@@ -413,15 +416,23 @@ def upload_videos_from_folder_to_project(
413416

414417
filenames = []
415418
for path in filtered_paths:
416-
filenames += upload_video_to_project(
417-
project,
418-
path,
419-
target_fps=target_fps,
420-
start_time=start_time,
421-
end_time=end_time,
422-
annotation_status=annotation_status,
423-
image_quality_in_editor=image_quality_in_editor
424-
)
419+
try:
420+
filename = upload_video_to_project(
421+
project,
422+
path,
423+
target_fps=target_fps,
424+
start_time=start_time,
425+
end_time=end_time,
426+
annotation_status=annotation_status,
427+
image_quality_in_editor=image_quality_in_editor
428+
)
429+
except Exception as e:
430+
logger.warning(
431+
"Couldn't upload video %s. Exception: ", path, str(e)
432+
)
433+
pass
434+
else:
435+
filenames += filename
425436

426437
return filenames
427438

superannotate/exceptions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ def __init__(self, file_size, file_name=""):
2525
)
2626

2727

28+
class SAVideoSizeTooLarge(SABaseException):
29+
def __init__(self, file_size, file_name=""):
30+
super().__init__(
31+
0, "Video " + file_name + " size " + str(file_size // 1024**3) +
32+
" GB is larger than " + str(common.MAX_VIDEO_SIZE // 1024**3) +
33+
" GB limit."
34+
)
35+
36+
2837
class SAExistingProjectNameException(SABaseException):
2938
pass
3039

superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.5.4"
1+
__version__ = "2.5.5b1"

0 commit comments

Comments
 (0)