feat(kling): 优化数字人视频播放和识别功能
Some checks failed
Build and Deploy / deploy (push) Has been cancelled

- 前端:新增签名URL存储,将视频下载为blob URL确保浏览器兼容播放
- 后端:移除视频/音频播放URL的Content-Type参数,简化签名URL生成逻辑
- 修复:使用签名URL调用人脸识别API,避免blob URL无法被外部API访问的问题
This commit is contained in:
2026-04-09 01:29:05 +08:00
parent 63d3e7eecb
commit e169065653
3 changed files with 21 additions and 8 deletions

View File

@@ -70,6 +70,9 @@ export const useDigitalHumanStore = defineStore('digitalHuman', () => {
/** 视频预览URL */
const videoPreviewUrl = ref('')
/** 素材库视频的签名URL用于识别API不用于播放 */
let signedVideoUrl = ''
/** 错误信息 */
const error = ref('')
@@ -278,7 +281,19 @@ export const useDigitalHumanStore = defineStore('digitalHuman', () => {
if (urlRes.code !== 0 || !urlRes.data) {
throw new Error(urlRes.msg || '获取播放链接失败')
}
videoPreviewUrl.value = urlRes.data
// 保存签名URL用于识别API
signedVideoUrl = urlRes.data
// 下载视频到本地生成blob URL确保浏览器能正常播放
videoStep.value = 'uploading'
const response = await fetch(urlRes.data)
if (!response.ok) throw new Error('视频下载失败')
const blob = await response.blob()
// 释放旧的blob URL
if (videoPreviewUrl.value?.startsWith('blob:')) {
URL.revokeObjectURL(videoPreviewUrl.value)
}
videoPreviewUrl.value = URL.createObjectURL(blob)
} catch (err: any) {
videoStep.value = 'error'
error.value = err.message || '获取播放链接失败'
@@ -350,8 +365,8 @@ export const useDigitalHumanStore = defineStore('digitalHuman', () => {
/** 识别已存在的视频 */
async function recognizeExistingVideo(video: Video): Promise<IdentifyData> {
// 使用已获取的带签名预览URL
return performFaceRecognition(video.id, videoPreviewUrl.value, false)
// 使用签名URL调用识别APIblob URL不可被外部API访问
return performFaceRecognition(video.id, signedVideoUrl, false)
}
/** 执行人脸识别 */
@@ -564,6 +579,7 @@ export const useDigitalHumanStore = defineStore('digitalHuman', () => {
videoFile.value = null
selectedVideo.value = null
videoPreviewUrl.value = ''
signedVideoUrl = ''
videoSelectorVisible.value = false
resetProcess()