A 0 in the user-given language input now matches streams with language defined as "und"
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2020-05-12 16:05:35 +02:00
parent b78aa7eb42
commit a516cdcdff
6 changed files with 14 additions and 12 deletions

View File

@ -107,15 +107,15 @@ class Main {
OutputUtil.println("[Audio languages jpn,eng,ger,fre] [Subtitle languages eng,ger,fre] [Convert to stereo if " +
"necessary true/false] [Prevent signs&songs subtitles true/false]\nYour input: ");
List<String> input = readInput(4);
String[] audioLang = new String[]{"jpn", "*"};
String[] subtitleLang = new String[]{"eng", "*"};
String[] audioLanguage = new String[]{"jpn", "0"};
String[] subtitleLanguage = new String[]{"eng", "0"};
boolean toStereo = true;
boolean preventSigns = true;
if (input.size() > 0 && ListUtil.getListFromCommaSeparatedString(input.get(0)) != null) {
audioLang = ListUtil.getListFromCommaSeparatedString(input.get(0));
audioLanguage = ListUtil.getListFromCommaSeparatedString(input.get(0));
}
if (input.size() > 1 && ListUtil.getListFromCommaSeparatedString(input.get(1)) != null) {
subtitleLang = ListUtil.getListFromCommaSeparatedString(input.get(1));
subtitleLanguage = ListUtil.getListFromCommaSeparatedString(input.get(1));
}
if (input.size() > 2) {
toStereo = Boolean.parseBoolean(input.get(2));
@ -123,7 +123,7 @@ class Main {
if (input.size() > 3) {
preventSigns = Boolean.parseBoolean(input.get(3));
}
converter = new AnimeConverter(FFPROBE_PATH, FFMPEG_PATH, audioLang, subtitleLang, toStereo, preventSigns);
converter = new AnimeConverter(FFPROBE_PATH, FFMPEG_PATH, audioLanguage, subtitleLanguage, toStereo, preventSigns);
}

View File

@ -17,7 +17,7 @@ import java.util.List;
* Implements all methods which can be useful for any implementation of a converter.
*/
public abstract class AbstractConverter implements Converter {
final boolean DEBUG = false;
final boolean debug = false;
private final String newExtension;
String ffprobePath;
String ffmpegPath;
@ -29,6 +29,7 @@ public abstract class AbstractConverter implements Converter {
*/
AbstractConverter(String newExtension) {
this.newExtension = newExtension;
OutputUtil.setDebug(this.debug);
try {
audioFormats = FileUtil.readFileLines("audio_formats.txt");
videoFormats = FileUtil.readFileLines("video_formats.txt");
@ -96,8 +97,8 @@ public abstract class AbstractConverter implements Converter {
for (String language : languages) {
for (G stream : streams) {
String streamLanguage = stream.getLanguage();
if (language.equals("*") || (streamLanguage == null && language.equals("0")) ||
(streamLanguage != null && streamLanguage.equals(language))) {
if (language.equals("*") || ((streamLanguage == null || streamLanguage.equals("und")) &&
language.equals("0")) || (streamLanguage != null && streamLanguage.equals(language))) {
sorted.add(stream);
}
}

View File

@ -49,7 +49,7 @@ public class AnimeConverter extends AbstractConverter {
@Override
public String[] generateConversionCommand(String executable, File file, List<StreamObject> streams, String outFile) {
List<String> command = FFMpegHelper.getFFMpegWebVideoCommand(executable, file.getName());
if (this.DEBUG) {
if (this.debug) {
FFMpegHelper.addDebugArguments(command, 50, 120);
}

View File

@ -29,7 +29,7 @@ public class AudioConverter extends AbstractConverter {
@Override
public String[] generateConversionCommand(String executable, File file, List<StreamObject> streams, String outFile) {
List<String> command = FFMpegHelper.getFFMpegGeneralFileCommand(executable, file.getName());
if (this.DEBUG) {
if (this.debug) {
FFMpegHelper.addDebugArguments(command, 50, 120);
}

View File

@ -31,7 +31,7 @@ public class VideoConverter extends AbstractConverter {
@Override
public String[] generateConversionCommand(String executable, File file, List<StreamObject> streams, String outFile) {
List<String> command = FFMpegHelper.getFFMpegGeneralFileCommand(executable, file.getName());
if (this.DEBUG) {
if (this.debug) {
FFMpegHelper.addDebugArguments(command, 50, 120);
}

View File

@ -111,8 +111,9 @@ public final class FFMpegHelper {
String read = readProcess(processReader, spacer);
if (!read.equals("")) {
if (write) {
OutputUtil.print(read);
OutputUtil.println(read);
} else {
OutputUtil.printDebug(read);
output.append(read);
}
}