File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -767,6 +767,8 @@ task_id = client.create_video_task(
767767##### Limitation
768768
769769- You can upload up to a size of 250 MB.
770+ - You can upload only videos with H.264 encoding.
771+ - You can upload only MP4 file format.
770772
771773#### Find Task
772774
Original file line number Diff line number Diff line change @@ -1252,6 +1252,10 @@ def create_video_task(
12521252 raise FastLabelInvalidException (
12531253 "Supported video size is under 250 MB." , 422
12541254 )
1255+ if not utils .is_video_supported_codec (file_path ):
1256+ raise FastLabelInvalidException (
1257+ "Supported video encoding for registration through the SDK is only H.264." , 422
1258+ )
12551259
12561260 file = utils .base64_encode (file_path )
12571261 payload = {"project" : project , "name" : name , "file" : file }
@@ -1316,6 +1320,10 @@ def create_video_classification_task(
13161320 raise FastLabelInvalidException (
13171321 "Supported video size is under 250 MB." , 422
13181322 )
1323+ if not utils .is_video_supported_codec (file_path ):
1324+ raise FastLabelInvalidException (
1325+ "Supported video encoding for registration through the SDK is only H.264." , 422
1326+ )
13191327
13201328 file = utils .base64_encode (file_path )
13211329 payload = {"project" : project , "name" : name , "file" : file }
Original file line number Diff line number Diff line change 222222# API can accept under 250 MB
223223SUPPORTED_OBJECT_SIZE = 250 * math .pow (1024 , 2 )
224224
225+ # Only 'avc1' and 'H264' are supported for video task creation.
226+ SUPPORTED_FOURCC = ["avc1" ]
227+
225228
226229SUPPORTED_INFERENCE_IMAGE_SIZE = 6 * math .pow (1024 , 2 )
227230
Original file line number Diff line number Diff line change 55
66import geojson
77import numpy as np
8+ import cv2
89
910from fastlabel import const
1011
@@ -18,6 +19,10 @@ def is_image_supported_ext(file_path: str) -> bool:
1819 return file_path .lower ().endswith ((".png" , ".jpg" , ".jpeg" ))
1920
2021
22+ def is_video_supported_codec (file_path : str ) -> bool :
23+ return get_video_fourcc (file_path ) in const .SUPPORTED_FOURCC
24+
25+
2126def is_video_supported_ext (file_path : str ) -> bool :
2227 return file_path .lower ().endswith (".mp4" )
2328
@@ -164,3 +169,11 @@ def is_clockwise(points: list) -> bool:
164169def get_json_length (value ) -> int :
165170 json_str = json .dumps (value )
166171 return len (json_str )
172+
173+
174+ def get_video_fourcc (video_path : str ) -> str :
175+ cap = cv2 .VideoCapture (video_path )
176+ fourcc_code = int (cap .get (cv2 .CAP_PROP_FOURCC ))
177+ fourcc_str = "" .join ([chr ((fourcc_code >> 8 * i ) & 0xFF ) for i in range (4 )])
178+ cap .release ()
179+ return fourcc_str
You can’t perform that action at this time.
0 commit comments