File tree Expand file tree Collapse file tree 4 files changed +73
-1
lines changed Expand file tree Collapse file tree 4 files changed +73
-1
lines changed Original file line number Diff line number Diff line change 11""" About information for videodb sdk"""
22
33
4- __version__ = "0.2.13 "
4+ __version__ = "0.2.14 "
55__title__ = "videodb"
66__author__ = "videodb"
77
Original file line number Diff line number Diff line change 1616 SubtitleBorderStyle ,
1717 SubtitleStyle ,
1818 TextStyle ,
19+ TranscodeMode ,
20+ ResizeMode ,
21+ VideoConfig ,
22+ AudioConfig ,
1923)
2024from videodb .client import Connection
2125from videodb .exceptions import (
4347 "TextStyle" ,
4448 "SceneExtractionType" ,
4549 "Segmenter" ,
50+ "TranscodeMode" ,
51+ "ResizeMode" ,
52+ "VideoConfig" ,
53+ "AudioConfig" ,
4654]
4755
4856
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ class ApiPath:
7676 web = "web"
7777 translate = "translate"
7878 dub = "dub"
79+ transcode = "transcode"
7980
8081
8182class Status :
@@ -164,3 +165,28 @@ class TextStyle:
164165 tabsize : int = 4
165166 x : Union [str , int ] = "(main_w-text_w)/2"
166167 y : Union [str , int ] = "(main_h-text_h)/2"
168+
169+
170+ class TranscodeMode :
171+ lightning = "lightning"
172+ economy = "economy"
173+
174+
175+ class ResizeMode :
176+ crop = "crop"
177+ fit = "fit"
178+ pad = "pad"
179+
180+
181+ @dataclass
182+ class VideoConfig :
183+ resolution : int = 720
184+ quality : int = 23
185+ framerate : int = None
186+ aspect_ratio : str = None
187+ resize_mode : str = ResizeMode .crop
188+
189+
190+ @dataclass
191+ class AudioConfig :
192+ mute : bool = False
Original file line number Diff line number Diff line change 88from videodb .__about__ import __version__
99from videodb ._constants import (
1010 ApiPath ,
11+ TranscodeMode ,
12+ VideoConfig ,
13+ AudioConfig ,
1114)
1215
1316from videodb .collection import Collection
@@ -188,6 +191,41 @@ def youtube_search(
188191 )
189192 return search_data .get ("results" )
190193
194+ def transcode (
195+ self ,
196+ source : str ,
197+ callback_url : str ,
198+ mode : TranscodeMode = TranscodeMode .economy ,
199+ start_ts : int = None ,
200+ end_ts : int = None ,
201+ video_config : VideoConfig = VideoConfig (),
202+ audio_config : AudioConfig = AudioConfig (),
203+ ) -> None :
204+ """Transcode the video
205+
206+ :param str source: URL of the video to transcode, preferably a downloadable URL
207+ :param str callback_url: URL to receive the callback
208+ :param TranscodeMode mode: Mode of the transcoding
209+ :param int start_ts: Start timestamp of the video to transcode (optional)
210+ :param int end_ts: End timestamp of the video to transcode (optional)
211+ :param VideoConfig video_config: Video configuration (optional)
212+ :param AudioConfig audio_config: Audio configuration (optional)
213+ :return: None
214+ :rtype: None
215+ """
216+ self .post (
217+ path = f"{ ApiPath .transcode } " ,
218+ data = {
219+ "source" : source ,
220+ "callback_url" : callback_url ,
221+ "mode" : mode ,
222+ "start_ts" : start_ts ,
223+ "end_ts" : end_ts ,
224+ "video_config" : video_config .__dict__ ,
225+ "audio_config" : audio_config .__dict__ ,
226+ },
227+ )
228+
191229 def upload (
192230 self ,
193231 file_path : str = None ,
You can’t perform that action at this time.
0 commit comments