|
|
@@ -52,31 +52,28 @@ public class VideoFileProcessor {
|
|
|
|
|
|
public UploadFileRet process(ObjectResult objectResult) {
|
|
|
String objectName = objectResult.getObjectName();
|
|
|
- String objectId = objectResult.getObjectId();
|
|
|
+ String videoFileId = objectResult.getObjectId();
|
|
|
boolean duplicate = objectResult.isDuplicate();
|
|
|
if (duplicate) {
|
|
|
String dupObjectId = objectResult.getDupObjectId();
|
|
|
- VideoFile videoFile = mediaRepository.findVideoFile(dupObjectId);
|
|
|
- boolean horizontal = videoFile.getHorizontal();
|
|
|
- int duration = videoFile.getDuration();
|
|
|
- VideoFile videoFile1 = new VideoFile(objectId, horizontal, duration);
|
|
|
-
|
|
|
VideoUrl videoUrl = mediaRepository.findVideoUrl(dupObjectId);
|
|
|
String urlType = videoUrl.getUrlType();
|
|
|
String quality = videoUrl.getQuality();
|
|
|
int width = videoUrl.getWidth();
|
|
|
int height = videoUrl.getHeight();
|
|
|
-
|
|
|
- String url = objectNameService.getObjectUrl(objectName);
|
|
|
- String objectName1 = objectNameService.getObjectNameFromUrl(url);
|
|
|
- ObjectResult objectResult1 = putObjectService.copyObject(objectName1, ".mp4");
|
|
|
+ String objectName1 = objectNameService.getObjectNameFromUrl(videoUrl.getUrl());
|
|
|
+ ObjectResult objectResult1 = putObjectService.copyObject(objectName1);
|
|
|
String objectId1 = objectResult1.getObjectId();
|
|
|
String url1 = objectNameService.getObjectUrl(objectName1);
|
|
|
+ VideoUrl videoUrl1 = new VideoUrl(videoFileId, objectId1, urlType, url1, quality, width, height);
|
|
|
|
|
|
- VideoUrl videoUrl1 = new VideoUrl(objectId, objectId1, urlType, url1, quality, width, height);
|
|
|
- mediaRepository.saveVideoFile(videoFile1, videoUrl1);
|
|
|
+ VideoFile videoFile = mediaRepository.findVideoFile(dupObjectId);
|
|
|
+ boolean horizontal = videoFile.getHorizontal();
|
|
|
+ int duration = videoFile.getDuration();
|
|
|
+ VideoFile videoFile1 = new VideoFile(videoFileId, horizontal, duration);
|
|
|
|
|
|
- return new UploadFileRet(objectId1, url1);
|
|
|
+ mediaRepository.saveVideoFile(videoFile1, videoUrl1);
|
|
|
+ return new UploadFileRet(videoFileId, url1);
|
|
|
}
|
|
|
|
|
|
String absolutePath = objectResult.getAbsolutePath();
|
|
|
@@ -96,7 +93,7 @@ public class VideoFileProcessor {
|
|
|
if (videoCodecs.contains(videoCodec)) {
|
|
|
AudioProps audioProps = mediaProps.getAudioProps();
|
|
|
if (audioProps != null && !audioCodecs.contains(audioProps.getCodecName())) {
|
|
|
- log.error("{} 对象的音频非 aac 编码, 暂不处理", objectName);
|
|
|
+ log.error("{} 对象的音频非 aac&mp3 编码, 暂不处理", objectName);
|
|
|
return null;
|
|
|
}
|
|
|
} else {
|
|
|
@@ -104,26 +101,22 @@ public class VideoFileProcessor {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- String videoFileId = objectId;
|
|
|
int width = videoProps.getCodedWidth().intValue();
|
|
|
int height = videoProps.getCodedHeight().intValue();
|
|
|
boolean horizontal = width>height;
|
|
|
int duration = videoProps.getDuration().intValue();
|
|
|
VideoFile videoFile = new VideoFile(videoFileId, horizontal, duration);
|
|
|
|
|
|
- MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
|
|
|
- String urlType = FileType.getVideoUrlType(absolutePath);
|
|
|
-
|
|
|
String originalObjectName = objectResult.getObjectName();
|
|
|
- ObjectResult objectResult1 = putObjectService.copyObject(originalObjectName, ".mp4");
|
|
|
+ ObjectResult objectResult1 = putObjectService.copyObject(originalObjectName);
|
|
|
String objectName1 = objectResult1.getObjectName();
|
|
|
String objectId1 = objectResult1.getObjectId();
|
|
|
String url1 = objectNameService.getObjectUrl(objectName1);
|
|
|
-
|
|
|
+ MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
|
|
|
+ String urlType = FileType.getVideoUrlType(absolutePath);
|
|
|
VideoUrl videoUrl = new VideoUrl(videoFileId, objectId1, urlType, url1, mediaResolution);;
|
|
|
mediaRepository.saveVideoFile(videoFile, videoUrl);
|
|
|
-
|
|
|
- return new UploadFileRet(objectId1, url1);
|
|
|
+ return new UploadFileRet(videoFileId, url1);
|
|
|
//log.info("添加视频格式转码任务");
|
|
|
//threadPool.submit(new ConvertTask());
|
|
|
}
|