|
@@ -34,7 +34,7 @@ import java.util.concurrent.ExecutorService;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class VideoFileProcessor {
|
|
public class VideoFileProcessor {
|
|
|
- private VideoRepository videoRepository;
|
|
|
|
|
|
|
+ private final VideoRepository videoRepository;
|
|
|
private final PutObjectService putObjectService;
|
|
private final PutObjectService putObjectService;
|
|
|
private final ObjectNameService objectNameService;
|
|
private final ObjectNameService objectNameService;
|
|
|
private final FileStoreService fileStoreService;
|
|
private final FileStoreService fileStoreService;
|
|
@@ -69,6 +69,8 @@ public class VideoFileProcessor {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ String videoCodec = videoUrl.getVideoCodec();
|
|
|
|
|
+ String audioCodec = videoUrl.getAudioCodec();
|
|
|
String urlType = videoUrl.getUrlType();
|
|
String urlType = videoUrl.getUrlType();
|
|
|
String url = objectNameService.getObjectUrl(objectName);
|
|
String url = objectNameService.getObjectUrl(objectName);
|
|
|
long bitRate = videoUrl.getBitRate();
|
|
long bitRate = videoUrl.getBitRate();
|
|
@@ -76,7 +78,8 @@ public class VideoFileProcessor {
|
|
|
int width = videoUrl.getWidth();
|
|
int width = videoUrl.getWidth();
|
|
|
int height = videoUrl.getHeight();
|
|
int height = videoUrl.getHeight();
|
|
|
int order = 1;
|
|
int order = 1;
|
|
|
- VideoUrl videoUrl1 = new VideoUrl(videoFileId, videoFileId, urlType, url, bitRate, quality, width, height, order);
|
|
|
|
|
|
|
+ VideoUrl videoUrl1 = new VideoUrl(videoFileId, videoFileId, videoCodec, audioCodec,
|
|
|
|
|
+ urlType, url, bitRate, quality, width, height, order);
|
|
|
|
|
|
|
|
videoRepository.saveVideoFile(videoFile1, videoUrl1);
|
|
videoRepository.saveVideoFile(videoFile1, videoUrl1);
|
|
|
return new UploadFileRet(videoFileId, url, true);
|
|
return new UploadFileRet(videoFileId, url, true);
|
|
@@ -96,7 +99,13 @@ public class VideoFileProcessor {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String videoCodec = mediaProps.getVideoProps().getCodecName();
|
|
String videoCodec = mediaProps.getVideoProps().getCodecName();
|
|
|
- if (videoCodecs.contains(videoCodec)) {
|
|
|
|
|
|
|
+ String audioCodec = null;
|
|
|
|
|
+ AudioProps audioProps1 = mediaProps.getAudioProps();
|
|
|
|
|
+ if (audioProps1 != null) {
|
|
|
|
|
+ audioCodec = audioProps1.getCodecName();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*if (videoCodecs.contains(videoCodec)) {
|
|
|
AudioProps audioProps = mediaProps.getAudioProps();
|
|
AudioProps audioProps = mediaProps.getAudioProps();
|
|
|
if (audioProps != null && !audioCodecs.contains(audioProps.getCodecName())) {
|
|
if (audioProps != null && !audioCodecs.contains(audioProps.getCodecName())) {
|
|
|
log.error("{} 对象的音频非 aac&mp3 编码, 暂不处理", objectName);
|
|
log.error("{} 对象的音频非 aac&mp3 编码, 暂不处理", objectName);
|
|
@@ -105,8 +114,7 @@ public class VideoFileProcessor {
|
|
|
} else {
|
|
} else {
|
|
|
log.error("{} 对象的视频非 h264 编码, 暂不处理", objectName);
|
|
log.error("{} 对象的视频非 h264 编码, 暂不处理", objectName);
|
|
|
return null;
|
|
return null;
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }*/
|
|
|
int width = videoProps.getCodedWidth().intValue();
|
|
int width = videoProps.getCodedWidth().intValue();
|
|
|
int height = videoProps.getCodedHeight().intValue();
|
|
int height = videoProps.getCodedHeight().intValue();
|
|
|
boolean horizontal = width>height;
|
|
boolean horizontal = width>height;
|
|
@@ -114,18 +122,14 @@ public class VideoFileProcessor {
|
|
|
VideoFile videoFile = new VideoFile(videoFileId, horizontal, duration);
|
|
VideoFile videoFile = new VideoFile(videoFileId, horizontal, duration);
|
|
|
|
|
|
|
|
String originalUrl = objectNameService.getObjectUrl(objectName);
|
|
String originalUrl = objectNameService.getObjectUrl(objectName);
|
|
|
-
|
|
|
|
|
- /*ObjectResult objectResult1 = putObjectService.copyObject(originalObjectName);
|
|
|
|
|
- String objectName1 = objectResult1.getObjectName();
|
|
|
|
|
- String objectId1 = objectResult1.getObjectId();
|
|
|
|
|
- String url1 = objectNameService.getObjectUrl(objectName1);*/
|
|
|
|
|
-
|
|
|
|
|
long bitRate = videoProps.getBitRate();
|
|
long bitRate = videoProps.getBitRate();
|
|
|
MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
|
|
MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
|
|
|
String urlType = FileType.getVideoUrlType(absolutePath);
|
|
String urlType = FileType.getVideoUrlType(absolutePath);
|
|
|
- VideoUrl videoUrl = new VideoUrl(videoFileId, videoFileId, urlType, originalUrl, bitRate, mediaResolution);
|
|
|
|
|
|
|
+ VideoUrl videoUrl =
|
|
|
|
|
+ new VideoUrl(videoFileId, videoFileId, videoCodec, audioCodec, urlType, originalUrl, bitRate, mediaResolution);
|
|
|
videoRepository.saveVideoFile(videoFile, videoUrl);
|
|
videoRepository.saveVideoFile(videoFile, videoUrl);
|
|
|
return new UploadFileRet(videoFileId, originalUrl, true);
|
|
return new UploadFileRet(videoFileId, originalUrl, true);
|
|
|
|
|
+
|
|
|
//log.info("添加视频格式转码任务");
|
|
//log.info("添加视频格式转码任务");
|
|
|
//threadPool.submit(new ConvertTask());
|
|
//threadPool.submit(new ConvertTask());
|
|
|
}
|
|
}
|
|
@@ -152,11 +156,13 @@ public class VideoFileProcessor {
|
|
|
ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, originalFilename, sha256sum);
|
|
ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, originalFilename, sha256sum);
|
|
|
|
|
|
|
|
String objectId = objectResult.getObjectId();
|
|
String objectId = objectResult.getObjectId();
|
|
|
|
|
+ String videoCodec = "h264";
|
|
|
|
|
+ String audioCodec = "aac";
|
|
|
String url = objectNameService.getObjectUrl(objectResult.getObjectName());
|
|
String url = objectNameService.getObjectUrl(objectResult.getObjectName());
|
|
|
String urlType = FileType.getVideoUrlType(absolutePath);
|
|
String urlType = FileType.getVideoUrlType(absolutePath);
|
|
|
long bitRate = 0;
|
|
long bitRate = 0;
|
|
|
MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
|
|
MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
|
|
|
- return new VideoUrl(videoFileId, objectId, urlType, url, bitRate, mediaResolution);
|
|
|
|
|
|
|
+ return new VideoUrl(videoFileId, objectId, videoCodec, audioCodec, urlType, url, bitRate, mediaResolution);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|