|
|
@@ -199,6 +199,8 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
@Async |
|
|
|
@Override |
|
|
|
public ResultData createVideo(PhotoSpeakVideo photoSpeakVideo) { |
|
|
|
PhotoSpeakVideo speakVideoUpd = new PhotoSpeakVideo(); |
|
|
|
speakVideoUpd.setId(photoSpeakVideo.getId()); |
|
|
|
try { |
|
|
|
AiPhotoSpeakParam param = new AiPhotoSpeakParam(); |
|
|
|
param.setTask_id(photoSpeakVideo.getId()); |
|
|
@@ -242,27 +244,27 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
try { |
|
|
|
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); |
|
|
|
if (video.isSuccess()) { |
|
|
|
photoSpeakVideo.setSaveDir(video.getSaveDir()); |
|
|
|
photoSpeakVideo.setAudioPath(video.getAudioPath()); |
|
|
|
photoSpeakVideo.setVideoPath(video.getUrl()); |
|
|
|
this.updateById(photoSpeakVideo); |
|
|
|
// speakVideoUpd.setSaveDir(video.getSaveDir()); |
|
|
|
// speakVideoUpd.setAudioPath(video.getAudioPath()); |
|
|
|
// speakVideoUpd.setVideoPath(video.getUrl()); |
|
|
|
// this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
photoSpeakVideo.setVideoMsg(video.getMsg()); |
|
|
|
this.updateById(photoSpeakVideo); |
|
|
|
speakVideoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
speakVideoUpd.setVideoMsg(video.getMsg()); |
|
|
|
this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), video.getMsg()); |
|
|
|
}catch (Exception e){ |
|
|
|
photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
photoSpeakVideo.setVideoMsg("Meta接口请求异常"); |
|
|
|
this.updateById(photoSpeakVideo); |
|
|
|
speakVideoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
speakVideoUpd.setVideoMsg("Meta接口请求异常"); |
|
|
|
this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"Meta接口请求异常"); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
photoSpeakVideo.setVideoMsg("接口请求异常"); |
|
|
|
this.updateById(photoSpeakVideo); |
|
|
|
speakVideoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
speakVideoUpd.setVideoMsg("接口请求异常"); |
|
|
|
this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"生成视频失败"); |
|
|
|
} |
|
|
|
} |
|
|
@@ -271,8 +273,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
@Async |
|
|
|
@Override |
|
|
|
public void uploadVideo(PhotoSpeakVideo mouldVideo){ |
|
|
|
if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) |
|
|
|
|| EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoStatus())){ |
|
|
|
if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus())){ |
|
|
|
String url1 = url + mouldVideo.getVideoPath(); |
|
|
|
VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url1); |
|
|
|
if(result.isSuccess()){ |
|
|
@@ -280,40 +281,38 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
videoUpd.setId(mouldVideo.getId()); |
|
|
|
videoUpd.setVideoId(result.getVideoId()); |
|
|
|
videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); |
|
|
|
videoUpd.setUpdateDate(new Date()); |
|
|
|
this.saveOrUpdate(videoUpd); |
|
|
|
|
|
|
|
AtomicInteger integer = new AtomicInteger(30); |
|
|
|
while (true){ |
|
|
|
PhotoSpeakVideo videoUrlUpd = new PhotoSpeakVideo(); |
|
|
|
videoUrlUpd.setId(mouldVideo.getId()); |
|
|
|
for (int i = 0;i <= 30; i++){ |
|
|
|
try { |
|
|
|
String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); |
|
|
|
Thread.sleep(1000); |
|
|
|
if (StringUtils.isNotEmpty(progress) && progress.equals("complete")) { |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId(),true); |
|
|
|
if (videoDetail.isSuccess() |
|
|
|
&& StringUtils.isNotBlank(videoDetail.getDuration()) |
|
|
|
&& !"0.0".equals(videoDetail.getDuration())) { |
|
|
|
mouldVideo.setCoverImg(videoDetail.getCoverURL()); |
|
|
|
mouldVideo.setVideoPlayUrl(videoDetail.getVideoUrl()); |
|
|
|
mouldVideo.setVideoTime(videoDetail.getDuration()); |
|
|
|
mouldVideo.setVideoSize(videoDetail.getSize()); |
|
|
|
mouldVideo.setVideoStatus(EnumVideoStatus.upload_success.getCode()); |
|
|
|
this.updateById(mouldVideo); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (integer.getAndDecrement() <= 0){ |
|
|
|
mouldVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); |
|
|
|
this.updateById(mouldVideo); |
|
|
|
break; |
|
|
|
} |
|
|
|
Thread.sleep(2000); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
mouldVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); |
|
|
|
this.updateById(mouldVideo); |
|
|
|
} |
|
|
|
String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); |
|
|
|
if (progress.equals("complete")) { |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId(),true); |
|
|
|
if (videoDetail.isSuccess()){ |
|
|
|
videoUrlUpd.setCoverImg(videoDetail.getCoverURL()); |
|
|
|
videoUrlUpd.setVideoPlayUrl(videoDetail.getVideoUrl()); |
|
|
|
videoUrlUpd.setVideoTime(videoDetail.getDuration()); |
|
|
|
videoUrlUpd.setVideoSize(videoDetail.getSize()); |
|
|
|
videoUrlUpd.setVideoStatus(EnumVideoStatus.upload_success.getCode()); |
|
|
|
videoUrlUpd.setVideoMsg("视频上传成功"); |
|
|
|
videoUrlUpd.setUpdateDate(new Date()); |
|
|
|
this.updateById(videoUrlUpd); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(videoUrlUpd.getVideoStatus() == null){ |
|
|
|
videoUrlUpd.setVideoStatus(EnumVideoStatus.upload_fail.getCode()); |
|
|
|
videoUrlUpd.setVideoMsg("视频上传超时"); |
|
|
|
videoUrlUpd.setUpdateDate(new Date()); |
|
|
|
this.updateById(videoUrlUpd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -358,6 +357,8 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
@Override |
|
|
|
@Async |
|
|
|
public ResultData videoHy(PhotoSpeakVideo speakVideo) { |
|
|
|
PhotoSpeakVideo speakVideoUpd = new PhotoSpeakVideo(); |
|
|
|
speakVideoUpd.setId(speakVideo.getId()); |
|
|
|
try { |
|
|
|
AiVideoHqParam param = new AiVideoHqParam(); |
|
|
|
param.setSave_dir(speakVideo.getSaveDir()); |
|
|
@@ -367,31 +368,31 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
try { |
|
|
|
AiVideoHqResult result = AiVideoHelper.videoHq(param); |
|
|
|
if (result.isSuccess()) { |
|
|
|
speakVideo.setVideoStatus(EnumVideoStatus.hy_success.getCode()); |
|
|
|
speakVideo.setVideoMsg("超分视频生成成功"); |
|
|
|
speakVideo.setVideoPath(result.getUrl()); |
|
|
|
this.updateById(speakVideo); |
|
|
|
// speakVideoUpd.setVideoStatus(EnumVideoStatus.hy_success.getCode()); |
|
|
|
// speakVideoUpd.setVideoMsg("超分视频生成成功"); |
|
|
|
// speakVideoUpd.setVideoPath(result.getUrl()); |
|
|
|
// this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
speakVideo.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
speakVideo.setVideoMsg("Mata视频超分失败"); |
|
|
|
speakVideo.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
this.updateById(speakVideo); |
|
|
|
speakVideoUpd.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
speakVideoUpd.setVideoMsg("Mata视频超分失败"); |
|
|
|
speakVideoUpd.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(result.getCode(), result.getMsgInfo(result.getCode(),result.getMsg())); |
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
speakVideo.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
speakVideo.setVideoMsg("Mata视频超分失败"); |
|
|
|
speakVideo.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
this.updateById(speakVideo); |
|
|
|
speakVideoUpd.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
speakVideoUpd.setVideoMsg("Mata视频超分失败"); |
|
|
|
speakVideoUpd.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"Meta接口请求异常"); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
speakVideo.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
speakVideo.setVideoMsg("超分视频接口请求异常"); |
|
|
|
speakVideo.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
this.updateById(speakVideo); |
|
|
|
speakVideoUpd.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
speakVideoUpd.setVideoMsg("超分视频接口请求异常"); |
|
|
|
speakVideoUpd.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
this.updateById(speakVideoUpd); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "超分视频接口请求异常"); |
|
|
|
} |
|
|
|
} |
|
|
@@ -399,8 +400,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
@Async |
|
|
|
@Override |
|
|
|
public void uploadHyVideo(PhotoSpeakVideo mouldVideo){ |
|
|
|
if(EnumVideoStatus.hy_success.getCode().equals(mouldVideo.getVideoStatus()) |
|
|
|
|| EnumVideoStatus.hy_upload_fail.getCode().equals(mouldVideo.getVideoStatus())){ |
|
|
|
if(EnumVideoStatus.hy_success.getCode().equals(mouldVideo.getVideoStatus())){ |
|
|
|
String url = hy_url + mouldVideo.getVideoPath(); |
|
|
|
VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); |
|
|
|
if(result.isSuccess()){ |
|
|
@@ -408,42 +408,38 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
videoUpd.setId(mouldVideo.getId()); |
|
|
|
videoUpd.setVideoId(result.getVideoId()); |
|
|
|
videoUpd.setVideoStatus(EnumVideoStatus.hy_upload_ing.getCode()); |
|
|
|
videoUpd.setUpdateDate(new Date()); |
|
|
|
this.saveOrUpdate(videoUpd); |
|
|
|
|
|
|
|
AtomicInteger integer = new AtomicInteger(30); |
|
|
|
while (true){ |
|
|
|
PhotoSpeakVideo videoUrlUpd = new PhotoSpeakVideo(); |
|
|
|
videoUrlUpd.setId(mouldVideo.getId()); |
|
|
|
for (int i = 0;i <= 30; i++){ |
|
|
|
try { |
|
|
|
String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); |
|
|
|
Thread.sleep(1000); |
|
|
|
if (progress.equals("complete")) { |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId(),true); |
|
|
|
if (videoDetail.isSuccess() |
|
|
|
&& StringUtils.isNotBlank(videoDetail.getDuration()) |
|
|
|
&& !"0.0".equals(videoDetail.getDuration())) { |
|
|
|
mouldVideo.setCoverImg(videoDetail.getCoverURL()); |
|
|
|
mouldVideo.setVideoPlayUrl(videoDetail.getVideoUrl()); |
|
|
|
mouldVideo.setVideoTime(videoDetail.getDuration()); |
|
|
|
mouldVideo.setVideoSize(videoDetail.getSize()); |
|
|
|
mouldVideo.setVideoStatus(EnumVideoStatus.hy_upload_success.getCode()); |
|
|
|
this.updateById(mouldVideo); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (integer.getAndDecrement() <= 0){ |
|
|
|
mouldVideo.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
mouldVideo.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); |
|
|
|
this.updateById(mouldVideo); |
|
|
|
break; |
|
|
|
} |
|
|
|
Thread.sleep(2000); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
mouldVideo.setVideoStatus(EnumVideoStatus.hy_fail.getCode()); |
|
|
|
mouldVideo.setIsHy(EnumYesOrNo.NO.getCode()); |
|
|
|
mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); |
|
|
|
this.updateById(mouldVideo); |
|
|
|
} |
|
|
|
String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); |
|
|
|
if (progress.equals("complete")) { |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId(),true); |
|
|
|
if (videoDetail.isSuccess()){ |
|
|
|
videoUrlUpd.setCoverImg(videoDetail.getCoverURL()); |
|
|
|
videoUrlUpd.setVideoPlayUrl(videoDetail.getVideoUrl()); |
|
|
|
videoUrlUpd.setVideoTime(videoDetail.getDuration()); |
|
|
|
videoUrlUpd.setVideoSize(videoDetail.getSize()); |
|
|
|
videoUrlUpd.setVideoStatus(EnumVideoStatus.hy_upload_success.getCode()); |
|
|
|
videoUrlUpd.setVideoMsg("视频上传成功"); |
|
|
|
videoUrlUpd.setUpdateDate(new Date()); |
|
|
|
this.updateById(videoUrlUpd); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(videoUrlUpd.getVideoStatus() == null){ |
|
|
|
videoUrlUpd.setVideoStatus(EnumVideoStatus.hy_upload_fail.getCode()); |
|
|
|
videoUrlUpd.setVideoMsg("视频上传超时"); |
|
|
|
videoUrlUpd.setUpdateDate(new Date()); |
|
|
|
this.updateById(videoUrlUpd); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|