diff --git a/videodb/__about__.py b/videodb/__about__.py index 3cc2806..1a52acf 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -2,7 +2,7 @@ -__version__ = "0.2.15" +__version__ = "0.2.17" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" diff --git a/videodb/_constants.py b/videodb/_constants.py index b98ddab..e8908c1 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -17,11 +17,13 @@ class SearchType: keyword = "keyword" scene = "scene" llm = "llm" + custom = "custom" class IndexType: spoken_word = "spoken_word" scene = "scene" + hybrid = "hybrid" class SceneExtractionType: @@ -36,6 +38,9 @@ class Workflows: class SemanticSearchDefaultValues: result_threshold = 5 score_threshold = 0.2 + rerank = False + rerank_params = {} + sort_docs_on = None class Segmenter: @@ -58,6 +63,7 @@ class ApiPath: index = "index" search = "search" compile = "compile" + clip = "clip" workflow = "workflow" timeline = "timeline" delete = "delete" diff --git a/videodb/collection.py b/videodb/collection.py index e941cf4..9451e57 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -8,6 +8,7 @@ ApiPath, IndexType, SearchType, + SemanticSearchDefaultValues, ) from videodb.video import Video from videodb.audio import Audio @@ -387,7 +388,11 @@ def search( result_threshold: Optional[int] = None, score_threshold: Optional[float] = None, dynamic_score_percentage: Optional[float] = None, + rerank: bool = SemanticSearchDefaultValues.rerank, + rerank_params: dict = SemanticSearchDefaultValues.rerank_params, + sort_docs_on: str = SemanticSearchDefaultValues.sort_docs_on, filter: List[Dict[str, Any]] = [], + prompt_id: Optional[str] = None, ) -> SearchResult: """Search for a query in the collection. @@ -397,6 +402,10 @@ def search( :param int result_threshold: Number of results to return (optional) :param float score_threshold: Threshold score for the search (optional) :param float dynamic_score_percentage: Percentage of dynamic score to consider (optional) + :param bool rerank: Rerank search results (optional) + :param dict rerank_params: Parameters for reranking (optional) + :param str sort_docs_on: Parameter to specify what metric to sort the docs of video on + :param str prompt_id: ID of the prompt to use for search (optional) :raise SearchError: If the search fails :return: :class:`SearchResult ` object :rtype: :class:`videodb.search.SearchResult` @@ -410,7 +419,11 @@ def search( result_threshold=result_threshold, score_threshold=score_threshold, dynamic_score_percentage=dynamic_score_percentage, + rerank=rerank, + rerank_params=rerank_params, filter=filter, + sort_docs_on=sort_docs_on, + prompt_id=prompt_id, ) def search_title(self, query) -> List[Video]: diff --git a/videodb/search.py b/videodb/search.py index ba557be..7750a57 100644 --- a/videodb/search.py +++ b/videodb/search.py @@ -29,6 +29,7 @@ def __init__(self, _connection, **kwargs): self.player_url = None self.collection_id = "default" self._results = kwargs.get("results", []) + self.metadata = kwargs.get("meta", None) self._format_results() def _format_results(self): @@ -45,6 +46,9 @@ def _format_results(self): doc.get("end"), doc.get("text"), doc.get("score"), + scene_index_id=doc.get("scene_index_id"), + scene_index_name=doc.get("scene_index_name"), + metadata=doc.get("metadata"), ) ) @@ -123,6 +127,8 @@ def search_inside_video( result_threshold: Optional[int] = None, score_threshold: Optional[float] = None, dynamic_score_percentage: Optional[float] = None, + rerank: bool = SemanticSearchDefaultValues.rerank, + rerank_params: dict = SemanticSearchDefaultValues.rerank_params, **kwargs, ): search_data = self._connection.post( @@ -132,10 +138,14 @@ def search_inside_video( "index_type": index_type, "query": query, "score_threshold": score_threshold - or SemanticSearchDefaultValues.score_threshold, + if score_threshold is not None + else SemanticSearchDefaultValues.score_threshold, "result_threshold": result_threshold - or SemanticSearchDefaultValues.result_threshold, + if result_threshold is not None + else SemanticSearchDefaultValues.result_threshold, "dynamic_score_percentage": dynamic_score_percentage, + "rerank": rerank, + "rerank_params": rerank_params, **kwargs, }, ) @@ -150,6 +160,9 @@ def search_inside_collection( result_threshold: Optional[int] = None, score_threshold: Optional[float] = None, dynamic_score_percentage: Optional[float] = None, + rerank: bool = SemanticSearchDefaultValues.rerank, + rerank_params: dict = SemanticSearchDefaultValues.rerank_params, + sort_docs_on: str = SemanticSearchDefaultValues.sort_docs_on, **kwargs, ): search_data = self._connection.post( @@ -159,10 +172,15 @@ def search_inside_collection( "index_type": index_type, "query": query, "score_threshold": score_threshold - or SemanticSearchDefaultValues.score_threshold, + if score_threshold is not None + else SemanticSearchDefaultValues.score_threshold, "result_threshold": result_threshold - or SemanticSearchDefaultValues.result_threshold, + if result_threshold is not None + else SemanticSearchDefaultValues.result_threshold, "dynamic_score_percentage": dynamic_score_percentage, + "rerank": rerank, + "rerank_params": rerank_params, + "sort_docs_on": sort_docs_on, **kwargs, }, ) @@ -238,6 +256,7 @@ def search_inside_collection(self, **kwargs): SearchType.semantic: SemanticSearch, SearchType.keyword: KeywordSearch, SearchType.scene: SceneSearch, + SearchType.custom: SemanticSearch, } diff --git a/videodb/shot.py b/videodb/shot.py index c2fadcb..2fee6d4 100644 --- a/videodb/shot.py +++ b/videodb/shot.py @@ -19,6 +19,9 @@ class Shot: :ivar int search_score: Search relevance score :ivar str stream_url: URL to stream the shot :ivar str player_url: URL to play the shot in a player + :ivar Optional[str] scene_index_id: ID of the scene index for scene search results + :ivar Optional[str] scene_index_name: Name of the scene index for scene search results + :ivar Optional[dict] metadata: Additional metadata for the shot """ def __init__( @@ -31,6 +34,10 @@ def __init__( end: float, text: Optional[str] = None, search_score: Optional[int] = None, + scene_index_id: Optional[str] = None, + scene_index_name: Optional[str] = None, + metadata: Optional[dict] = None, + ) -> None: self._connection = _connection self.video_id = video_id @@ -40,21 +47,37 @@ def __init__( self.end = end self.text = text self.search_score = search_score + self.scene_index_id = scene_index_id + self.scene_index_name = scene_index_name + self.metadata = metadata self.stream_url = None self.player_url = None def __repr__(self) -> str: - return ( + repr_str = ( f"Shot(" f"video_id={self.video_id}, " f"video_title={self.video_title}, " f"start={self.start}, " f"end={self.end}, " f"text={self.text}, " - f"search_score={self.search_score}, " - f"stream_url={self.stream_url}, " + f"search_score={self.search_score}" + ) + if self.scene_index_id: + repr_str += f", scene_index_id={self.scene_index_id}" + + if self.scene_index_name: + repr_str += f", scene_index_name={self.scene_index_name}" + + if self.metadata: + repr_str += f", metadata={self.metadata}" + + repr_str += ( + f", stream_url={self.stream_url}, " f"player_url={self.player_url})" ) + return repr_str + def __getitem__(self, key): """Get an item from the shot object""" diff --git a/videodb/timeline_v2.py b/videodb/timeline_v2.py new file mode 100644 index 0000000..01a50f9 --- /dev/null +++ b/videodb/timeline_v2.py @@ -0,0 +1,657 @@ +from typing import List, Optional, Union +from enum import Enum + + +class AssetType(str, Enum): + video = "video" + image = "image" + audio = "audio" + text = "text" + caption = "caption" + + +class Fit(str, Enum): + crop = "crop" + cover = "cover" + contain = "contain" + + +class Position(str, Enum): + top = "top" + bottom = "bottom" + left = "left" + right = "right" + center = "center" + top_left = "top-left" + top_right = "top-right" + bottom_left = "bottom-left" + bottom_right = "bottom-right" + + +class Filter(str, Enum): + """A filter effect to apply to the Clip.""" + + blur = "blur" + boost = "boost" + contrast = "contrast" + darken = "darken" + greyscale = "greyscale" + lighten = "lighten" + muted = "muted" + negative = "negative" + + +class TextAlignment(str, Enum): + """Place the text in one of nine predefined positions of the background.""" + + top = "top" + top_right = "top_right" + right = "right" + bottom_right = "bottom_right" + bottom = "bottom" + bottom_left = "bottom_left" + left = "left" + top_left = "top_left" + center = "center" + + +class HorizontalAlignment(str, Enum): + """Horizontal text alignment options.""" + + left = "left" + center = "center" + right = "right" + + +class CaptionBorderStyle(str, Enum): + """Border style properties for caption assets.""" + + outline_and_shadow = "outline_and_shadow" + outline = "outline" + + +class CaptionAlignment(str, Enum): + """Caption alignment properties for caption assets.""" + + bottom_left = "bottom_left" + bottom_center = "bottom_center" + bottom_right = "bottom_right" + middle_left = "middle_left" + middle_center = "middle_center" + middle_right = "middle_right" + top_left = "top_left" + top_center = "top_center" + top_right = "top_right" + + +class CaptionAnimation(str, Enum): + """Caption animation properties for caption assets.""" + + # float_in_bottom = "float_in_bottom" + box_highlight = "box_highlight" + color_highlight = "color_highlight" + reveal = "reveal" + karioke = "karioke" + impact = "impact" + supersize = "supersize" + + +class VerticalAlignment(str, Enum): + """Vertical text alignment options.""" + + top = "top" + center = "center" + bottom = "bottom" + + +class Offset: + def __init__(self, x: float = 0, y: float = 0): + self.x = x + self.y = y + + def to_json(self): + return { + "x": self.x, + "y": self.y, + } + + +class Crop: + def __init__(self, top: int = 0, right: int = 0, bottom: int = 0, left: int = 0): + self.top = top + self.right = right + self.bottom = bottom + self.left = left + + def to_json(self): + return { + "top": self.top, + "right": self.right, + "bottom": self.bottom, + "left": self.left, + } + + +class Transition: + def __init__(self, in_: str = None, out: str = None): + self.in_ = in_ + self.out = out + + def to_json(self): + return { + "in": self.in_, + "out": self.out, + } + + +class BaseAsset: + """The type of asset to display for the duration of the Clip.""" + + type: AssetType + + +class VideoAsset(BaseAsset): + """The VideoAsset is used to create video sequences from video files. The src must be a publicly accessible URL to a video resource""" + + type = AssetType.video + + def __init__( + self, + id: str, + trim: int = 0, + volume: float = 1, + crop: Optional[Crop] = None, + ): + if trim < 0: + raise ValueError("trim must be non-negative") + if not (0 <= volume <= 5): + raise ValueError("volume must be between 0 and 5") + + self.id = id + self.trim = trim + self.volume = volume + self.crop = crop if crop is not None else Crop() + + def to_json(self): + return { + "type": self.type, + "id": self.id, + "trim": self.trim, + "volume": self.volume, + "crop": self.crop.to_json(), + } + + +class ImageAsset(BaseAsset): + """The ImageAsset is used to create video from images to compose an image. The src must be a publicly accessible URL to an image resource such as a jpg or png file.""" + + type = AssetType.image + + def __init__(self, id: str, trim: int = 0, crop: Optional[Crop] = None): + if trim < 0: + raise ValueError("trim must be non-negative") + + self.id = id + self.trim = trim + self.crop = crop if crop is not None else Crop() + + def to_json(self): + return { + "type": self.type, + "id": self.id, + "crop": self.crop.to_json(), + } + + +class AudioAsset(BaseAsset): + """The AudioAsset is used to create audio sequences from audio files. The src must be a publicly accessible URL to an audio resource""" + + type = AssetType.audio + + def __init__(self, id: str, trim: int = 0, volume: float = 1): + self.id = id + self.trim = trim + self.volume = volume + + def to_json(self): + return { + "type": self.type, + "id": self.id, + "trim": self.trim, + "volume": self.volume, + } + + +class Font: + """Font styling properties for text assets.""" + + def __init__( + self, + family: str = "Clear Sans", + size: int = 48, + color: str = "#FFFFFF", + opacity: float = 1.0, + weight: Optional[int] = None, + ): + if size < 1: + raise ValueError("size must be at least 1") + if not (0.0 <= opacity <= 1.0): + raise ValueError("opacity must be between 0.0 and 1.0") + if weight is not None and not (100 <= weight <= 900): + raise ValueError("weight must be between 100 and 900") + + self.family = family + self.size = size + self.color = color + self.opacity = opacity + self.weight = weight + + def to_json(self): + data = { + "family": self.family, + "size": self.size, + "color": self.color, + "opacity": self.opacity, + } + if self.weight is not None: + data["weight"] = self.weight + return data + + +class Border: + """Text border properties.""" + + def __init__(self, color: str = "#000000", width: float = 0.0): + if width < 0.0: + raise ValueError("width must be non-negative") + self.color = color + self.width = width + + def to_json(self): + return { + "color": self.color, + "width": self.width, + } + + +class Shadow: + """Text shadow properties.""" + + def __init__(self, color: str = "#000000", x: float = 0.0, y: float = 0.0): + if x < 0.0: + raise ValueError("x must be non-negative") + if y < 0.0: + raise ValueError("y must be non-negative") + self.color = color + self.x = x + self.y = y + + def to_json(self): + return { + "color": self.color, + "x": self.x, + "y": self.y, + } + + +class Background: + """Text background styling properties.""" + + def __init__( + self, + width: float = 0.0, + height: float = 0.0, + color: str = "#000000", + border_width: float = 0.0, + opacity: float = 1.0, + text_alignment: TextAlignment = TextAlignment.center, + ): + if width < 0.0: + raise ValueError("width must be non-negative") + if height < 0.0: + raise ValueError("height must be non-negative") + if border_width < 0.0: + raise ValueError("border_width must be non-negative") + if not (0.0 <= opacity <= 1.0): + raise ValueError("opacity must be between 0.0 and 1.0") + + self.width = width + self.height = height + self.color = color + self.border_width = border_width + self.opacity = opacity + self.text_alignment = text_alignment + + def to_json(self): + return { + "width": self.width, + "height": self.height, + "color": self.color, + "border_width": self.border_width, + "opacity": self.opacity, + "text_alignment": self.text_alignment.value, + } + + +class Alignment: + """Text alignment properties.""" + + def __init__( + self, + horizontal: HorizontalAlignment = HorizontalAlignment.center, + vertical: VerticalAlignment = VerticalAlignment.center, + ): + self.horizontal = horizontal + self.vertical = vertical + + def to_json(self): + return { + "horizontal": self.horizontal.value, + "vertical": self.vertical.value, + } + + +class TextAsset(BaseAsset): + """The TextAsset is used to create text sequences from text strings with full control over the text styling and positioning.""" + + type = AssetType.text + + def __init__( + self, + text: str, + font: Optional[Font] = None, + border: Optional[Border] = None, + shadow: Optional[Shadow] = None, + background: Optional[Background] = None, + alignment: Optional[Alignment] = None, + tabsize: int = 4, + line_spacing: float = 0, + width: Optional[int] = None, + height: Optional[int] = None, + ): + if tabsize < 1: + raise ValueError("tabsize must be at least 1") + if line_spacing < 0.0: + raise ValueError("line_spacing must be non-negative") + if width is not None and width < 1: + raise ValueError("width must be at least 1") + if height is not None and height < 1: + raise ValueError("height must be at least 1") + + self.text = text + self.font = font if font is not None else Font() + self.border = border + self.shadow = shadow + self.background = background + self.alignment = alignment if alignment is not None else Alignment() + self.tabsize = tabsize + self.line_spacing = line_spacing + self.width = width + self.height = height + + def to_json(self): + data = { + "type": self.type, + "text": self.text, + "font": self.font.to_json(), + "alignment": self.alignment.to_json(), + "tabsize": self.tabsize, + "line_spacing": self.line_spacing, + } + if self.border: + data["border"] = self.border.to_json() + if self.shadow: + data["shadow"] = self.shadow.to_json() + if self.background: + data["background"] = self.background.to_json() + if self.width is not None: + data["width"] = self.width + if self.height is not None: + data["height"] = self.height + + return data + + +class FontStyling: + """Font styling properties for caption assets.""" + + def __init__( + self, + name: str = "Clear Sans", + size: int = 30, + bold: bool = False, + italic: bool = False, + underline: bool = False, + strikeout: bool = False, + scale_x: float = 100, + scale_y: float = 100, + spacing: float = 0.0, + angle: float = 0.0, + ): + self.name = name + self.size = size + self.bold = bold + self.italic = italic + self.underline = underline + self.strikeout = strikeout + self.scale_x = scale_x + self.scale_y = scale_y + self.spacing = spacing + self.angle = angle + + def to_json(self): + return { + "font_name": self.name, + "font_size": self.size, + "bold": self.bold, + "italic": self.italic, + "underline": self.underline, + "strikeout": self.strikeout, + "scale_x": self.scale_x, + "scale_y": self.scale_y, + "spacing": self.spacing, + "angle": self.angle, + } + + +class BorderAndShadow: + """Border and shadow properties for caption assets.""" + + def __init__( + self, + style: CaptionBorderStyle = CaptionBorderStyle.outline_and_shadow, + outline: int = 1, + outline_color: str = "&H00000000", + shadow: int = 0, + ): + self.style = style + self.outline = outline + self.outline_color = outline_color + self.shadow = shadow + + def to_json(self): + return { + "style": self.style.value, + "outline": self.outline, + "outline_color": self.outline_color, + "shadow": self.shadow, + } + + +class Positioning: + """Positioning properties for caption assets.""" + + def __init__( + self, + alignment: CaptionAlignment = CaptionAlignment.bottom_center, + margin_l: int = 30, + margin_r: int = 30, + margin_v: int = 30, + ): + self.alignment = alignment + self.margin_l = margin_l + self.margin_r = margin_r + self.margin_v = margin_v + + def to_json(self): + return { + "alignment": self.alignment.value, + "margin_l": self.margin_l, + "margin_r": self.margin_r, + "margin_v": self.margin_v, + } + + +class CaptionAsset(BaseAsset): + """The CaptionAsset is used to create captions from text strings with full styling and ass support.""" + + type = AssetType.caption + + def __init__( + self, + src: str = "auto", + font: Optional[FontStyling] = None, + primary_color: str = "&H00FFFFFF", + secondary_color: str = "&H000000FF", + back_color: str = "&H00000000", + border: Optional[BorderAndShadow] = None, + position: Optional[Positioning] = None, + animation: Optional[CaptionAnimation] = None, + ): + self.src = src + self.font = font if font is not None else FontStyling() + self.primary_color = primary_color + self.secondary_color = secondary_color + self.back_color = back_color + self.border = border if border is not None else BorderAndShadow() + self.position = position if position is not None else Positioning() + self.animation = animation + + def to_json(self): + data = { + "type": self.type, + "src": self.src, + "font": self.font.to_json(), + "primary_color": self.primary_color, + "secondary_color": self.secondary_color, + "back_color": self.back_color, + "border": self.border.to_json(), + "position": self.position.to_json(), + } + if self.animation: + data["animation"] = self.animation.value + return data + + +AnyAsset = Union[VideoAsset, ImageAsset, AudioAsset, TextAsset, CaptionAsset] + + +class Clip: + """A clip is a container for a specific type of asset, i.e. a title, image, video, audio or html. You use a Clip to define when an asset will display on the timeline, how long it will play for and transitions, filters and effects to apply to it.""" + + def __init__( + self, + asset: AnyAsset, + start: Union[float, int], + length: Union[float, int], + transition: Optional[Transition] = None, + effect: Optional[str] = None, + filter: Optional[Filter] = None, + scale: float = 1, + opacity: float = 1, + fit: Optional[Fit] = Fit.crop, + position: Position = Position.center, + offset: Optional[Offset] = None, + ): + if start < 0: + raise ValueError("start must be non-negative") + if length <= 0: + raise ValueError("length must be positive") + if not (0 <= scale <= 10): + raise ValueError("scale must be between 0 and 10") + if not (0 <= opacity <= 1): + raise ValueError("opacity must be between 0 and 1") + + self.asset = asset + self.start = start + self.length = length + self.transition = transition + self.effect = effect + self.filter = filter + self.scale = scale + self.opacity = opacity + self.fit = fit + self.position = position + self.offset = offset if offset is not None else Offset() + + def to_json(self): + json = { + "asset": self.asset.to_json(), + "start": self.start, + "length": self.length, + "effect": self.effect, + "scale": self.scale, + "opacity": self.opacity, + "fit": self.fit, + "position": self.position, + "offset": self.offset.to_json(), + } + + if self.transition: + json["transition"] = self.transition.to_json() + if self.filter: + json["filter"] = self.filter.value + + return json + + +class Track: + def __init__(self, clips: List[Clip] = []): + self.clips = clips + + def add_clip(self, clip: Clip): + self.clips.append(clip) + + def to_json(self): + return { + "clips": [clip.to_json() for clip in self.clips], + } + + +class TimelineV2: + def __init__(self, connection): + self.connection = connection + self.background: str = "#000000" + self.resolution: str = "1280x720" + self.tracks: List[Track] = [] + self.stream_url = None + self.player_url = None + + def add_track(self, track: Track): + self.tracks.append(track) + + def add_clip(self, track_index: int, clip: Clip): + self.tracks[track_index].clips.append(clip) + + def to_json(self): + return { + "timeline": { + "background": self.background, + "resolution": self.resolution, + "tracks": [track.to_json() for track in self.tracks], + } + } + + def generate_stream(self): + stream_data = self.connection.post( + path="timeline_v2", + data=self.to_json(), + ) + self.stream_url = stream_data.get("stream_url") + self.player_url = stream_data.get("player_url") + return stream_data.get("stream_url", None) + + def download_stream(self, stream_url: str): + return self.connection.post( + path="timeline_v2/download", data={"stream_url": stream_url} + ) diff --git a/videodb/video.py b/videodb/video.py index eb4da7b..edb7a1e 100644 --- a/videodb/video.py +++ b/videodb/video.py @@ -5,6 +5,7 @@ IndexType, SceneExtractionType, SearchType, + SemanticSearchDefaultValues, Segmenter, SubtitleStyle, Workflows, @@ -69,6 +70,8 @@ def search( result_threshold: Optional[int] = None, score_threshold: Optional[float] = None, dynamic_score_percentage: Optional[float] = None, + rerank: bool = SemanticSearchDefaultValues.rerank, + rerank_params: dict = SemanticSearchDefaultValues.rerank_params, filter: List[Dict[str, Any]] = [], **kwargs, ) -> SearchResult: @@ -80,6 +83,8 @@ def search( :param int result_threshold: (optional) Number of results to return :param float score_threshold: (optional) Threshold score for the search :param float dynamic_score_percentage: (optional) Percentage of dynamic score to consider + :param bool rerank: (optional) Rerank search results + :param dict rerank_params: (optional) Parameters for reranking :raise SearchError: If the search fails :return: :class:`SearchResult ` object :rtype: :class:`videodb.search.SearchResult` @@ -93,6 +98,8 @@ def search( result_threshold=result_threshold, score_threshold=score_threshold, dynamic_score_percentage=dynamic_score_percentage, + rerank=rerank, + rerank_params=rerank_params, filter=filter, **kwargs, ) @@ -277,12 +284,14 @@ def translate_transcript( def index_spoken_words( self, language_code: Optional[str] = None, + segmentation_type: Optional[str] = None, force: bool = False, callback_url: str = None, ) -> None: """Semantic indexing of spoken words in the video. :param str language_code: (optional) Language code of the video + :param str segmentation_type: (optional) Segmentation type used for indexing :param bool force: (optional) Force to index the video :param str callback_url: (optional) URL to receive the callback :raises InvalidRequestError: If the video is already indexed @@ -294,6 +303,7 @@ def index_spoken_words( data={ "index_type": IndexType.spoken_word, "language_code": language_code, + "segmentation_type": segmentation_type, "force": force, "callback_url": callback_url, }, @@ -562,6 +572,31 @@ def add_subtitle(self, style: SubtitleStyle = SubtitleStyle()) -> str: ) return subtitle_data.get("stream_url", None) + def clip( + self, + prompt: str, + content_type: str, + model_name: str, + ) -> str: + """Generate a clip from the video using a prompt. + + :param str prompt: Prompt to generate the clip + :param str content_type: Content type for the clip + :param str model_name: Model name for generation + :return: The stream url of the generated clip + :rtype: str + """ + + clip_data = self._connection.post( + path=f"{ApiPath.video}/{self.id}/{ApiPath.clip}", + data={ + "prompt": prompt, + "content_type": content_type, + "model_name": model_name, + }, + ) + return SearchResult(self._connection, **clip_data) + def insert_video(self, video, timestamp: float) -> str: """Insert a video into another video