MoviePy Video Tools
Agno MoviePyVideoTools enable an Agent to process videos, extract audio, generate SRT caption files, and embed rich, word-highlighted captions.
Prerequisites
To use MoviePyVideoTools
, you need to install moviepy
and its dependency ffmpeg
:
Important for Captioning Workflow:
The create_srt
and embed_captions
tools require a transcription of the video’s audio. MoviePyVideoTools
itself does not perform speech-to-text. You’ll typically use another tool, such as OpenAITools
with its transcribe_audio
function, to generate the transcription (often in SRT format) which is then used by these tools.
Example
The following example demonstrates a complete workflow where an agent uses MoviePyVideoTools
in conjunction with OpenAITools
to:
- Extract audio from a video file
- Transcribe the audio using OpenAI’s speech-to-text
- Generate an SRT caption file from the transcription
- Embed the captions into the video with word-level highlighting
Toolkit Functions
These are the functions exposed by MoviePyVideoTools
:
Function | Description |
---|---|
extract_audio | Extracts the audio track from a video file and saves it to a specified output path. |
create_srt | Saves a given transcription (expected in SRT format) to a .srt file at the specified output path. |
embed_captions | Embeds captions from an SRT file into a video, creating a new video file with word-level highlighting. |
Toolkit Parameters
These parameters are passed to the MoviePyVideoTools
constructor:
Parameter | Type | Default | Description |
---|---|---|---|
process_video | bool | True | Enables the extract_audio tool. |
generate_captions | bool | True | Enables the create_srt tool. |
embed_captions | bool | True | Enables the embed_captions tool. |