Adds a MKV to h264 MKV converter
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:
@ -0,0 +1,75 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* A converter solely for the purpose of converting video streams of MKV files into h264
|
||||
*/
|
||||
public class MkvH264Converter extends AbstractConverter {
|
||||
|
||||
/**
|
||||
* Initializes variables used by the abstract converter
|
||||
*
|
||||
* @param ffprobePath <p>Path/command to ffprobe.</p>
|
||||
* @param ffmpegPath <p>Path/command to ffmpeg.</p>
|
||||
*/
|
||||
public MkvH264Converter(String ffprobePath, String ffmpegPath) {
|
||||
super("mkv");
|
||||
this.ffprobePath = ffprobePath;
|
||||
this.ffmpegPath = ffmpegPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValidFormats() {
|
||||
return new String[]{"mkv"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] generateConversionCommand(String executable, File file, List<StreamObject> streams,
|
||||
String outFile) {
|
||||
List<String> command = FFMpegHelper.getFFMpegGeneralFileCommand(executable, file.getName());
|
||||
if (this.debug) {
|
||||
FFMpegHelper.addDebugArguments(command, 50, 120);
|
||||
}
|
||||
|
||||
// Map video if present
|
||||
if (!filterStreamsByType(streams, VideoStream.class).isEmpty()) {
|
||||
command.add("-map");
|
||||
command.add("0:v");
|
||||
command.add("-vcodec");
|
||||
command.add("h264");
|
||||
}
|
||||
|
||||
// Map audio if present
|
||||
if (!filterStreamsByType(streams, AudioStream.class).isEmpty()) {
|
||||
command.add("-map");
|
||||
command.add("0:a");
|
||||
command.add("-c:a");
|
||||
command.add("copy");
|
||||
}
|
||||
|
||||
// Map subtitles if present
|
||||
if (!filterStreamsByType(streams, SubtitleStream.class).isEmpty()) {
|
||||
command.add("-map");
|
||||
command.add("0:s");
|
||||
command.add("-c:s");
|
||||
command.add("copy");
|
||||
}
|
||||
|
||||
command.add("-map_metadata");
|
||||
command.add("0");
|
||||
command.add("-movflags");
|
||||
command.add("use_metadata_tags");
|
||||
|
||||
command.add(outFile);
|
||||
return command.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user