Various smaller improvements
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
Improves Signs & Songs subtitle RegEx Adds tests for the Signs & Songs subtitle RegEx Automatically changes "enm" language to English Makes the downscale converter select HEVC if the input is HEVC
This commit is contained in:
parent
1dc489a6f8
commit
1ceb378757
6
pom.xml
6
pom.xml
@ -128,5 +128,11 @@
|
|||||||
<version>1.9.4</version>
|
<version>1.9.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<version>5.10.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -12,6 +12,7 @@ import net.knarcraft.ffmpegconverter.converter.module.output.CopySubtitlesModule
|
|||||||
import net.knarcraft.ffmpegconverter.converter.module.output.ScaleModule;
|
import net.knarcraft.ffmpegconverter.converter.module.output.ScaleModule;
|
||||||
import net.knarcraft.ffmpegconverter.converter.module.output.SetOutputFileModule;
|
import net.knarcraft.ffmpegconverter.converter.module.output.SetOutputFileModule;
|
||||||
import net.knarcraft.ffmpegconverter.converter.module.output.SetQualityModule;
|
import net.knarcraft.ffmpegconverter.converter.module.output.SetQualityModule;
|
||||||
|
import net.knarcraft.ffmpegconverter.converter.module.output.SetVideoCodecModule;
|
||||||
import net.knarcraft.ffmpegconverter.streams.StreamObject;
|
import net.knarcraft.ffmpegconverter.streams.StreamObject;
|
||||||
import net.knarcraft.ffmpegconverter.streams.VideoStream;
|
import net.knarcraft.ffmpegconverter.streams.VideoStream;
|
||||||
import net.knarcraft.ffmpegconverter.utility.FFMpegHelper;
|
import net.knarcraft.ffmpegconverter.utility.FFMpegHelper;
|
||||||
@ -71,8 +72,15 @@ public class DownScaleConverter extends AbstractConverter {
|
|||||||
modules.add(new MapAllModule<>(streams));
|
modules.add(new MapAllModule<>(streams));
|
||||||
modules.add(new CopyAudioModule());
|
modules.add(new CopyAudioModule());
|
||||||
modules.add(new CopySubtitlesModule());
|
modules.add(new CopySubtitlesModule());
|
||||||
|
|
||||||
|
if (videoStream.getCodecName().trim().equalsIgnoreCase("hevc")) {
|
||||||
|
modules.add(new SetVideoCodecModule("hevc"));
|
||||||
|
} else {
|
||||||
|
modules.add(new SetVideoCodecModule("h264"));
|
||||||
|
}
|
||||||
|
|
||||||
modules.add(new ScaleModule(this.newWidth, this.newHeight));
|
modules.add(new ScaleModule(this.newWidth, this.newHeight));
|
||||||
modules.add(new SetQualityModule(20, "p7"));
|
modules.add(new SetQualityModule(20, "slower"));
|
||||||
modules.add(new SetOutputFileModule(outFile));
|
modules.add(new SetOutputFileModule(outFile));
|
||||||
modules.add(new HardwareDecodeModule());
|
modules.add(new HardwareDecodeModule());
|
||||||
new ModuleExecutor(command, modules).execute();
|
new ModuleExecutor(command, modules).execute();
|
||||||
|
@ -98,7 +98,7 @@ public abstract class AbstractStream implements StreamObject {
|
|||||||
private String parseLanguage(@NotNull Map<StreamTag, String> streamInfo) {
|
private String parseLanguage(@NotNull Map<StreamTag, String> streamInfo) {
|
||||||
String languageString = ValueParsingHelper.parseString(streamInfo.get(StreamTag.TAG_LANGUAGE), "und");
|
String languageString = ValueParsingHelper.parseString(streamInfo.get(StreamTag.TAG_LANGUAGE), "und");
|
||||||
String title = ValueParsingHelper.parseString(streamInfo.get(StreamTag.TAG_TITLE), "");
|
String title = ValueParsingHelper.parseString(streamInfo.get(StreamTag.TAG_TITLE), "");
|
||||||
if (languageString.equalsIgnoreCase("zxx") ||
|
if (languageString.equalsIgnoreCase("zxx") || languageString.equalsIgnoreCase("enm") ||
|
||||||
(title.toLowerCase().matches(".*english.*") && languageString.equalsIgnoreCase("jpn"))) {
|
(title.toLowerCase().matches(".*english.*") && languageString.equalsIgnoreCase("jpn"))) {
|
||||||
return "eng";
|
return "eng";
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.knarcraft.ffmpegconverter.streams;
|
package net.knarcraft.ffmpegconverter.streams;
|
||||||
|
|
||||||
|
import net.knarcraft.ffmpegconverter.utility.SubtitleHelper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -50,8 +51,7 @@ public class SubtitleStream extends AbstractStream implements StreamObject {
|
|||||||
* @return <p>True if the subtitle translates everything.</p>
|
* @return <p>True if the subtitle translates everything.</p>
|
||||||
*/
|
*/
|
||||||
private boolean checkIfIsFullSubtitle() {
|
private boolean checkIfIsFullSubtitle() {
|
||||||
return !getTitle().toLowerCase().trim().matches(".*si(ng|gn)s?[ &/a-z+]+(songs?)?([$ @-]+.*)?|" +
|
return !SubtitleHelper.isSongsSignsSubtitle(this.getTitle());
|
||||||
".*songs?[ &/a-z]+(si(gn|ng)s?)?([$ @-]+.*)?|.*forced.*|.*s&s.*|songs($| |-|@)+|si(gn|ng)s($| |-|@)+");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package net.knarcraft.ffmpegconverter.utility;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper class for subtitle-related tasks
|
||||||
|
*/
|
||||||
|
public final class SubtitleHelper {
|
||||||
|
|
||||||
|
private SubtitleHelper() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given subtitle is a songs & signs subtitle
|
||||||
|
*
|
||||||
|
* @param subtitleTitle <p>The subtitle to check</p>
|
||||||
|
* @return <p>True if the subtitle is a songs and signs, not a full subtitle</p>
|
||||||
|
*/
|
||||||
|
public static boolean isSongsSignsSubtitle(@NotNull String subtitleTitle) {
|
||||||
|
Pattern pattern = Pattern.compile("(^| |\\(|\\[\\{)si(ng|gn)s?($|[ &/+-@])+(titles)?[ &/+-@]?(songs?)?|" +
|
||||||
|
"(^| |\\(|\\[\\{)songs?($|[ &/+-@])+(si(gn|ng)s?)?|.*forced.*|.*s&s.*");
|
||||||
|
Matcher matcher = pattern.matcher(subtitleTitle.toLowerCase().trim());
|
||||||
|
return matcher.find();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package net.knarcraft.ffmpegconverter.utility;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
public class SubtitleHelperTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isSignsSongsSubtitlePositiveTest() {
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Signs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Sign"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Song"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Signs & Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Songs & Signs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Sings & Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Songs & Sings"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Signs/Titles/Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Signs@"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Sings & Songs@"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Songs & Sings -"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Signs/Titles/Songs bla bla (bla)"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("English (Signs/Titles/Songs)"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Forced"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Signs / Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Songs / Signs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Forced Subtitles"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Some Text Signs & Songs"));
|
||||||
|
assertTrue(SubtitleHelper.isSongsSignsSubtitle("Some Text Songs & Signs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isSignsSongsSubtitleNegativeTest() {
|
||||||
|
assertFalse(SubtitleHelper.isSongsSignsSubtitle("Potato"));
|
||||||
|
assertFalse(SubtitleHelper.isSongsSignsSubtitle("assign"));
|
||||||
|
assertFalse(SubtitleHelper.isSongsSignsSubtitle("signed"));
|
||||||
|
assertFalse(SubtitleHelper.isSongsSignsSubtitle("English"));
|
||||||
|
assertFalse(SubtitleHelper.isSongsSignsSubtitle("Full subtitle"));
|
||||||
|
assertFalse(SubtitleHelper.isSongsSignsSubtitle("Dialogue"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user