This commit is contained in:
2025-01-02 15:12:20 +08:00
parent c000eb2700
commit 1923a5c438
10 changed files with 132 additions and 22 deletions

View File

@ -53,7 +53,6 @@ public class VideoPieceGetter {
public static class Task {
public String type = "normal";
public Long faceSampleId;
public Date createTime;
public Callback callback;
public Long memberId;
public Long faceId;
@ -127,14 +126,14 @@ public class VideoPieceGetter {
}
BigDecimal duration = cutPre.add(cutPost);
List<FileObject> listByDtRange = pieceGetter.getFileListByDtRange(
new Date(task.getCreateTime().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue()),
new Date(task.getCreateTime().getTime() + cutPost.multiply(BigDecimal.valueOf(1000)).longValue())
new Date(faceSample.getCreateAt().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue()),
new Date(faceSample.getCreateAt().getTime() + cutPost.multiply(BigDecimal.valueOf(1000)).longValue())
);
if (listByDtRange.isEmpty()) {
log.warn("没有可用的文件");
return;
}
long offset = task.getCreateTime().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue() - listByDtRange.get(0).getCreateTime().getTime();
long offset = faceSample.getCreateAt().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue() - listByDtRange.get(0).getCreateTime().getTime();
FfmpegTask ffmpegTask = new FfmpegTask();
ffmpegTask.setFileList(listByDtRange);
ffmpegTask.setDuration(duration);
@ -149,9 +148,12 @@ public class VideoPieceGetter {
log.info("视频裁切成功");
IStorageAdapter adapter = StorageFactory.use("assets");
String url = adapter.uploadFile(outFile, "video-source", outFile.getName());
// 上传成功后删除文件
outFile.delete();
SourceEntity imgSource = sourceMapper.findBySampleId(faceSample.getId());
SourceEntity sourceEntity = new SourceEntity();
sourceEntity.setId(SnowFlakeUtil.getLongId());
sourceEntity.setCreateTime(faceSample.getCreateAt());
MemberSourceEntity videoSource = new MemberSourceEntity();
videoSource.setMemberId(task.getMemberId());
videoSource.setType(1);