|
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 |
@@ -212,6 +215,45 @@ def youtube_search( |
212 | 215 | ) |
213 | 216 | return search_data.get("results") |
214 | 217 |
|
| 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 | + |
215 | 257 | def upload( |
216 | 258 | self, |
217 | 259 | file_path: str = None, |
|
0 commit comments