Skip to content

Commit 1f57a6b

Browse files
authored
Merge pull request #48 from video-db/ankit/add-timeline-v2
Ankit/add timeline v2
2 parents fca5f27 + 92dc137 commit 1f57a6b

File tree

5 files changed

+730
-1
lines changed

5 files changed

+730
-1
lines changed

videodb/__about__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
""" About information for videodb sdk"""
22

33

4-
__version__ = "0.2.14"
4+
5+
__version__ = "0.2.17"
56
__title__ = "videodb"
67
__author__ = "videodb"
78
__email__ = "contact@videodb.io"

videodb/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
SubtitleBorderStyle,
1717
SubtitleStyle,
1818
TextStyle,
19+
TranscodeMode,
20+
ResizeMode,
21+
VideoConfig,
22+
AudioConfig,
1923
)
2024
from videodb.client import Connection
2125
from videodb.exceptions import (
@@ -43,6 +47,10 @@
4347
"TextStyle",
4448
"SceneExtractionType",
4549
"Segmenter",
50+
"TranscodeMode",
51+
"ResizeMode",
52+
"VideoConfig",
53+
"AudioConfig",
4654
]
4755

4856

videodb/_constants.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class ApiPath:
8686
web = "web"
8787
translate = "translate"
8888
dub = "dub"
89+
transcode = "transcode"
8990

9091

9192
class Status:
@@ -174,3 +175,28 @@ class TextStyle:
174175
tabsize: int = 4
175176
x: Union[str, int] = "(main_w-text_w)/2"
176177
y: Union[str, int] = "(main_h-text_h)/2"
178+
179+
180+
class TranscodeMode:
181+
lightning = "lightning"
182+
economy = "economy"
183+
184+
185+
class ResizeMode:
186+
crop = "crop"
187+
fit = "fit"
188+
pad = "pad"
189+
190+
191+
@dataclass
192+
class VideoConfig:
193+
resolution: int = None
194+
quality: int = 23
195+
framerate: int = None
196+
aspect_ratio: str = None
197+
resize_mode: str = ResizeMode.crop
198+
199+
200+
@dataclass
201+
class AudioConfig:
202+
mute: bool = False

videodb/client.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from videodb.__about__ import __version__
99
from videodb._constants import (
1010
ApiPath,
11+
TranscodeMode,
12+
VideoConfig,
13+
AudioConfig,
1114
)
1215

1316
from videodb.collection import Collection
@@ -212,6 +215,45 @@ def youtube_search(
212215
)
213216
return search_data.get("results")
214217

218+
def transcode(
219+
self,
220+
source: str,
221+
callback_url: str,
222+
mode: TranscodeMode = TranscodeMode.economy,
223+
video_config: VideoConfig = VideoConfig(),
224+
audio_config: AudioConfig = AudioConfig(),
225+
) -> None:
226+
"""Transcode the video
227+
228+
:param str source: URL of the video to transcode, preferably a downloadable URL
229+
:param str callback_url: URL to receive the callback
230+
:param TranscodeMode mode: Mode of the transcoding
231+
:param VideoConfig video_config: Video configuration (optional)
232+
:param AudioConfig audio_config: Audio configuration (optional)
233+
:return: Transcode job ID
234+
:rtype: str
235+
"""
236+
job_data = self.post(
237+
path=f"{ApiPath.transcode}",
238+
data={
239+
"source": source,
240+
"callback_url": callback_url,
241+
"mode": mode,
242+
"video_config": video_config.__dict__,
243+
"audio_config": audio_config.__dict__,
244+
},
245+
)
246+
return job_data.get("job_id")
247+
248+
def get_transcode_details(self, job_id: str) -> dict:
249+
"""Get the details of a transcode job.
250+
251+
:param str job_id: ID of the transcode job
252+
:return: Details of the transcode job
253+
:rtype: dict
254+
"""
255+
return self.get(path=f"{ApiPath.transcode}/{job_id}")
256+
215257
def upload(
216258
self,
217259
file_path: str = None,

0 commit comments

Comments
 (0)