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 1
1
""" About information for videodb sdk"""
2
2
3
3
4
- __version__ = "0.2.13 "
4
+ __version__ = "0.2.14 "
5
5
__title__ = "videodb"
6
6
__author__ = "videodb"
7
7
__email__ = "contact@videodb.io"
Original file line number Diff line number Diff line change 16
16
SubtitleBorderStyle ,
17
17
SubtitleStyle ,
18
18
TextStyle ,
19
+ TranscodeMode ,
20
+ ResizeMode ,
21
+ VideoConfig ,
22
+ AudioConfig ,
19
23
)
20
24
from videodb .client import Connection
21
25
from videodb .exceptions import (
43
47
"TextStyle" ,
44
48
"SceneExtractionType" ,
45
49
"Segmenter" ,
50
+ "TranscodeMode" ,
51
+ "ResizeMode" ,
52
+ "VideoConfig" ,
53
+ "AudioConfig" ,
46
54
]
47
55
48
56
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ class ApiPath:
76
76
web = "web"
77
77
translate = "translate"
78
78
dub = "dub"
79
+ transcode = "transcode"
79
80
80
81
81
82
class Status :
@@ -164,3 +165,28 @@ class TextStyle:
164
165
tabsize : int = 4
165
166
x : Union [str , int ] = "(main_w-text_w)/2"
166
167
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 8
8
from videodb .__about__ import __version__
9
9
from videodb ._constants import (
10
10
ApiPath ,
11
+ TranscodeMode ,
12
+ VideoConfig ,
13
+ AudioConfig ,
11
14
)
12
15
13
16
from videodb .collection import Collection
@@ -188,6 +191,41 @@ def youtube_search(
188
191
)
189
192
return search_data .get ("results" )
190
193
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
+
191
229
def upload (
192
230
self ,
193
231
file_path : str = None ,
You can’t perform that action at this time.
0 commit comments