Support for all the codes

This commit is contained in:
Akshay
2023-09-26 08:12:18 +03:00
committed by GitHub
parent 56c511b5d8
commit 52949f2fd1
+7 -2
View File
@@ -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,