| @@ -0,0 +1,5 @@ | |||||
| ALTER TABLE `mallink_suimang_test`.`photo_speak_video` | |||||
| ADD COLUMN `video_hy_status` smallint NULL COMMENT '视频超分状态' AFTER `video_status`; | |||||
| ALTER TABLE `mallink_suimang_test`.`voice_info` | |||||
| ADD COLUMN `age_type` smallint NULL COMMENT '年纪类型 EnumAgeType' AFTER `sex`; | |||||
| @@ -363,4 +363,47 @@ public class PhotoSpeakVideoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("视频超分") | |||||
| @GetMapping("/videoHy") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData videoHy(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] PersonPhotoController::videoHy"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数为空"); | |||||
| } | |||||
| PhotoSpeakVideo speakVideo = photoSpeakVideoService.getById(id); | |||||
| if(speakVideo == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到数据"); | |||||
| } | |||||
| if (StringUtils.isEmpty(speakVideo.getSaveDir())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"save_dir为空"); | |||||
| } | |||||
| if(!speakVideo.getUserId().equals(getMemberId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到用户数据"); | |||||
| } | |||||
| if(!EnumVideoStatus.upload_success.getCode().equals(speakVideo.getVideoStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"原始视频生成未完成"); | |||||
| } | |||||
| if(EnumVideoStatus.ing.getCode().equals(speakVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.success.getCode().equals(speakVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.upload_ing.getCode().equals(speakVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.upload_fail.getCode().equals(speakVideo.getVideoHyStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"高清晰度视频生成中"); | |||||
| } | |||||
| if(EnumVideoStatus.upload_success.getCode().equals(speakVideo.getVideoHyStatus())){ | |||||
| //上传阿里云状态 生成成功 | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"高清晰度视频已生成完成"); | |||||
| } | |||||
| speakVideo.setVideoStatus(EnumVideoStatus.ing.getCode()); | |||||
| speakVideo.setVideoMsg(""); | |||||
| speakVideo.setUpdateDate(new Date()); | |||||
| photoSpeakVideoService.updateById(speakVideo); | |||||
| photoSpeakVideoService.videoHy(speakVideo,true); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | } | ||||
| @@ -109,4 +109,52 @@ public class PhotoSpeakSchedule { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 获取超分时长和大小 | |||||
| */ | |||||
| @Scheduled(cron = "0 1/5 * * * *?") // 每五分钟检查一次 | |||||
| public void userVideoHyDetailSchedule() { | |||||
| List<PhotoSpeakVideo> videos = photoSpeakVideoService.getUpLoadHyIngList(); | |||||
| if (videos != null && videos.size() > 0) { | |||||
| for (PhotoSpeakVideo video : videos) { | |||||
| try { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(video.getVideoId()); | |||||
| if (videoDetail.isSuccess() | |||||
| && StringUtils.isNotBlank(videoDetail.getDuration()) | |||||
| && !"0.0".equals(videoDetail.getDuration())) { | |||||
| video.setCoverImg(videoDetail.getCoverURL()); | |||||
| video.setVideoPlayUrl(videoDetail.getVideoUrl()); | |||||
| video.setVideoTime(videoDetail.getDuration()); | |||||
| video.setVideoSize(videoDetail.getSize()); | |||||
| video.setVideoHyStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| photoSpeakVideoService.updateById(video); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 超分生成视频 | |||||
| */ | |||||
| @Scheduled(cron = "0 20/30 * * * *?") // 每半小时检查一次 | |||||
| public void photoSpeakCreateHySchedule() { | |||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||||
| videoUpd.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date())); | |||||
| videoUpd.setVideoHyStatus(EnumVideoStatus.fail.getCode()); | |||||
| List<PhotoSpeakVideo> list = photoSpeakVideoService.findList(videoUpd); | |||||
| if (list != null && list.size() > 0) { | |||||
| for (PhotoSpeakVideo video : list) { | |||||
| try { | |||||
| photoSpeakVideoService.videoHy(video,false); | |||||
| } catch (Exception e) { | |||||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -154,5 +154,7 @@ public class PhotoSpeakVideo extends TenantEntity { | |||||
| private Long musicId; | private Long musicId; | ||||
| private String saveDir; | private String saveDir; | ||||
| private Integer videoHyStatus; | |||||
| } | } | ||||
| @@ -73,4 +73,8 @@ public class VoiceInfo extends TenantEntity { | |||||
| * 是否删除1是0否 | * 是否删除1是0否 | ||||
| */ | */ | ||||
| private Integer isDel; | private Integer isDel; | ||||
| /** | |||||
| * 年纪类型 EnumAgeType | |||||
| */ | |||||
| private Integer ageType; | |||||
| } | } | ||||
| @@ -59,4 +59,10 @@ public interface PhotoSpeakVideoService { | |||||
| int updateById(PhotoSpeakVideo video); | int updateById(PhotoSpeakVideo video); | ||||
| void videoHy(PhotoSpeakVideo speakVideo,Boolean flag); | |||||
| void uploadHyVideo(PhotoSpeakVideo mouldVideo); | |||||
| List<PhotoSpeakVideo> getUpLoadHyIngList(); | |||||
| } | } | ||||
| @@ -491,4 +491,44 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| return photoSpeakVideoMapper.updateById(video); | return photoSpeakVideoMapper.updateById(video); | ||||
| } | } | ||||
| @Override | |||||
| public void videoHy(PhotoSpeakVideo speakVideo,Boolean flag) { | |||||
| AiVideoHqParam param = new AiVideoHqParam(); | |||||
| param.setSave_dir(speakVideo.getSaveDir()); | |||||
| AiVideoHqResult result = AiVideoHelper.videoHq(param); | |||||
| if(result.isSuccess()){ | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.success.getCode()); | |||||
| speakVideo.setVideoMsg("超分视频生成成功"); | |||||
| this.updateById(speakVideo); | |||||
| this.uploadHyVideo(speakVideo); | |||||
| } | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.fail.getCode()); | |||||
| speakVideo.setVideoMsg("超分视频失败"); | |||||
| this.updateById(speakVideo); | |||||
| } | |||||
| @Override | |||||
| public void uploadHyVideo(PhotoSpeakVideo mouldVideo){ | |||||
| if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoHyStatus())){ | |||||
| String url = mouldVideo.getPhotoSpeakPathUri() + mouldVideo.getVideoPath(); | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | |||||
| if(result.isSuccess()){ | |||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||||
| videoUpd.setId(mouldVideo.getId()); | |||||
| videoUpd.setVideoId(result.getVideoId()); | |||||
| videoUpd.setVideoHyStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
| this.saveOrUpdate(videoUpd); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public List<PhotoSpeakVideo> getUpLoadHyIngList() { | |||||
| PhotoSpeakVideo umVideoQ = new PhotoSpeakVideo(); | |||||
| umVideoQ.setVideoHyStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
| return photoSpeakVideoMapper.getSortList(umVideoQ); | |||||
| } | |||||
| } | } | ||||
| @@ -42,6 +42,7 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
| x.setStyle(list); | x.setStyle(list); | ||||
| } else { | } else { | ||||
| x.setStyle(Lists.newArrayList()); | x.setStyle(Lists.newArrayList()); | ||||
| } | } | ||||
| }); | }); | ||||
| return voiceInfos; | return voiceInfos; | ||||
| @@ -301,7 +301,7 @@ public class AiVideoHelper { | |||||
| // AiVideoHqParam param = new AiVideoHqParam(); | // AiVideoHqParam param = new AiVideoHqParam(); | ||||
| // param.setSave_dir(); | // param.setSave_dir(); | ||||
| // AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||||
| // AiVideoHqResult result = AiVideoHelper.videoHq(param); | |||||
| // System.out.println(result); | // System.out.println(result); | ||||
| } | } | ||||