From 552ed166a8f6681d9140adb7cf734a50e521da2b Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Tue, 29 Apr 2025 10:01:21 +0530 Subject: [PATCH 1/8] feat: add transcode --- videodb/__about__.py | 2 +- videodb/__init__.py | 8 ++++++++ videodb/_constants.py | 26 ++++++++++++++++++++++++++ videodb/client.py | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/videodb/__about__.py b/videodb/__about__.py index 972eedd..90f7f66 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -1,7 +1,7 @@ """ About information for videodb sdk""" -__version__ = "0.2.13" +__version__ = "0.2.14" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" diff --git a/videodb/__init__.py b/videodb/__init__.py index 6f13816..d1d3215 100644 --- a/videodb/__init__.py +++ b/videodb/__init__.py @@ -16,6 +16,10 @@ SubtitleBorderStyle, SubtitleStyle, TextStyle, + TranscodeMode, + ResizeMode, + VideoConfig, + AudioConfig, ) from videodb.client import Connection from videodb.exceptions import ( @@ -43,6 +47,10 @@ "TextStyle", "SceneExtractionType", "Segmenter", + "TranscodeMode", + "ResizeMode", + "VideoConfig", + "AudioConfig", ] diff --git a/videodb/_constants.py b/videodb/_constants.py index b155752..b0eafbe 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -76,6 +76,7 @@ class ApiPath: web = "web" translate = "translate" dub = "dub" + transcode = "transcode" class Status: @@ -164,3 +165,28 @@ class TextStyle: tabsize: int = 4 x: Union[str, int] = "(main_w-text_w)/2" y: Union[str, int] = "(main_h-text_h)/2" + + +class TranscodeMode: + lightning = "lightning" + economy = "economy" + + +class ResizeMode: + crop = "crop" + fit = "fit" + pad = "pad" + + +@dataclass +class VideoConfig: + resolution: int = 720 + quality: int = 23 + framerate: int = None + aspect_ratio: str = None + resize_mode: str = ResizeMode.crop + + +@dataclass +class AudioConfig: + mute: bool = False diff --git a/videodb/client.py b/videodb/client.py index 7cbfbfd..54fe008 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -8,6 +8,9 @@ from videodb.__about__ import __version__ from videodb._constants import ( ApiPath, + TranscodeMode, + VideoConfig, + AudioConfig, ) from videodb.collection import Collection @@ -188,6 +191,41 @@ def youtube_search( ) return search_data.get("results") + def transcode( + self, + source: str, + callback_url: str, + mode: TranscodeMode = TranscodeMode.economy, + start_ts: int = None, + end_ts: int = None, + video_config: VideoConfig = VideoConfig(), + audio_config: AudioConfig = AudioConfig(), + ) -> None: + """Transcode the video + + :param str source: URL of the video to transcode, preferably a downloadable URL + :param str callback_url: URL to receive the callback + :param TranscodeMode mode: Mode of the transcoding + :param int start_ts: Start timestamp of the video to transcode (optional) + :param int end_ts: End timestamp of the video to transcode (optional) + :param VideoConfig video_config: Video configuration (optional) + :param AudioConfig audio_config: Audio configuration (optional) + :return: None + :rtype: None + """ + self.post( + path=f"{ApiPath.transcode}", + data={ + "source": source, + "callback_url": callback_url, + "mode": mode, + "start_ts": start_ts, + "end_ts": end_ts, + "video_config": video_config.__dict__, + "audio_config": audio_config.__dict__, + }, + ) + def upload( self, file_path: str = None, From 55269c97083323dcb1ceb4e787a1488f7bdfad94 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Tue, 6 May 2025 15:14:40 +0530 Subject: [PATCH 2/8] refactor: start and end --- videodb/client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/videodb/client.py b/videodb/client.py index 54fe008..f0e5c26 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -196,8 +196,8 @@ def transcode( source: str, callback_url: str, mode: TranscodeMode = TranscodeMode.economy, - start_ts: int = None, - end_ts: int = None, + start: int = None, + end: int = None, video_config: VideoConfig = VideoConfig(), audio_config: AudioConfig = AudioConfig(), ) -> None: @@ -206,8 +206,8 @@ def transcode( :param str source: URL of the video to transcode, preferably a downloadable URL :param str callback_url: URL to receive the callback :param TranscodeMode mode: Mode of the transcoding - :param int start_ts: Start timestamp of the video to transcode (optional) - :param int end_ts: End timestamp of the video to transcode (optional) + :param int start: Start timestamp of the video to transcode (optional) + :param int end: End timestamp of the video to transcode (optional) :param VideoConfig video_config: Video configuration (optional) :param AudioConfig audio_config: Audio configuration (optional) :return: None @@ -219,8 +219,8 @@ def transcode( "source": source, "callback_url": callback_url, "mode": mode, - "start_ts": start_ts, - "end_ts": end_ts, + "start": start, + "end": end, "video_config": video_config.__dict__, "audio_config": audio_config.__dict__, }, From 808b8fdef764867c0cf9ab772d1269e908c2b833 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:14:50 +0530 Subject: [PATCH 3/8] feat: add transcode details --- videodb/client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/videodb/client.py b/videodb/client.py index f0e5c26..528bfdf 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -226,6 +226,15 @@ def transcode( }, ) + def get_transcode_details(self, job_id: str) -> dict: + """Get the details of a transcode job. + + :param str job_id: ID of the transcode job + :return: Details of the transcode job + :rtype: dict + """ + return self.get(path=f"{ApiPath.transcode}/{job_id}") + def upload( self, file_path: str = None, From 80f4541966b66199ace6811d5ed834577a7485eb Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:18:13 +0530 Subject: [PATCH 4/8] fix: constants --- videodb/_constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/videodb/_constants.py b/videodb/_constants.py index b0eafbe..a4415b2 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -180,7 +180,7 @@ class ResizeMode: @dataclass class VideoConfig: - resolution: int = 720 + resolution: int = None quality: int = 23 framerate: int = None aspect_ratio: str = None From 24711acbc9ab52ac7017e2439a6229d524a8f138 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:26:12 +0530 Subject: [PATCH 5/8] feat: add job id --- videodb/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/videodb/client.py b/videodb/client.py index 528bfdf..896eacd 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -213,7 +213,7 @@ def transcode( :return: None :rtype: None """ - self.post( + job_data = self.post( path=f"{ApiPath.transcode}", data={ "source": source, @@ -225,6 +225,7 @@ def transcode( "audio_config": audio_config.__dict__, }, ) + return job_data.get("job_id") def get_transcode_details(self, job_id: str) -> dict: """Get the details of a transcode job. From 1993b82c4804233f02827295cef95df1c3678aff Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:29:28 +0530 Subject: [PATCH 6/8] build: update version --- videodb/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/videodb/__about__.py b/videodb/__about__.py index 90f7f66..4059c8a 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -1,7 +1,7 @@ """ About information for videodb sdk""" -__version__ = "0.2.14" +__version__ = "0.2.15" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" From fa73a1e939f6d710bc41bb5ebaf1cadb2b2970ba Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:53:17 +0530 Subject: [PATCH 7/8] fix: remove ts --- videodb/client.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/videodb/client.py b/videodb/client.py index 896eacd..a8818c2 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -196,8 +196,6 @@ def transcode( source: str, callback_url: str, mode: TranscodeMode = TranscodeMode.economy, - start: int = None, - end: int = None, video_config: VideoConfig = VideoConfig(), audio_config: AudioConfig = AudioConfig(), ) -> None: @@ -206,8 +204,6 @@ def transcode( :param str source: URL of the video to transcode, preferably a downloadable URL :param str callback_url: URL to receive the callback :param TranscodeMode mode: Mode of the transcoding - :param int start: Start timestamp of the video to transcode (optional) - :param int end: End timestamp of the video to transcode (optional) :param VideoConfig video_config: Video configuration (optional) :param AudioConfig audio_config: Audio configuration (optional) :return: None @@ -219,8 +215,6 @@ def transcode( "source": source, "callback_url": callback_url, "mode": mode, - "start": start, - "end": end, "video_config": video_config.__dict__, "audio_config": audio_config.__dict__, }, From 5aa14a6a2d701b306f42f7de85e3ae1d33a2a020 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Thu, 12 Jun 2025 17:45:00 +0530 Subject: [PATCH 8/8] fix: doc strings --- videodb/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/videodb/client.py b/videodb/client.py index 5bd7375..25ae399 100644 --- a/videodb/client.py +++ b/videodb/client.py @@ -230,8 +230,8 @@ def transcode( :param TranscodeMode mode: Mode of the transcoding :param VideoConfig video_config: Video configuration (optional) :param AudioConfig audio_config: Audio configuration (optional) - :return: None - :rtype: None + :return: Transcode job ID + :rtype: str """ job_data = self.post( path=f"{ApiPath.transcode}",