mirror of
https://github.com/aNNiMON/ffmpegbot
synced 2024-09-19 22:54:20 +03:00
Fix Audio Track parameter
This commit is contained in:
parent
1a9b338836
commit
bc21f06e9a
@ -76,7 +76,8 @@ public class FFmpegCommandBuilder implements Visitor<MediaSession> {
|
||||
public void visit(AudioStreamByLanguage p, MediaSession input) {
|
||||
if (discardAudio) return;
|
||||
if (p.getValue().isEmpty()) return;
|
||||
audioCommands.add("-map 0:m:language:" + p.getValue());
|
||||
audioCommands.add("-map");
|
||||
audioCommands.add("0:m:language:" + p.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,7 +136,7 @@ public class FFmpegCommandBuilder implements Visitor<MediaSession> {
|
||||
|
||||
public String[] buildCommand(final @NotNull MediaSession session) {
|
||||
final var commands = new ArrayList<String>();
|
||||
commands.addAll(List.of("ffmpeg", "-loglevel", "quiet", "-stats"));
|
||||
commands.addAll(List.of("ffmpeg", "-loglevel", "error", "-stats"));
|
||||
commands.addAll(session.getInputParams().asFFmpegCommands());
|
||||
commands.addAll(List.of("-i", FilePath.inputDir() + "/" + session.getInputFile().getName()));
|
||||
if (FileTypes.canContainAudio(session.getFileType())) {
|
||||
|
@ -3,8 +3,10 @@ package com.annimon.ffmpegbot.commands.ffmpeg;
|
||||
import com.annimon.ffmpegbot.parameters.Parameter;
|
||||
import com.annimon.ffmpegbot.session.MediaSession;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class FFmpegTask {
|
||||
|
||||
@ -19,13 +21,20 @@ public class FFmpegTask {
|
||||
pb.redirectErrorStream(true);
|
||||
pb.inheritIO();
|
||||
session.setStatus("Starting ffmpeg");
|
||||
final Process process = pb.start();
|
||||
final Scanner out = new Scanner(process.getInputStream());
|
||||
while (out.hasNextLine()) {
|
||||
final String line = out.nextLine();
|
||||
final var process = pb.start();
|
||||
final var lines = new StringJoiner("\n");
|
||||
try (final var reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
lines.add(line);
|
||||
session.setStatus(line);
|
||||
}
|
||||
process.waitFor();
|
||||
int status = process.waitFor();
|
||||
if (status != 0) {
|
||||
session.setStatus(lines.toString());
|
||||
throw new RuntimeException("ffmpeg process was finished with non-zero value " + status);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
session.setStatus("Failed due to " + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
|
Loading…
Reference in New Issue
Block a user