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) {
|
public void visit(AudioStreamByLanguage p, MediaSession input) {
|
||||||
if (discardAudio) return;
|
if (discardAudio) return;
|
||||||
if (p.getValue().isEmpty()) 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
|
@Override
|
||||||
@ -135,7 +136,7 @@ public class FFmpegCommandBuilder implements Visitor<MediaSession> {
|
|||||||
|
|
||||||
public String[] buildCommand(final @NotNull MediaSession session) {
|
public String[] buildCommand(final @NotNull MediaSession session) {
|
||||||
final var commands = new ArrayList<String>();
|
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(session.getInputParams().asFFmpegCommands());
|
||||||
commands.addAll(List.of("-i", FilePath.inputDir() + "/" + session.getInputFile().getName()));
|
commands.addAll(List.of("-i", FilePath.inputDir() + "/" + session.getInputFile().getName()));
|
||||||
if (FileTypes.canContainAudio(session.getFileType())) {
|
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.parameters.Parameter;
|
||||||
import com.annimon.ffmpegbot.session.MediaSession;
|
import com.annimon.ffmpegbot.session.MediaSession;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
public class FFmpegTask {
|
public class FFmpegTask {
|
||||||
|
|
||||||
@ -19,13 +21,20 @@ public class FFmpegTask {
|
|||||||
pb.redirectErrorStream(true);
|
pb.redirectErrorStream(true);
|
||||||
pb.inheritIO();
|
pb.inheritIO();
|
||||||
session.setStatus("Starting ffmpeg");
|
session.setStatus("Starting ffmpeg");
|
||||||
final Process process = pb.start();
|
final var process = pb.start();
|
||||||
final Scanner out = new Scanner(process.getInputStream());
|
final var lines = new StringJoiner("\n");
|
||||||
while (out.hasNextLine()) {
|
try (final var reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||||
final String line = out.nextLine();
|
String line;
|
||||||
session.setStatus(line);
|
while ((line = reader.readLine()) != null) {
|
||||||
|
lines.add(line);
|
||||||
|
session.setStatus(line);
|
||||||
|
}
|
||||||
|
int status = process.waitFor();
|
||||||
|
if (status != 0) {
|
||||||
|
session.setStatus(lines.toString());
|
||||||
|
throw new RuntimeException("ffmpeg process was finished with non-zero value " + status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
process.waitFor();
|
|
||||||
} catch (InterruptedException | IOException e) {
|
} catch (InterruptedException | IOException e) {
|
||||||
session.setStatus("Failed due to " + e.getMessage());
|
session.setStatus("Failed due to " + e.getMessage());
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user