快速提取单帧 - ExtractSingleFrame
函数简介
快速提取单帧(无需保持视频打开状态)。
接口名称
ExtractSingleFrame
DLL调用
int64_t ExtractSingleFrame(int64_t instance, string videoPath, int32_t frameIndex)
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| videoPath | 字符串 | 视频文件路径 |
| frameIndex | 整数型 | 帧索引 |
示例
int64_t instance = CreateCOLAPlugInterFace();
int64_t imageHandle = ExtractSingleFrame(instance, "test.mp4", 100);
if (imageHandle != 0) {
printf("提取第100帧成功,图像句柄: %lld\n", (long long)imageHandle);
// 使用图像句柄...
FreeImagePtr(instance, imageHandle);
} else {
printf("提取失败\n");
}
DestroyCOLAPlugInterFace(instance);
返回值
图像句柄(BGRA格式),失败返回0。
注意事项
- 返回的图像句柄需调用FreeImagePtr释放
- 此方法无需保持视频打开状态,适合单次提取
