Skip to content

Commit

Permalink
feat: add debug option for every ffmpeg commend
Browse files Browse the repository at this point in the history
  • Loading branch information
gmkim20713 committed Nov 4, 2024
1 parent 461626b commit 485a219
Showing 1 changed file with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private Mono<String> generateRecapFrame(String recapId, String memberName, Strin
String recapCreatedDate = DateTimeFormatter.ofPattern("yyyy.MM.dd").format(LocalDate.now());

FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-loglevel", "debug")
.addExtraArgs(
"-filter_complex",
String.format(
Expand Down Expand Up @@ -107,29 +108,38 @@ private Mono<String> generateRecapFrame(String recapId, String memberName, Strin
private Mono<Void> generateRecapPhotos(List<String> downloadedPath, String recapId) {

return Mono.fromRunnable(() -> {

FFmpegBuilder builder = new FFmpegBuilder()
try {
FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-loglevel", "debug")
.addInput(recapProperties.getFrameFilePath(recapId));

for (String path : downloadedPath) {
builder.addInput(path);
}
for (String path : downloadedPath) {
builder.addInput(path);
}

StringBuilder filterComplex = new StringBuilder();
StringBuilder filterComplex = new StringBuilder();

for (int inputIndex = 1; inputIndex <= downloadedPath.size(); inputIndex++) {
filterComplex.append(String.format("[%d]scale='min(1200,iw)':'min(1776,ih)':force_original_aspect_ratio=decrease[photo_scaled_%d]; ", inputIndex, inputIndex));
filterComplex.append(String.format("[recap_bg][photo_scaled_%d]overlay=(W-w)/2:(H-h)/2+80[final%d];", inputIndex, inputIndex));
}
for (int inputIndex = 1; inputIndex <= downloadedPath.size(); inputIndex++) {
filterComplex.append(String.format(
"[%d]scale='min(1200,iw)':'min(1776,ih)':force_original_aspect_ratio=decrease[photo_scaled_%d]; ",
inputIndex, inputIndex));
filterComplex.append(String.format(
"[recap_bg][photo_scaled_%d]overlay=(W-w)/2:(H-h)/2+80[final%d];",
inputIndex, inputIndex));
}

builder.addExtraArgs("-filter_complex", filterComplex.toString());
builder.addExtraArgs("-filter_complex", filterComplex.toString());

for (int outputIndex = 1; outputIndex <= downloadedPath.size(); outputIndex++) {
builder.addOutput(recapProperties.getPhotoFilePath(recapId, outputIndex))
.addExtraArgs("-map", String.format("[final%d]", outputIndex));
}
for (int outputIndex = 1; outputIndex <= downloadedPath.size(); outputIndex++) {
builder.addOutput(recapProperties.getPhotoFilePath(recapId, outputIndex))
.addExtraArgs("-map", String.format("[final%d]", outputIndex));
}

ffmpegExecutor.createJob(builder).run();
ffmpegExecutor.createJob(builder).run();
} catch (Exception e) {
log.error("Failed to generate recap photos", e);
throw new RuntimeException("Failed to generate recap photos", e);
}
}).then();
}

Expand All @@ -139,8 +149,9 @@ private Mono<String> generateRecapVideo(String recapId) {
String recapVideoPath = recapProperties.getVideoFilePath(recapId);

FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-loglevel", "debug")
.addExtraArgs("-r", "2")
.addInput(recapProperties.getPhotoFilePath(recapId))
.addInput(recapProperties.getPhotoFilePath(recapId))
.addOutput(recapVideoPath)
.done();

Expand Down

0 comments on commit 485a219

Please sign in to comment.