Skip to content

Commit

Permalink
fix: 인코딩 이전에 해상도 짝수 여부 확인
Browse files Browse the repository at this point in the history
  • Loading branch information
SJ70 committed Oct 12, 2024
1 parent 9edca17 commit aad2534
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/j9/bestmoments/service/FfmpegService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.j9.bestmoments.service;

import jakarta.persistence.criteria.CriteriaBuilder.In;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -18,6 +19,17 @@ public class FfmpegService {
@Async
public void encodeVideo(String inputFilePath, String outputFilePath, String resolution) {
try {
// 해상도가 홀수인 경우 조정
int width = Integer.parseInt(resolution.split("x")[0]);
int height = Integer.parseInt(resolution.split("x")[0]);
if (width % 2 == 1) {
width++;
}
if (height % 2 == 1) {
height++;
}
resolution = width + "x" + height;

ProcessBuilder processBuilder = new ProcessBuilder(
ffmpegPath, "-i", inputFilePath, "-s", resolution, "-codec:v", "libx264", outputFilePath
);
Expand Down

0 comments on commit aad2534

Please sign in to comment.