Skip to content

Commit

Permalink
test: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jamebal committed Apr 30, 2024
1 parent 424df12 commit 1ebe8a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,9 @@ private static void setMusic(File file, Update update) {
}

private void setMediaCover(String fileId, String username, String fileName, String relativePath, Update update) {
log.info("setMediaCover:{}", fileName);
String coverPath = videoProcessService.getVideoCover(fileId, username, relativePath, fileName);
log.info("coverPath:{}", coverPath);
if (!CharSequenceUtil.isBlank(coverPath)) {
if (update == null) {
update = new Update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public void uploadChunkFile(UploadApiParamDTO upload, UploadResponse uploadRespo
*/
public UploadResponse mergeFile(UploadApiParamDTO upload) throws IOException {
UploadResponse uploadResponse = new UploadResponse();
log.info("合并文件1: {}", upload.getFilename());
Path prePth = Paths.get(upload.getUsername(), upload.getCurrentDirectory(), upload.getFilename());
String ossPath = CaffeineUtil.getOssPath(prePth);
if (ossPath != null) {
Expand All @@ -119,9 +118,7 @@ public UploadResponse mergeFile(UploadApiParamDTO upload) throws IOException {
}
PathUtil.move(file, outputFile, true);
uploadResponse.setUpload(true);
log.info("合并文件2: {}", outputFile);
commonFileService.createFile(upload.getUsername(), outputFile.toFile(), null, null);
log.info("合并文件3: {}", upload.getFilename());
return uploadResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public String getVideoCover(String fileId, String username, String relativePath,
private static ProcessBuilder getVideoCoverProcessBuilder(String videoPath, String outputPath, double videoDuration) {
double targetTimestamp = videoDuration * 0.1;
String formattedTimestamp = formatTimestamp(targetTimestamp);
log.info("formattedTimestamp: {}", formattedTimestamp);
log.info("\r\n videoPath: {}, formattedTimestamp: {}", videoPath, formattedTimestamp);
ProcessBuilder processBuilder = new ProcessBuilder(
Constants.FFMPEG,
"-ss", formattedTimestamp,
Expand All @@ -183,7 +183,7 @@ private static String formatTimestamp(double timestamp) {
* 获取视频文件缓存目录
*
* @param username username
* @param fileId fileId
* @param fileId fileId
* @return 视频文件缓存目录
*/
private String getVideoCacheDir(String username, String fileId) {
Expand Down Expand Up @@ -341,6 +341,7 @@ private boolean checkNVENC() {

/**
* 判断是否需要转码
*
* @param videoInfo 视频信息
* @return 是否需要转码
*/
Expand All @@ -353,6 +354,7 @@ private boolean needTranscode(VideoInfo videoInfo) {

/**
* 判断视频格式是否为HTML5 Video Player支持的格式
*
* @param format 视频格式
* @return 是否支持
*/
Expand Down Expand Up @@ -422,6 +424,7 @@ private static void printErrorInfo(ProcessBuilder processBuilder) {

/**
* 获取视频的分辨率和码率信息
*
* @param videoPath 视频路径
* @return 视频信息
*/
Expand Down Expand Up @@ -449,7 +452,7 @@ private VideoInfo getVideoInfo(String videoPath) {
int width = streamObject.getIntValue("width");
int height = streamObject.getIntValue("height");
int bitrate = streamObject.getIntValue("bit_rate") / 1000; // 转换为 kbps
return new VideoInfo(width, height, format, bitrate, duration);
return new VideoInfo(videoPath, width, height, format, bitrate, duration);
}
}

Expand All @@ -471,20 +474,22 @@ private static class VideoInfo {
private int bitrate;
private String format;
private double duration;

public VideoInfo() {
this.width = 1920;
this.height = 1080;
this.format = "mov,mp4,m4a,3gp,3g2,mj2";
this.bitrate = 3000;
this.duration = 10d;
}
public VideoInfo(int width, int height, String format, int bitrate, double duration) {

public VideoInfo(String videoPath, int width, int height, String format, int bitrate, double duration) {
this.width = width;
this.height = height;
this.format = format;
this.bitrate = bitrate;
this.duration = duration;
log.info("width: {}, height: {}, format: {}, bitrate: {}, duration: {}", width, height, format, bitrate, duration);
log.info("\r\n videoPath: {}, width: {}, height: {}, format: {}, bitrate: {}, duration: {}", videoPath, width, height, format, bitrate, duration);
}
}

Expand Down

0 comments on commit 1ebe8a9

Please sign in to comment.