autogen_ext.agents.video_surfer.tools#

extract_audio(video_path: str, audio_output_path: str) str[源]#

从视频文件中提取音频并将其保存为 MP3 文件。

参数:
  • video_path – 视频文件的路径。

  • audio_output_path – 保存提取的音频文件的路径。

返回:

确认消息,包含保存的音频文件的路径。

transcribe_audio_with_timestamps(audio_path: str) str[源]#

使用 Whisper 模型转录带时间戳的音频文件。

参数:

audio_path – 音频文件的路径。

返回:

带时间戳的转录文本。

get_video_length(video_path: str) str[源]#

返回视频的长度(秒)。

参数:

video_path – 视频文件的路径。

返回:

视频的持续时间(秒)。

save_screenshot(video_path: str, timestamp: float, output_path: str) None[源]#

在指定时间戳捕获屏幕截图并将其保存到输出路径。

参数:
  • video_path – 视频文件的路径。

  • timestamp – 时间戳,单位为秒。

  • output_path – 保存屏幕截图的路径。文件格式由路径中的扩展名决定。

async transcribe_video_screenshot(video_path: str, timestamp: float, model_client: ChatCompletionClient) str[源]#

使用 OpenAI API 转录在指定时间戳捕获的视频屏幕截图内容。

参数:
  • video_path – 视频文件的路径。

  • timestamp – 时间戳,单位为秒。

  • model_client – ChatCompletionClient 实例。

返回:

屏幕截图内容的描述。

get_screenshot_at(video_path: str, timestamps: List[float]) List[Tuple[float, ndarray[Any, Any]]][源]#

在指定时间戳捕获屏幕截图并将其作为 Python 对象返回。

参数:
  • video_path – 视频文件的路径。

  • timestamps – 时间戳列表,单位为秒。

返回:

包含时间戳和对应帧(图像)的元组列表。每帧是一个 NumPy 数组(高 x 宽 x 通道)。