Video¶
-
supervisely_lib.video.video.
is_valid_ext
(ext: str) → bool[source]¶ Checks if given extension is supported.
- Parameters
ext (str) – Video file extension.
- Returns
bool
- Return type
bool
- Usage example
sly.video.is_valid_ext(".mp4") # True sly.video.is_valid_ext(".jpeg") # False
-
supervisely_lib.video.video.
has_valid_ext
(path: str) → bool[source]¶ Checks if Video file from given path has supported extension.
- Parameters
path (str) – Path to Video file.
- Returns
bool
- Return type
bool
- Usage example
video_path = "/home/admin/work//videos/Cars/ds0/video/6x.mp4" sly.video.has_valid_ext(video_path) # True
-
supervisely_lib.video.video.
validate_ext
(ext: str) → None[source]¶ Raises error if given extension is not supported.
- Parameters
ext (str) – Extension.
- Raises
UnsupportedVideoFormat
if given extension is not supported.- Returns
None
- Return type
NoneType
- Usage example
sly.video.validate_ext(".jpeg") # Unsupported video extension: .jpeg. # Only the following extensions are supported: ['.avi', '.mp4', '.3gp', '.flv', '.webm', '.wmv', '.mov', '.mkv'].
-
supervisely_lib.video.video.
get_image_size_and_frames_count
(path: str) → Tuple[Tuple[int, int], int][source]¶ Gets image size and number of frames from Video file.
- Parameters
path (str) – Path to Video file.
- Returns
Image size and number of Video frames.
- Return type
Tuple[Tuple[int, int], int]
- Usage example
video_path = "/home/admin/work/videos/Cars/ds0/video/6x.mp4" video_info = sly.video.get_image_size_and_frames_count(video_path) print(video_info) # Output: ((720, 1280), 152)
-
supervisely_lib.video.video.
validate_format
(path: str) → None[source]¶ Raise error if Video file from given path couldn’t be read or file extension is not supported.
- Parameters
path (str) – Path to Video file.
- Raises
VideoReadException
if Video file from given path couldn’t be read or file extension is not supported- Returns
None
- Return type
NoneType
- Usage example
video_path = "/home/paul/work/sphinx-docs/supervisely_py/docs/source/debug/video/Prius_360/ds0/video/video.jpg" sly.video.validate_format(video_path) # Unsupported video extension: .jpg. Only the following extensions are supported: ['.avi', '.mp4', '.3gp', '.flv', '.webm', '.wmv', '.mov', '.mkv'].
-
supervisely_lib.video.video.
count_video_streams
(all_streams: List[dict]) → int[source]¶ Count number of video streams in video.
- Parameters
all_streams (List[dict]) – List of Video file audio and video streams.
- Returns
Number of video streams in Video file
- Return type
int
-
supervisely_lib.video.video.
get_video_streams
(all_streams: List[dict]) → list[source]¶ Get list of video streams from given list of all streams.
- Parameters
all_streams (List[dict]) – List of Video file audio and video streams.
- Returns
List of video streams in Video file.
- Return type
list
-
supervisely_lib.video.video.
warn_video_requires_processing
(file_name: str, logger=None) → None[source]¶ Create logger if it was not there and displays message about the need for transcoding.
- Parameters
file_name (str) – Video file name.
logger (logger) – Logger object.
- Returns
None
- Return type
NoneType
-
supervisely_lib.video.video.
gen_video_stream_name
(file_name: str, stream_index: int) → str[source]¶ Create name to video stream from given filename and index of stream.
- Parameters
file_name (str) – Video file name.
stream_index (int) – Stream index.
- Returns
str
- Return type
str
- Usage example
stream_name = gen_video_stream_name('my_video.mp4', 2) print(stream_name) # Output: my_video_stream_2_CULxO.mp4