- 前端:新增签名URL存储,将视频下载为blob URL确保浏览器兼容播放 - 后端:移除视频/音频播放URL的Content-Type参数,简化签名URL生成逻辑 - 修复:使用签名URL调用人脸识别API,避免blob URL无法被外部API访问的问题
This commit is contained in:
@@ -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调用识别API(blob 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()
|
||||
|
||||
Reference in New Issue
Block a user