Camel.toolkits.video download toolkit
_capture_screenshot
Capture a screenshot from a video file at a specific timestamp.
Parameters:
- video_file (str): The path to the video file.
- timestamp (float): The time in seconds from which to capture the screenshot.
Returns:
Image.Image: The captured screenshot in the form of Image.Image.
VideoDownloaderToolkit
A class for downloading videos and optionally splitting them into chunks.
Parameters:
- download_directory (Optional[str], optional): The directory where the video will be downloaded to. If not provided, video will be stored in a temporary directory and will be cleaned up after use. (default: :obj:
None
) - cookies_path (Optional[str], optional): The path to the cookies file for the video service in Netscape format. (default: :obj:
None
)
init
del
Deconstructor for the VideoDownloaderToolkit class.
Cleans up the downloaded video if they are stored in a temporary directory.
download_video
Download the video and optionally split it into chunks.
yt-dlp will detect if the video is downloaded automatically so there is no need to check if the video exists.
Parameters:
- url (str): The URL of the video to download.
Returns:
str: The path to the downloaded video file.
get_video_bytes
Download video by the path, and return the content in bytes.
Parameters:
- video_path (str): The path to the video file.
Returns:
bytes: The video file content in bytes.
get_video_screenshots
Capture screenshots from the video at specified timestamps or by dividing the video into equal parts if an integer is provided.
Parameters:
- video_path (str): The local path or URL of the video to take screenshots.
- amount (int): the amount of evenly split screenshots to capture.
Returns:
List[Image.Image]: A list of screenshots as Image.Image.
get_tools
Returns:
List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.