|
|
|
@ -31,21 +31,10 @@ public class JmText2Video extends JmCommon {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
String prompt = "蓝色毛绒玩具在超市里拖地,结果拖把洒出好多五颜六色的粉末,接着把粉末洒向镜头前,镜头随之穿过粉末";
|
|
|
|
|
//String prompt = "蓝色毛绒玩具在超市里拖地,结果拖把洒出好多五颜六色的粉末,接着把粉末洒向镜头前,镜头随之穿过粉末";
|
|
|
|
|
String prompt="第一个镜头-全景:身穿宇航服的狗狗左右环顾第二个镜头-近景:宇航员狗狗向操作台走去第三个镜头-特写:宇航员狗狗伸手去按操作界";
|
|
|
|
|
//保存的文件名称
|
|
|
|
|
String mp4FileName = "1.mp4";
|
|
|
|
|
|
|
|
|
|
// 获取项目根目录路径
|
|
|
|
|
String projectRoot = System.getProperty("user.dir");
|
|
|
|
|
// 拼接相对路径
|
|
|
|
|
String basePath = projectRoot + "/src/main/java/com/dsideal/aiSupport/Util/JiMeng/Example/";
|
|
|
|
|
|
|
|
|
|
// 确保目录存在
|
|
|
|
|
java.io.File dir = new java.io.File(basePath);
|
|
|
|
|
if (!dir.exists()) {
|
|
|
|
|
dir.mkdirs();
|
|
|
|
|
log.info("创建目录: {}", basePath);
|
|
|
|
|
}
|
|
|
|
|
String mp4FileName = "Text2Video.mp4";
|
|
|
|
|
|
|
|
|
|
// 添加重试逻辑,处理API并发限制错误
|
|
|
|
|
JSONObject jo = null;
|
|
|
|
@ -68,7 +57,6 @@ public class JmText2Video extends JmCommon {
|
|
|
|
|
log.error("生成视频失败: 错误码={}, 错误信息={}", code, JmErrorCode.getMessageByCode(code));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 成功获取结果,跳出循环
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -93,7 +81,7 @@ public class JmText2Video extends JmCommon {
|
|
|
|
|
|
|
|
|
|
//检查任务是不是已经结束
|
|
|
|
|
int retryCount = 0;
|
|
|
|
|
int maxRetries = 30; // 最大重试次数
|
|
|
|
|
int maxRetries = 1000; // 最大重试次数
|
|
|
|
|
int retryInterval = 3000; // 重试间隔(毫秒)
|
|
|
|
|
|
|
|
|
|
while (retryCount < maxRetries) {
|
|
|
|
|