VideoApi¶
- class VideoApi[source]¶
Bases:
supervisely.api.module_api.RemoveableBulkModuleApi
API for working with
Video
.VideoApi
object is immutable.- Parameters
- api : Api
API connection to the server.
- Usage example
import supervisely as sly import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() # Pass values into the API constructor (optional, not recommended) # api = sly.Api(server_address="https://app.supervise.ly", token="4r47N...xaTatb") video_id = 19371139 video_info = api.video.get_info_by_id(video_id) # api usage example
Methods
Add existing video from source Dataset to destination Dataset.
Checks existing hashes for Videos.
Downloads Video from Dataset to local path by ID.
Downloads Video with given ID between given start and end frames.
Downloads Video with given path in Supervisely between given start and end frames.
Download video with given ID in Supervisely between given start and end frames on the given path.
Checks if an entity with the given parent_id and name exists
Get project ID and dataset ID for given Video ID.
Generates a free name for an entity with the given parent_id and name.
Get Video information by ID in VideoInfo<VideoInfo> format.
Get Video information by ID.
Get information about an entity by its name from the Supervisely server.
Get Video information by ID in json format.
Get list of information about all videos for a given dataset ID.
Get list of all or limited quantity entities from the Supervisely server.
This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
get_list_generator
Get list of all
VideoInfo
field names.Get string name of
VideoInfo
NamedTuple.Send message to the Annotation Tool and return info if tracking was stopped
Send message to the Annotation Tool
Remove video from supervisely by id.
Remove videos from supervisely by IDs.
Upload custom data info in VideoInfo object.
Upload Video from given hash to Dataset.
Upload Videos from given hashes to Dataset.
Uploads video from given id to Dataset.
Uploads videos from given ids to Dataset.
Upload Video from given link to Dataset.
Upload Videos from given links to Dataset.
Uploads Video with given name from given local path to Dataset.
Uploads Videos with given names from given local paths to Dataset.
Update Video file metadata
Update Video files metadata
Get url of the video by dataset ID and video ID
Attributes
MAX_WAIT_ATTEMPTS
Maximum number of attempts that will be made to wait for a certain condition to be met.
WAIT_ATTEMPT_TIMEOUT_SEC
Number of seconds for intervals between attempts.
- InfoType¶
alias of
supervisely.api.module_api.VideoInfo
- add_existing(dataset_id, video_info, name)[source]¶
Add existing video from source Dataset to destination Dataset.
- Parameters
- Returns
Information about Video. See
info_sequence
- Return type
-
import supervisely as sly from supervisely.video.video import get_info os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id = 55846 video_id = 19371139 video_info = api.video.get_info_by_id(video_id) new_info = api.video.add_existing(dataset_id, video_info, "sea lion.mp4") print(new_info) # Output: # VideoInfo( # id=19371140, # name='sea lion.mp4' # hash='30/TQ1BcIOn1AI4RFgRO/6psRtr3lqNPmr4uQ=', # link=None, # team_id=435, # workspace_id=684, # project_id=17208, # dataset_id=55846, # path_original='/h5ung-public/videos/Z/d/HD/lfgipl...NXrg5vz.mp4', # frames_to_timecodes=[], # frames_count=245, # frame_width=1920, # frame_height=1080, # created_at='2023-02-07T19:35:01.808Z', # updated_at='2023-02-07T19:35:01.808Z', # tags=[], # file_meta={ # 'codecName': 'h264', # 'codecType': 'video', # 'duration': 10.218542, # 'formatName': 'mov,mp4,m4a,3gp,3g2,mj2', # 'framesCount': 245, # 'framesToTimecodes': [], # 'height': 1080, # 'index': 0, # 'mime': 'video/mp4', # 'rotation': 0, # 'size': '6795452', # 'startTime': 0, # 'streams': [], # 'width': 1920 # }, # custom_data={}, # processing_path='1/194' # )
- check_existing_hashes(hashes)[source]¶
Checks existing hashes for Videos.
- Parameters
- hashes : List[str]
List of hashes.
- Returns
List of existing hashes
- Return type
List[str]
- Usage example
Checkout detailed example here (you must be logged into your Supervisely account)
import supervisely as sly # Helpful method when your uploading was interrupted # You can check what videos has been successfully uploaded by their hashes and what not # And continue uploading the rest of the videos from that point os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() # Find project project = api.project.get_info_by_id(WORKSPACE_ID, PROJECT_ID) # Get paths of all videos in a directory videos_paths = sly.fs.list_files('videos_to_upload') #Calculate hashes for all videos paths hash_to_video = {} videos_hashes = [] for idx, item in enumerate(videos_paths): item_hash = sly.fs.get_file_hash(item) videos_hashes.append(item_hash) hash_to_video[item_hash] = item # Get hashes that are already on server remote_hashes = api.video.check_existing_hashes(videos_hashes) already_uploaded_videos = {hh: hash_to_video[hh] for hh in remote_hashes}
-
download_path(id, path, progress_cb=
None
)[source]¶ Downloads Video from Dataset to local path by ID.
- Parameters
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_info = api.video.get_info_by_id(770918) save_path = os.path.join("/home/admin/work/projects/videos/", video_info.name) api.video.download_path(770918, save_path)
-
download_range_by_id(id, frame_start, frame_end, is_stream=
True
)[source]¶ Downloads Video with given ID between given start and end frames.
- Parameters
- Returns
Response object
- Return type
Response
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 198835945 start_fr = 5 end_fr= 35 response = api.video.download_range_by_id(video_id, start_fr, end_fr)
-
download_range_by_path(path_original, frame_start, frame_end, is_stream=
False
)[source]¶ Downloads Video with given path in Supervisely between given start and end frames.
- Parameters
- Returns
Response object
- Return type
Response
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 198835945 start_fr = 5 end_fr= 35 video_info = api.video.get_info_by_id(video_id) path_sl = video_info.path_original response = api.video.download_range_by_path(path_sl, start_fr, end_fr)
- download_save_range(video_id, frame_start, frame_end, save_path)[source]¶
Download video with given ID in Supervisely between given start and end frames on the given path.
- Parameters
- Returns
Full path to saved video
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 198835945 start_fr = 5 end_fr= 35 video_info = api.video.get_info_by_id(video_id) name = video_info.name save_path = os.path.join('/home/admin/work/projects/videos', name) result = api.video.download_save_range(video_id, start_fr, end_fr, save_path) print(result) # Output: /home/admin/work/projects/videos/MOT16-03.mp4
- exists(parent_id, name)¶
Checks if an entity with the given parent_id and name exists
- Parameters
- Returns
Returns True if entity exists, and False if not
- Return type
- Usage example
import supervisely as sly # You can connect to API directly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) # Or you can use API from environment os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() name = "IMG_0315.jpeg" dataset_id = 55832 exists = api.image.exists(dataset_id, name) print(exists) # True
- get_destination_ids(id)[source]¶
Get project ID and dataset ID for given Video ID.
- Parameters
- id : int
Video ID in Supervisely.
- Returns
Project ID and dataset ID
- Return type
Tuple[int, int]
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 198702499 project_id, dataset_id = api.video.get_destination_ids(video_id) print(project_id, dataset_id) # Output: 17208 55846
- get_free_name(parent_id, name)¶
Generates a free name for an entity with the given parent_id and name. Adds an increasing suffix to original name until a unique name is found.
- Parameters
- Returns
Returns free name.
- Return type
- Usage example
import supervisely as sly # You can connect to API directly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) # Or you can use API from environment os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() name = "IMG_0315.jpeg" dataset_id = 55832 free_name = api.image.get_free_name(dataset_id, name) print(free_name) # IMG_0315_001.jpeg
-
get_info_by_id(id, raise_error=
False
)[source]¶ Get Video information by ID in VideoInfo<VideoInfo> format.
- Parameters
- Returns
Information about Video. See
info_sequence
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 198702499 video_info = api.video.get_info_by_id(video_id) print(video_info) # Output: # VideoInfo( # id=198702499, # name='Videos_dataset_animals_sea_lion.mp4' # hash='30/TQ1BcIOn1AI4RFgRO/6psRtr3lqNPmr4uQ=', # link=None, # team_id=435, # workspace_id=684, # project_id=17208, # dataset_id=55846, # path_original='/h5s-public/videos/Z/d/HD/lfgNXrg5vz.mp4', # frames_to_timecodes=[], # frames_count=245, # frame_width=1920, # frame_height=1080, # created_at='2023-02-07T19:35:01.808Z', # updated_at='2023-02-07T19:35:01.808Z', # tags=[], # file_meta={ # 'codecName': 'h264', # 'codecType': 'video', # 'duration': 10.218542, # 'formatName': 'mov,mp4,m4a,3gp,3g2,mj2', # 'framesCount': 245, # 'framesToTimecodes': [], # 'height': 1080, # 'index': 0, # 'mime': 'video/mp4', # 'rotation': 0, # 'size': '6795452', # 'startTime': 0, # 'streams': [], # 'width': 1920 # }, # custom_data={}, # processing_path='1/194' # )
-
get_info_by_id_batch(ids, progress_cb=
None
, force_metadata_for_links=False
)[source]¶ Get Video information by ID.
- Parameters
- Returns
List of information about Videos. See
info_sequence
.- Return type
List[VideoInfo]
- Usage example
os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_ids = [376728, 376729, 376730, 376731, 376732, 376733] video_infos = api.video.get_info_by_id_batch(video_ids)
- get_info_by_name(parent_id, name)¶
Get information about an entity by its name from the Supervisely server.
- Parameters
- Usage example
import supervisely as sly # You can connect to API directly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) # Or you can use API from environment os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id = 55832 name = "IMG_0315.jpeg" info = api.image.get_info_by_name(dataset_id, name) print(info) # Output: ImageInfo(id=19369643, name='IMG_0315.jpeg', ...)
-
get_json_info_by_id(id, raise_error=
False
)[source]¶ Get Video information by ID in json format.
- Parameters
- Returns
Information about Video. See
info_sequence
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 19371139 video_info = api.video.get_info_by_id(video_id) print(video_info) # Output: # { # 'createdAt': '2023-02-07T19:35:01.808Z', # 'customData': {}, # 'datasetId': 55846, # 'description': '', # 'fileMeta': { # 'codecName': 'h264', # 'codecType': 'video', # 'duration': 10.218542, # 'formatName': 'mov,mp4,m4a,3gp,3g2,mj2', # 'framesCount': 245, # 'framesToTimecodes': [], # 'height': 1080, # 'index': 0, # 'mime': 'video/mp4', # 'rotation': 0, # 'size': '6795452', # 'startTime': 0, # 'streams': [], # 'width': 1920 # }, # 'fullStorageUrl': 'https://app.supervise.ly/h..i35vz.mp4', # 'hash': '30/TQ1BcIOn1ykA2psRtr3lq3HF6NPmr4uQ=', # 'id': 19371139, # 'link': None, # 'meta': {'videoStreamIndex': 0}, # 'name': 'Videos_dataset_animals_sea_lion.mp4', # 'pathOriginal': '/h5u1vqgms4-public/videos/Z/d/HD/lfgiplg5vz.mp4', # 'processingPath': '1/194', # 'projectId': 17208, # 'tags': [ # { # 'createdAt': '2023-02-07T19:35:01.808Z', # 'entityId': 19371139, # 'frameRange': [244, 244], # 'id': 12241539, # 'labelerLogin': 'admin', # 'tagId': 377141, # 'updatedAt': '2023-02-07T19:35:01.808Z' # } # ], # 'teamId': 435, # 'updatedAt': '2023-02-07T19:35:01.808Z', # 'workspaceId': 684 # }
-
get_list(dataset_id, filters=
None
, raw_video_meta=False
)[source]¶ Get list of information about all videos for a given dataset ID.
- Parameters
- Returns
List of information about videos in given dataset.
- Return type
List[VideoInfo]
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id = 55846 video_infos = api.video.get_list(dataset_id) print(video_infos) # Output: [VideoInfo(...), VideoInfo(...)] filtered_video_infos = api.video.get_list(dataset_id, filters=[{'field': 'id', 'operator': '=', 'value': '19371139'}]) print(filtered_video_infos) # Output: [VideoInfo(id=19371139, ...)]
-
get_list_all_pages(method, data, progress_cb=
None
, convert_json_info_cb=None
, limit=None
, return_first_response=False
)¶ Get list of all or limited quantity entities from the Supervisely server.
- Parameters
- method : str
Request method name
- data : dict
Dictionary with request body info
- progress_cb : Progress, optional
Function for tracking download progress.
- convert_json_info_cb : Callable, optional
Function for convert json info
- limit : int, optional
Number of entity to retrieve
- return_first_response : bool, optional
Specify if return first response
-
get_list_all_pages_generator(method, data, progress_cb=
None
, convert_json_info_cb=None
, limit=None
, return_first_response=False
)¶ This generator function retrieves a list of all or a limited quantity of entities from the Supervisely server, yielding batches of entities as they are retrieved
- Parameters
- method : str
Request method name
- data : dict
Dictionary with request body info
- progress_cb : Progress, optional
Function for tracking download progress.
- convert_json_info_cb : Callable, optional
Function for convert json info
- limit : int, optional
Number of entity to retrieve
- return_first_response : bool, optional
Specify if return first response
- static info_tuple_name()[source]¶
Get string name of
VideoInfo
NamedTuple.- Returns
NamedTuple name.
- Return type
- notify_progress(track_id, video_id, frame_start, frame_end, current, total)[source]¶
Send message to the Annotation Tool and return info if tracking was stopped
- remove(video_id)[source]¶
Remove video from supervisely by id.
- Parameters
- video_id : int
Videos ID in Supervisely.
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 2389126 api.video.remove(video_id)
-
remove_batch(ids, progress_cb=
None
, batch_size=50
)[source]¶ Remove videos from supervisely by IDs.
- Parameters
- ids : List[int]
List of Videos IDs in Supervisely.
- progress_cb : tqdm or callable, optional
Function for tracking progress of removing.
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_ids = [2389126, 2389127] api.video.remove_batch(video_ids)
- update_custom_data(id, data)[source]¶
Upload custom data info in VideoInfo object.
- Parameters
- Returns
Return updating result
- Return type
- Usage example
import supervisely as sly from supervisely.video.video import get_info os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 19402023 api.video.update_custom_data(video_id, {"field": "value"}) video_info = api.video.get_info_by_id(video_id) print(video_info.custom_data) # Output: {'field': 'value'}
-
upload_hash(dataset_id, name, hash, stream_index=
None
)[source]¶ Upload Video from given hash to Dataset.
- Parameters
- Returns
Information about Video. See
info_sequence
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dst_dataset_id = 55846 src_video_id = 186580617 video_info = api.video.get_info_by_id(src_video_id) hash = video_info.hash # It is necessary to upload video with the same extention as in src dataset name = video_info.name new_video_info = api.video.upload_hash(dst_dataset_id, name, hash) print(new_video_info) # Output: # VideoInfo( # id=19371139, # name='Videos_dataset_animals_sea_lion.mp4' # hash='30/TQ1BcIOn1AI4RFgRO/6psRtr3lqNPmr4uQ=', # link=None, # team_id=435, # workspace_id=684, # project_id=17208, # dataset_id=55846, # path_original='/h5s-public/videos/Z/d/HD/lfgNXrg5vz.mp4', # frames_to_timecodes=[], # frames_count=245, # frame_width=1920, # frame_height=1080, # created_at='2023-02-07T19:35:01.808Z', # updated_at='2023-02-07T19:35:01.808Z', # tags=[], # file_meta={ # 'codecName': 'h264', # 'codecType': 'video', # 'duration': 10.218542, # 'formatName': 'mov,mp4,m4a,3gp,3g2,mj2', # 'framesCount': 245, # 'framesToTimecodes': [], # 'height': 1080, # 'index': 0, # 'mime': 'video/mp4', # 'rotation': 0, # 'size': '6795452', # 'startTime': 0, # 'streams': [], # 'width': 1920 # }, # custom_data={}, # processing_path='1/194' # )
-
upload_hashes(dataset_id, names, hashes, metas=
None
, progress_cb=None
)[source]¶ Upload Videos from given hashes to Dataset.
- Parameters
- Returns
List with information about Videos. See
info_sequence
- Return type
List[VideoInfo]
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() src_dataset_id = 466639 dst_dataset_id = 468620 hashes = [] names = [] metas = [] video_infos = api.video.get_list(src_dataset_id) # Create lists of hashes, videos names and meta information for each video for video_info in video_infos: hashes.append(video_info.hash) # It is necessary to upload videos with the same names(extentions) as in src dataset names.append(video_info.name) metas.append({video_info.name: video_info.frame_height}) progress = sly.Progress("Videos upload: ", len(hashes)) new_videos_info = api.video.upload_hashes(dst_dataset_id, names, hashes, metas, progress.iters_done_report) # Output: # {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Videos upload: ", "current": 0, "total": 2, "timestamp": "2021-03-24T10:18:57.111Z", "level": "info"} # {"message": "progress", "event_type": "EventType.PROGRESS", "subtask": "Videos upload: ", "current": 2, "total": 2, "timestamp": "2021-03-24T10:18:57.304Z", "level": "info"}
-
upload_id(dataset_id, name, id, meta=
None
)[source]¶ Uploads video from given id to Dataset.
- Parameters
- Returns
Information about Video. See
info_sequence
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() src_video_id = 186580617 dst_dataset_id = 468620 new_video_info = api.video.upload_id(dst_dataset_id, 'new_video_name.mp4', src_video_id)
-
upload_ids(dataset_id, names, ids, metas=
None
, progress_cb=None
, infos=None
)[source]¶ Uploads videos from given ids to Dataset.
- Parameters
- dataset_id : int
Destination dataset ID.
- names : List[str]
Videos names.
- ids : List[int]
Source videos IDs in Supervisely.
- metas : Optional[List[Dict]]
Videos metadata.
- progress_cb : Optional[Union[tqdm, Callable]]
Function for tracking download progress.
- infos : Optional[List[VideoInfo]]
Videos information.
- Returns
List with information about Videos. See
info_sequence
- Return type
List[VideoInfo]
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() src_dataset_id = 466639 dst_dataset_id = 468620 ids = [] names = [] metas = [] video_infos = api.video.get_list(src_dataset_id) # Create lists of ids, videos names and meta information for each video for video_info in video_infos: ids.append(video_info.id) # It is necessary to upload videos with the same names(extentions) as in src dataset names.append(video_info.name) metas.append({video_info.name: video_info.frame_height}) progress = sly.Progress("Videos upload: ", len(ids)) new_videos_info = api.video.upload_ids(dst_dataset_id, names, ids, metas, progress.iters_done_report)
-
upload_link(dataset_id, link, name=
None
, info=None
, hash=None
, meta=None
, skip_download=False
)[source]¶ Upload Video from given link to Dataset.
- Parameters
- Returns
List with information about Video. See
info_sequence
- Return type
List[VideoInfo]
import supervisely as sly from supervisely.video.video import get_info os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id = 55847 link = "https://video...040243048_main.mp4" name = "cars.mp4" info = api.video.upload_link(dataset_id, link, name) print(info) # Output: [ # VideoInfo( # id=19371139, # name='cars.mp4' # hash='30/TQ1BcIOn1AI4RFgRO/6psRtr3lqNPmr4uQ=', # link=None, # team_id=435, # workspace_id=684, # project_id=17208, # dataset_id=55847, # path_original='/h5ung-public/videos/Z/d/HD/lfgipl...NXrg5vz.mp4', # frames_to_timecodes=[], # frames_count=245, # frame_width=1920, # frame_height=1080, # created_at='2023-02-07T19:35:01.808Z', # updated_at='2023-02-07T19:35:01.808Z', # tags=[], # file_meta={ # 'codecName': 'h264', # 'codecType': 'video', # 'duration': 10.218542, # 'formatName': 'mov,mp4,m4a,3gp,3g2,mj2', # 'framesCount': 245, # 'framesToTimecodes': [], # 'height': 1080, # 'index': 0, # 'mime': 'video/mp4', # 'rotation': 0, # 'size': '6795452', # 'startTime': 0, # 'streams': [], # 'width': 1920 # }, # custom_data={}, # processing_path='1/194' # ) # ]
-
upload_links(dataset_id, links, names, infos=
None
, hashes=None
, metas=None
, skip_download=False
)[source]¶ Upload Videos from given links to Dataset.
- Parameters
- Returns
List with information about Videos. See
info_sequence
- Return type
List[VideoInfo]
- Usage example
import supervisely as sly from supervisely.video.video import get_info os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id = 55847 links = [ "https://videos...7477606_main.mp4", "https://videos...040243048_main.mp4", "https://videos...065451525_main.mp4" ] names = ["cars.mp4", "animals.mp4", "traffic.mp4"] video_infos = api.video.upload_links(dataset_id, links, names) print(video_infos) # Output: [ VideoInfo(id=19593405, ...), VideoInfo(id=19593406, ...), VideoInfo(id=19593407, ...) ]
-
upload_path(dataset_id, name, path, meta=
None
, item_progress=None
)[source]¶ Uploads Video with given name from given local path to Dataset.
- Parameters
- Returns
List with information about Videos. See
info_sequence
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id=55846 video_name = "7777.mp4" video_path = "/home/admin/Downloads/video/770918.mp4" video_infos = api.video.upload_path( dataset_id=dataset_id, name=video_name, path=video_path, )
-
upload_paths(dataset_id, names, paths, progress_cb=
None
, metas=None
, infos=None
, item_progress=None
)[source]¶ Uploads Videos with given names from given local paths to Dataset.
- Parameters
- Returns
List with information about Videos. See
info_sequence
- Return type
List[VideoInfo]
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id=55846 video_names = ["7777.mp4", "8888.mp4", "9999.mp4"] video_paths = ["/home/admin/Downloads/video/770918.mp4", "/home/admin/Downloads/video/770919.mp4", "/home/admin/Downloads/video/770920.mp4"] video_infos = api.video.upload_paths( dataset_id=dataset_id, names=video_names, paths=video_paths, )
- upsert_info(hash, info)[source]¶
Update Video file metadata
- Parameters
- Returns
Return updating result
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() video_id = 19388386 video_info = api.video.get_info_by_id(video_id) video_hash = video_info.hash res = api.video.upsert_info(video_hash, {"field": "value"}) print(res) # Output: {'success': True}
-
upsert_infos(hashes, infos, links=
None
)[source]¶ Update Video files metadata
- Parameters
- Returns
Return updating result
- Return type
- Usage example
import supervisely as sly os.environ['SERVER_ADDRESS'] = 'https://app.supervise.ly' os.environ['API_TOKEN'] = 'Your Supervisely API Token' api = sly.Api.from_env() dataset_id = 56443 video_ids = [19388386, 19388387, 19388388] video_infos = api.video.get_list( dataset_id=dataset_id, filters=[{'field': 'id', 'operator': 'in', 'value': video_ids}] ) video_hashes = [video_info.hash for video_info in video_infos] new_infos = [{"field1": "value1"}, {"field2": "value2"}, {"field3": "value3"}] res = api.video.upsert_infos(video_hashes, new_infos) print(res) # Output: {'success': True}