Removes some code duplication and makes converter code utilize the StreamObject interface
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

This commit is contained in:
2020-05-11 17:58:10 +02:00
parent 2404d85468
commit 9673266c09
5 changed files with 98 additions and 87 deletions

View File

@ -16,9 +16,9 @@ public class AudioConverter extends AbstractConverter {
/**
* Instantiates a new audio converter
*
* @param ffprobePath <p>Path/command to ffprobe.</p>
* @param ffmpegPath <p>Path/command to ffmpeg.</p>
* @param newExtension <p>The extension of the new file.</p>
* @param ffprobePath <p>Path/command to ffprobe.</p>
* @param ffmpegPath <p>Path/command to ffmpeg.</p>
* @param newExtension <p>The extension of the new file.</p>
*/
public AudioConverter(String ffprobePath, String ffmpegPath, String newExtension) {
super(newExtension);
@ -29,16 +29,14 @@ public class AudioConverter extends AbstractConverter {
@Override
public String[] builderCommand(String executable, File file, List<StreamObject> streams, String outFile) {
List<String> command = FFMpegHelper.getFFMpegGeneralFileCommand(executable, file.getName());
List<AudioStream> audioStreams = filterStreamsByType(streams, "audio");
AudioStream audioStream = null;
if (audioStreams.size() > 0) {
audioStream = audioStreams.get(0);
if (this.DEBUG) {
FFMpegHelper.addDebugArguments(command, 50, 120);
}
if (audioStreams.size() > 0) {
command.add("-map");
command.add("0:" + audioStream.getAbsoluteIndex());
}
command.add(outFile);
//Gets the first audio stream from the file and adds it to the output file
AudioStream audioStream = getFirstAudioSteam(streams);
addAudioStreams(command, audioStream, false);
return command.toArray(new String[0]);
}