代码如下:
const file = document.getElementById("video1").files[0];
const reader = new FileReader();
reader.onload = function() {
const ok_video_base64 = this.result.split(",")[1];
that
.$axios({
url: `https://aip.baidubce.com/rest/2.0/face/v1/faceliveness/verify?access_token=${that.access_token}`,
data: `session_id=${that.session_id}&video_base64=${ok_video_base64}`,
method: "post",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
})
.then((res) => {
Indicator.close();
MessageBox({
title: "提示",
message: JSON.stringify(res),
});
if (res.data.error_code === 0) {
// console.log(res.data.result);
const score = res.data.result.score; // 活体分数
const thresholds = res.data.result.thresholds["frr_1e-3"]; // 活体阈值
const similarity = res.data.result.code.similarity; // 语音相似度
const condition1 = score > thresholds; // 合格条件1:活体分数大于阈值,合格
const condition2 = similarity > 0.75; // 合格条件2:语音相似度大于0.75,合格
if (condition1 && condition2) {
const pic = res.data.result.pic_list[0].pic;
upLoadImg(
null,
pic,
"renLian",
(imgUrl) => {
CusToast("人脸识别成功");
this.$store.commit("setLivingFaceImg", imgUrl);
},
() => {
CusToast("上传失败");
},
0
);
} else {
if (!condition1) {
MessageBox({
title: "提示",
message: `分数:${score},阈值:${thresholds},分数小于阈值,不合格,请重新录制视频`,
});
}
if (!condition2) {
MessageBox({
title: "提示",
message: `语音相似度:${similarity},小于0.75,不合格,请重新录制视频`,
}).then(() => that.getBaiduSessionCode());
}
}
} else {
that.showFaceFailInfo(res.data.error_code);
}
})
https://blog.csdn.net/ligongke513/article/details/116231794
从前台获取mp4文件是vp8格式的,这个前台暂时不知道是否能转为h264, 当然可以上传到服务器,用ffmpeg ,视频转码h264,音频转码为aac,再转base64。
您好,请问这个问题解决了吗
好的,多谢
视频解析服务发生错误
可能是你页面的视频有问题。或者是接口服务视频解析服务有问题。
建议提交工单让百度技术排查一下