Adds a converter for web video and changes behavior of the normal video converter
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

The normal video converter now includes all streams
The web video converter selects the first of each stream
Changes some method names
Moves the convert command to the abstract converter
This commit is contained in:
2020-05-12 19:56:01 +02:00
parent a516cdcdff
commit f2b2de514e
8 changed files with 94 additions and 49 deletions

View File

@ -0,0 +1,53 @@
package net.knarcraft.ffmpegconverter.converter;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import net.knarcraft.ffmpegconverter.utility.FFMpegHelper;
import java.io.File;
import java.util.List;
public class WebVideoConverter extends AbstractConverter {
/**
* Instantiates a new web video converter
*
* @param ffprobePath <p>Path/command to ffprobe.</p>
* @param ffmpegPath <p>Path/command to ffmpeg.</p>
* @param outExtension <p>The extension of the new file.</p>
*/
public WebVideoConverter(String ffprobePath, String ffmpegPath, String outExtension) {
super(outExtension);
this.ffprobePath = ffprobePath;
this.ffmpegPath = ffmpegPath;
}
@Override
public String[] getValidFormats() {
return videoFormats;
}
@Override
public String[] generateConversionCommand(String executable, File file, List<StreamObject> streams, String outFile) {
List<String> command = FFMpegHelper.getFFMpegWebVideoCommand(executable, file.getName());
if (this.debug) {
FFMpegHelper.addDebugArguments(command, 50, 120);
}
//Get first streams from the file
SubtitleStream subtitleStream = getFirstSubtitleStream(streams);
VideoStream videoStream = getFirstVideoStream(streams);
AudioStream audioStream = getFirstAudioSteam(streams);
//Add streams to output
FFMpegHelper.addSubtitleAndVideoStream(command, subtitleStream, videoStream, file);
if (audioStream != null) {
FFMpegHelper.addAudioStream(command, audioStream, true);
}
command.add(outFile);
return command.toArray(new String[0]);
}
}