From 52949f2fd1ce0c40211ef38453de0f075f1405f1 Mon Sep 17 00:00:00 2001 From: Akshay <59740725+Killua7362@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:12:18 +0300 Subject: [PATCH] Support for all the codes --- supervision/utils/video.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/supervision/utils/video.py b/supervision/utils/video.py index d9f2ed1e..3b4b6481 100644 --- a/supervision/utils/video.py +++ b/supervision/utils/video.py @@ -80,13 +80,18 @@ class VideoSink: ``` """ - def __init__(self, target_path: str, video_info: VideoInfo): + def __init__(self, target_path: str, video_info: VideoInfo, /, codec: str = 'mp4v'): self.target_path = target_path self.video_info = video_info - self.__fourcc = cv2.VideoWriter_fourcc(*"mp4v") + self.__codec = codec self.__writer = None def __enter__(self): + try: + self.__fourcc = cv2.VideoWriter_fourcc(*self.__codec) + except: + print(f"{self.__codec} does not exist. Defaulting to mp4v...") + self.__fourcc = cv2.VideoWriter_fourcc(*'mp4v') self.__writer = cv2.VideoWriter( self.target_path, self.__fourcc,