All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
54 lines
2.0 KiB
Java
54 lines
2.0 KiB
Java
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(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);
|
|
if (audioStream != null) {
|
|
FFMpegHelper.addAudioStream(command, audioStream, true);
|
|
}
|
|
|
|
command.add(outFile);
|
|
return command.toArray(new String[0]);
|
|
}
|
|
}
|