Changes newExtension to outputExtension and requires streams to be filtered by type before calling getFirstTypeStream
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
This commit is contained in:
parent
d349629574
commit
8b0c1ea815
@ -18,7 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class AbstractConverter implements Converter {
|
||||
final boolean debug = false;
|
||||
private final String newExtension;
|
||||
private final String outputExtension;
|
||||
String ffprobePath;
|
||||
String ffmpegPath;
|
||||
String[] audioFormats;
|
||||
@ -27,8 +27,8 @@ public abstract class AbstractConverter implements Converter {
|
||||
/**
|
||||
* Initializes variables used by the abstract converter
|
||||
*/
|
||||
AbstractConverter(String newExtension) {
|
||||
this.newExtension = newExtension;
|
||||
AbstractConverter(String outputExtension) {
|
||||
this.outputExtension = outputExtension;
|
||||
OutputUtil.setDebug(this.debug);
|
||||
try {
|
||||
audioFormats = FileUtil.readFileLines("audio_formats.txt");
|
||||
@ -127,7 +127,7 @@ public abstract class AbstractConverter implements Converter {
|
||||
throw new IllegalArgumentException("The file has no valid streams. Please make sure the file exists and" +
|
||||
" is not corrupt.");
|
||||
}
|
||||
String newPath = FileUtil.getNonCollidingPath(folder, file, newExtension);
|
||||
String newPath = FileUtil.getNonCollidingPath(folder, file, outputExtension);
|
||||
OutputUtil.println();
|
||||
OutputUtil.println("Preparing to start process...");
|
||||
OutputUtil.println("Converting " + file);
|
||||
@ -138,11 +138,10 @@ public abstract class AbstractConverter implements Converter {
|
||||
/**
|
||||
* Gets the first audio stream from a list of streams
|
||||
*
|
||||
* @param streams <p>A list of all streams.</p>
|
||||
* @param audioStreams <p>A list of all streams.</p>
|
||||
* @return <p>The first audio stream found or null if no audio streams were found.</p>
|
||||
*/
|
||||
AudioStream getFirstAudioSteam(List<StreamObject> streams) {
|
||||
List<AudioStream> audioStreams = filterStreamsByType(streams, AudioStream.class);
|
||||
AudioStream getFirstAudioStream(List<AudioStream> audioStreams) {
|
||||
AudioStream audioStream = null;
|
||||
if (audioStreams.size() > 0) {
|
||||
audioStream = audioStreams.get(0);
|
||||
@ -153,11 +152,10 @@ public abstract class AbstractConverter implements Converter {
|
||||
/**
|
||||
* Gets the first subtitle stream from a list of streams
|
||||
*
|
||||
* @param streams <p>A list of all streams.</p>
|
||||
* @param subtitleStreams <p>A list of all subtitle streams.</p>
|
||||
* @return <p>The first subtitle stream found or null if no subtitle streams were found.</p>
|
||||
*/
|
||||
SubtitleStream getFirstSubtitleStream(List<StreamObject> streams) {
|
||||
List<SubtitleStream> subtitleStreams = filterStreamsByType(streams, SubtitleStream.class);
|
||||
SubtitleStream getFirstSubtitleStream(List<SubtitleStream> subtitleStreams) {
|
||||
SubtitleStream subtitleStream = null;
|
||||
if (subtitleStreams.size() > 0) {
|
||||
subtitleStream = subtitleStreams.get(0);
|
||||
@ -168,11 +166,10 @@ public abstract class AbstractConverter implements Converter {
|
||||
/**
|
||||
* Gets the first video stream from a list of streams
|
||||
*
|
||||
* @param streams <p>A list of all streams.</p>
|
||||
* @param videoStreams <p>A list of all streams.</p>
|
||||
* @return <p>The first video stream found or null if no video streams were found.</p>
|
||||
*/
|
||||
VideoStream getFirstVideoStream(List<StreamObject> streams) {
|
||||
List<VideoStream> videoStreams = filterStreamsByType(streams, VideoStream.class);
|
||||
VideoStream getFirstVideoStream(List<VideoStream> videoStreams) {
|
||||
VideoStream videoStream = null;
|
||||
if (videoStreams.size() > 0) {
|
||||
videoStream = videoStreams.get(0);
|
||||
|
@ -80,7 +80,7 @@ public class AdvancedConverter extends AbstractConverter {
|
||||
|
||||
//Get the first audio stream in accordance with chosen languages
|
||||
List<AudioStream> audioStreams = filterAudioStreams(filterStreamsByType(streams, AudioStream.class), audioLanguages);
|
||||
AudioStream audioStream = getFirstAudioSteam(new ArrayList<>(audioStreams));
|
||||
AudioStream audioStream = getFirstAudioStream(new ArrayList<>(audioStreams));
|
||||
|
||||
//Get the first subtitle stream in accordance with chosen languages and signs and songs prevention
|
||||
List<SubtitleStream> subtitleStreams = filterSubtitleStreams(filterStreamsByType(streams,
|
||||
|
@ -49,7 +49,7 @@ public class AnimeConverter extends AbstractConverter {
|
||||
|
||||
//Get the first audio stream in accordance with chosen languages
|
||||
List<AudioStream> audioStreams = filterAudioStreams(filterStreamsByType(streams, AudioStream.class), audioLanguages);
|
||||
AudioStream audioStream = getFirstAudioSteam(new ArrayList<>(audioStreams));
|
||||
AudioStream audioStream = getFirstAudioStream(new ArrayList<>(audioStreams));
|
||||
|
||||
//Get the first subtitle stream in accordance with chosen languages and signs and songs prevention
|
||||
List<SubtitleStream> subtitleStreams = filterSubtitleStreams(filterStreamsByType(streams,
|
||||
@ -57,7 +57,7 @@ public class AnimeConverter extends AbstractConverter {
|
||||
SubtitleStream subtitleStream = getFirstSubtitleStream(new ArrayList<>(subtitleStreams));
|
||||
|
||||
//Get the first video stream
|
||||
VideoStream videoStream = getFirstVideoStream(streams);
|
||||
VideoStream videoStream = getFirstVideoStream(filterStreamsByType(streams, VideoStream.class));
|
||||
|
||||
//Add streams to output file
|
||||
FFMpegHelper.addAudioStream(command, audioStream, toStereo);
|
||||
|
@ -33,7 +33,7 @@ public class AudioConverter extends AbstractConverter {
|
||||
}
|
||||
|
||||
//Gets the first audio stream from the file and adds it to the output file
|
||||
AudioStream audioStream = getFirstAudioSteam(streams);
|
||||
AudioStream audioStream = getFirstAudioStream(filterStreamsByType(streams, AudioStream.class));
|
||||
FFMpegHelper.addAudioStream(command, audioStream, false);
|
||||
command.add(outFile);
|
||||
|
||||
|
@ -37,9 +37,9 @@ public class WebVideoConverter extends AbstractConverter {
|
||||
}
|
||||
|
||||
//Get first streams from the file
|
||||
SubtitleStream subtitleStream = getFirstSubtitleStream(streams);
|
||||
VideoStream videoStream = getFirstVideoStream(streams);
|
||||
AudioStream audioStream = getFirstAudioSteam(streams);
|
||||
SubtitleStream subtitleStream = getFirstSubtitleStream(filterStreamsByType(streams, SubtitleStream.class));
|
||||
VideoStream videoStream = getFirstVideoStream(filterStreamsByType(streams, VideoStream.class));
|
||||
AudioStream audioStream = getFirstAudioStream(filterStreamsByType(streams, AudioStream.class));
|
||||
|
||||
//Add streams to output
|
||||
FFMpegHelper.addSubtitleAndVideoStream(command, subtitleStream, videoStream, file);
|
||||
|
Loading…
Reference in New Issue
Block a user