| | |
| | | import cn.iocoder.yudao.module.digitalcourse.dal.mysql.coursemedia.CourseMediaMapper; |
| | | import cn.iocoder.yudao.module.digitalcourse.manager.MediaTaskManager; |
| | | import cn.iocoder.yudao.module.digitalcourse.model.MediaTask; |
| | | import cn.iocoder.yudao.module.infra.api.config.ConfigApi; |
| | | import com.alibaba.fastjson.JSON; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | |
| | |
| | | |
| | | @Override |
| | | public PageResult<CourseMediaDO> getCourseMediaPage(CourseMediaPageReqVO pageReqVO) { |
| | | return courseMediaMapper.selectPage(pageReqVO); |
| | | } |
| | | PageResult<CourseMediaDO> courseMediaDOPageResult = courseMediaMapper.selectPage(pageReqVO); |
| | | for (CourseMediaDO courseMediaDO : courseMediaDOPageResult.getList()) { |
| | | if (courseMediaDO.getStatus() == 1) { |
| | | //视频合成中 查询排队和合成进度 |
| | | Long id = courseMediaDO.getCourseId(); |
| | | int pos = mediaTaskManager.getQueuePosition(id); |
| | | if (pos == -1) { |
| | | //不在队列中,说明已经合成完成 |
| | | courseMediaDO.setStatus(3); |
| | | courseMediaMapper.updateById(courseMediaDO); |
| | | } |
| | | if (pos == 0) { |
| | | //正在合成中 |
| | | String reqJson = courseMediaDO.getReqJson(); |
| | | CourseMediaMegerVO courseMediaMegerVO = JSON.parseObject(reqJson, CourseMediaMegerVO.class); |
| | | int size = courseMediaMegerVO.getScenes().size(); |
| | | String s = configApi.getConfigValueByKey(HEYGEM_FACE2FACE) + "/temp/"; |
| | | //查询s下面的文件 |
| | | File folder = new File(s); |
| | | int count = 0; |
| | | |
| | | if (folder.exists() && folder.isDirectory()) { |
| | | File[] files = folder.listFiles(); |
| | | if (files != null) { |
| | | for (File file : files) { |
| | | if (file.isFile() && file.getName().endsWith("-r.mp4")) { |
| | | count++; |
| | | System.out.println("匹配文件: " + file.getName()); |
| | | } |
| | | } |
| | | } |
| | | System.out.println("总计匹配 -r.mp4 文件数量: " + count); |
| | | } else { |
| | | System.out.println("路径不存在或不是目录"); |
| | | } |
| | | if (count+1>size){ |
| | | courseMediaDO.setProgressVideo((count) + "/" + size); |
| | | }else{ |
| | | courseMediaDO.setProgressVideo((count+1)+"/"+size); |
| | | |
| | | } |
| | | } |
| | | courseMediaDO.setPos(pos); |
| | | } |
| | | |
| | | } |
| | | return courseMediaDOPageResult; |
| | | } |
| | | private static final String HEYGEM_FACE2FACE = "heygem.face2face"; |
| | | @Resource |
| | | private ConfigApi configApi; |
| | | @Override |
| | | public CommonResult megerMedia(CourseMediaMegerVO updateReqVO) { |
| | | Long id = updateReqVO.getId(); |