feat: 优化
This commit is contained in:
@@ -119,11 +119,9 @@ public class BatchProduceAlignment {
|
||||
for (int i = 0; i < videoArray.length; i++) {
|
||||
String videoUrl = videoArray[i];
|
||||
|
||||
// 验证视频URL必须是阿里云OSS地址
|
||||
if (!videoUrl.contains(".aliyuncs.com")) {
|
||||
log.error("[ICE][视频URL不是阿里云OSS地址][视频{}: {}]", i + 1, videoUrl);
|
||||
throw new IllegalArgumentException("视频URL必须是阿里云OSS地址,当前URL: " + videoUrl);
|
||||
}
|
||||
// 将CDN URL转换为OSS原始URL(ICE需要原始域名)
|
||||
videoUrl = properties.convertToOssUrl(videoUrl);
|
||||
videoArray[i] = videoUrl; // 更新数组中的URL
|
||||
|
||||
log.debug("[ICE][添加视频片段][{}: {}]", i + 1, videoUrl);
|
||||
// 使用标准的 MediaURL 参数(符合 ICE API 文档规范)
|
||||
@@ -275,11 +273,9 @@ public class BatchProduceAlignment {
|
||||
String videoUrl = material.getFileUrl();
|
||||
int duration = material.getDuration();
|
||||
|
||||
// 验证视频URL必须是阿里云OSS地址
|
||||
if (!videoUrl.contains(".aliyuncs.com")) {
|
||||
log.error("[ICE][视频URL不是阿里云OSS地址][视频{}: {}]", i + 1, videoUrl);
|
||||
throw new IllegalArgumentException("视频URL必须是阿里云OSS地址,当前URL: " + videoUrl);
|
||||
}
|
||||
// 将CDN URL转换为OSS原始URL(ICE需要原始域名)
|
||||
videoUrl = properties.convertToOssUrl(videoUrl);
|
||||
material.setFileUrl(videoUrl); // 更新material中的URL
|
||||
|
||||
// 计算随机截取起点
|
||||
// 优先使用前端传入的素材实际时长,无则从0开始截取(兜底)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.tik.mix.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -13,8 +15,11 @@ import java.time.Duration;
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "yudao.ice")
|
||||
@RequiredArgsConstructor
|
||||
public class IceProperties {
|
||||
|
||||
private final FileApi fileApi;
|
||||
|
||||
/**
|
||||
* AccessKey ID
|
||||
*/
|
||||
@@ -60,4 +65,26 @@ public class IceProperties {
|
||||
public String getOssWriteUrl(String path) {
|
||||
return "https://" + bucket + ".oss-" + regionId + ".aliyuncs.com/" + path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将CDN URL转换为OSS原始URL(ICE需要原始域名才能访问)
|
||||
* CDN域名从数据库的文件配置中获取
|
||||
*/
|
||||
public String convertToOssUrl(String url) {
|
||||
if (StrUtil.isBlank(url)) {
|
||||
return url;
|
||||
}
|
||||
// 如果已经是OSS原始域名,直接返回
|
||||
if (url.contains(".aliyuncs.com")) {
|
||||
return url;
|
||||
}
|
||||
// 从数据库获取CDN域名
|
||||
String cdnDomain = fileApi.getMasterFileDomain();
|
||||
if (StrUtil.isBlank(cdnDomain)) {
|
||||
return url;
|
||||
}
|
||||
// 将CDN域名替换为OSS原始域名
|
||||
String ossDomain = "https://" + bucket + ".oss-" + regionId + ".aliyuncs.com";
|
||||
return url.replace(cdnDomain, ossDomain);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user