Changes main package name and fixes files with weird names throwing errors
All checks were successful
KnarCraft/FFmpegConvert/master This commit looks good
All checks were successful
KnarCraft/FFmpegConvert/master This commit looks good
Fixes conversion of files with a single quote or square brackets in the filename Moves all files into the net.knarcraft.ffmpegconverter package
This commit is contained in:
parent
c80193281d
commit
4e1cebd95d
@ -1,3 +1,3 @@
|
|||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Main-Class: ffmpegconverter.Main
|
Main-Class: net.knarcraft.ffmpegconverter.Main
|
||||||
|
|
||||||
|
4
pom.xml
4
pom.xml
@ -57,7 +57,7 @@
|
|||||||
<url>https://git.knarcraft.net</url>
|
<url>https://git.knarcraft.net</url>
|
||||||
<layout>default</layout>
|
<layout>default</layout>
|
||||||
</repository>
|
</repository>
|
||||||
<downloadUrl>https://git.knarcraft.net/KnarCraft/FFmpegConvert</downloadUrl>
|
<downloadUrl>https://jenkins.knarcraft.net/job/KnarCraft/job/FFmpegConvert/job/master/lastSuccessfulBuild/artifact/</downloadUrl>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
<manifest>
|
<manifest>
|
||||||
<addClasspath>true</addClasspath>
|
<addClasspath>true</addClasspath>
|
||||||
<classpathPrefix>lib/</classpathPrefix>
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
<mainClass>ffmpegconverter.Main</mainClass>
|
<mainClass>net.knarcraft.ffmpegconverter.Main</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package ffmpegconverter;
|
package net.knarcraft.ffmpegconverter;
|
||||||
|
|
||||||
import ffmpegconverter.converter.AnimeConverter;
|
import net.knarcraft.ffmpegconverter.converter.AnimeConverter;
|
||||||
import ffmpegconverter.converter.AudioConverter;
|
import net.knarcraft.ffmpegconverter.converter.AudioConverter;
|
||||||
import ffmpegconverter.converter.Converter;
|
import net.knarcraft.ffmpegconverter.converter.Converter;
|
||||||
import ffmpegconverter.converter.VideoConverter;
|
import net.knarcraft.ffmpegconverter.converter.VideoConverter;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import static ffmpegconverter.Parser.tokenize;
|
import static net.knarcraft.ffmpegconverter.Parser.tokenize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a files or files in a folder to a web playable mp4.
|
* Converts a files or files in a folder to a web playable mp4.
|
@ -1,10 +1,8 @@
|
|||||||
package ffmpegconverter;
|
package net.knarcraft.ffmpegconverter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static ffmpegconverter.Main.listContains;
|
|
||||||
|
|
||||||
public class Parser {
|
public class Parser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +24,7 @@ public class Parser {
|
|||||||
new Main.converterArgument("-outext", true, Main.converterArgumentValueType.SINGLE_VALUE)
|
new Main.converterArgument("-outext", true, Main.converterArgumentValueType.SINGLE_VALUE)
|
||||||
};
|
};
|
||||||
String type = tokens.get(0).toLowerCase();
|
String type = tokens.get(0).toLowerCase();
|
||||||
if (!listContains(types, s -> s.equals(type))) {
|
if (!Main.listContains(types, s -> s.equals(type))) {
|
||||||
throw new IllegalArgumentException("Unknown converter type chosen.");
|
throw new IllegalArgumentException("Unknown converter type chosen.");
|
||||||
}
|
}
|
||||||
if (tokens.size() < 2) {
|
if (tokens.size() < 2) {
|
@ -1,12 +1,13 @@
|
|||||||
package ffmpegconverter.converter;
|
package net.knarcraft.ffmpegconverter.converter;
|
||||||
|
|
||||||
import ffmpegconverter.streams.AudioStream;
|
import net.knarcraft.ffmpegconverter.streams.AudioStream;
|
||||||
import ffmpegconverter.streams.StreamObject;
|
import net.knarcraft.ffmpegconverter.streams.StreamObject;
|
||||||
import ffmpegconverter.streams.SubtitleStream;
|
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
|
||||||
import ffmpegconverter.streams.VideoStream;
|
import net.knarcraft.ffmpegconverter.streams.VideoStream;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AnimeConverter extends Converter {
|
public class AnimeConverter extends Converter {
|
||||||
@ -112,8 +113,9 @@ public class AnimeConverter extends Converter {
|
|||||||
command.add("-map");
|
command.add("-map");
|
||||||
command.add("0:" + videoStream.getAbsoluteIndex());
|
command.add("0:" + videoStream.getAbsoluteIndex());
|
||||||
command.add("-vf");
|
command.add("-vf");
|
||||||
command.add("subtitles='" + fileName.replace("'", "\'") + "':si=" +
|
String safeFileName = fileName.replace("'", "\\\\\\'").replace("]", "\\]").replace("[", "\\[");
|
||||||
subtitleStream.getRelativeIndex());
|
String subtitleCommand = String.format("subtitles=\"%s\"", safeFileName);
|
||||||
|
command.add(subtitleCommand);
|
||||||
} else {
|
} else {
|
||||||
command.add("-map");
|
command.add("-map");
|
||||||
command.add("0:" + videoStream.getAbsoluteIndex());
|
command.add("0:" + videoStream.getAbsoluteIndex());
|
@ -1,7 +1,7 @@
|
|||||||
package ffmpegconverter.converter;
|
package net.knarcraft.ffmpegconverter.converter;
|
||||||
|
|
||||||
import ffmpegconverter.streams.AudioStream;
|
import net.knarcraft.ffmpegconverter.streams.AudioStream;
|
||||||
import ffmpegconverter.streams.StreamObject;
|
import net.knarcraft.ffmpegconverter.streams.StreamObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,9 +1,9 @@
|
|||||||
package ffmpegconverter.converter;
|
package net.knarcraft.ffmpegconverter.converter;
|
||||||
|
|
||||||
import ffmpegconverter.streams.AudioStream;
|
import net.knarcraft.ffmpegconverter.streams.AudioStream;
|
||||||
import ffmpegconverter.streams.StreamObject;
|
import net.knarcraft.ffmpegconverter.streams.StreamObject;
|
||||||
import ffmpegconverter.streams.SubtitleStream;
|
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
|
||||||
import ffmpegconverter.streams.VideoStream;
|
import net.knarcraft.ffmpegconverter.streams.VideoStream;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -309,7 +309,7 @@ public abstract class Converter {
|
|||||||
* @return A list containing just subtitles of chosen languages, sorted in order of languages
|
* @return A list containing just subtitles of chosen languages, sorted in order of languages
|
||||||
*/
|
*/
|
||||||
static List<SubtitleStream> filterSubtitleStreams(List<SubtitleStream> subtitleStreams, String[] subtitleLanguages,
|
static List<SubtitleStream> filterSubtitleStreams(List<SubtitleStream> subtitleStreams, String[] subtitleLanguages,
|
||||||
boolean preventSignsAndSongs) {
|
boolean preventSignsAndSongs) {
|
||||||
List<SubtitleStream> filtered = new ArrayList<>();
|
List<SubtitleStream> filtered = new ArrayList<>();
|
||||||
//Go through languages. Select all subtitles of the language
|
//Go through languages. Select all subtitles of the language
|
||||||
for (String language : subtitleLanguages) {
|
for (String language : subtitleLanguages) {
|
@ -1,8 +1,8 @@
|
|||||||
package ffmpegconverter.converter;
|
package net.knarcraft.ffmpegconverter.converter;
|
||||||
|
|
||||||
import ffmpegconverter.streams.AudioStream;
|
import net.knarcraft.ffmpegconverter.streams.AudioStream;
|
||||||
import ffmpegconverter.streams.StreamObject;
|
import net.knarcraft.ffmpegconverter.streams.StreamObject;
|
||||||
import ffmpegconverter.streams.VideoStream;
|
import net.knarcraft.ffmpegconverter.streams.VideoStream;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
|||||||
package ffmpegconverter.streams;
|
package net.knarcraft.ffmpegconverter.streams;
|
||||||
|
|
||||||
public class AudioStream extends StreamObject {
|
public class AudioStream extends StreamObject {
|
||||||
private String language; //The audio language
|
private String language; //The audio language
|
@ -1,4 +1,4 @@
|
|||||||
package ffmpegconverter.streams;
|
package net.knarcraft.ffmpegconverter.streams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object representation of a stream in a media file
|
* An object representation of a stream in a media file
|
@ -1,4 +1,4 @@
|
|||||||
package ffmpegconverter.streams;
|
package net.knarcraft.ffmpegconverter.streams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object representation of a subtitle stream in a media file
|
* An object representation of a subtitle stream in a media file
|
@ -1,4 +1,4 @@
|
|||||||
package ffmpegconverter.streams;
|
package net.knarcraft.ffmpegconverter.streams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object representation of a video stream in a media file
|
* An object representation of a video stream in a media file
|
@ -1,6 +1,6 @@
|
|||||||
package ffmpegconverter;
|
package net.knarcraft.ffmpegconverter;
|
||||||
|
|
||||||
import ffmpegconverter.converter.AnimeConverter;
|
import net.knarcraft.ffmpegconverter.converter.AnimeConverter;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user