From aad253463e29eb3e62de8b4cb5d668d0ee591782 Mon Sep 17 00:00:00 2001 From: SJ70 Date: Sat, 12 Oct 2024 20:32:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9D=B8=EC=BD=94=EB=94=A9=20=EC=9D=B4?= =?UTF-8?q?=EC=A0=84=EC=97=90=20=ED=95=B4=EC=83=81=EB=8F=84=20=EC=A7=9D?= =?UTF-8?q?=EC=88=98=20=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/j9/bestmoments/service/FfmpegService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/j9/bestmoments/service/FfmpegService.java b/src/main/java/com/j9/bestmoments/service/FfmpegService.java index c9f8213..391c82e 100644 --- a/src/main/java/com/j9/bestmoments/service/FfmpegService.java +++ b/src/main/java/com/j9/bestmoments/service/FfmpegService.java @@ -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; @@ -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 );