All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
69 lines
2.5 KiB
Java
69 lines
2.5 KiB
Java
package net.knarcraft.ffmpegconverter.converter;
|
|
|
|
import net.knarcraft.ffmpegconverter.container.FFMpegCommand;
|
|
import net.knarcraft.ffmpegconverter.container.StreamProbeResult;
|
|
import net.knarcraft.ffmpegconverter.converter.module.ConverterModule;
|
|
import net.knarcraft.ffmpegconverter.converter.module.DebugModule;
|
|
import net.knarcraft.ffmpegconverter.converter.module.ModuleExecutor;
|
|
import net.knarcraft.ffmpegconverter.converter.module.mapping.MapAllModule;
|
|
import net.knarcraft.ffmpegconverter.converter.module.output.CopyAllModule;
|
|
import net.knarcraft.ffmpegconverter.converter.module.output.SetOutputFileModule;
|
|
import net.knarcraft.ffmpegconverter.utility.FFMpegHelper;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* A transcoder which removes embedded caption subtitles, like EIA-608
|
|
*/
|
|
public class EmbeddedCaptionStripper extends AbstractConverter {
|
|
|
|
/**
|
|
* Instantiates a new mkv to mp4 transcoder
|
|
*
|
|
* @param ffprobePath <p>Path/command to ffprobe.</p>
|
|
* @param ffmpegPath <p>Path/command to ffmpeg.</p>
|
|
*/
|
|
public EmbeddedCaptionStripper(String ffprobePath, String ffmpegPath) {
|
|
super("mkv");
|
|
this.ffprobePath = ffprobePath;
|
|
this.ffmpegPath = ffmpegPath;
|
|
}
|
|
|
|
@Override
|
|
@NotNull
|
|
public List<String> getValidFormats() {
|
|
return List.of("mkv");
|
|
}
|
|
|
|
@Override
|
|
@Nullable
|
|
public FFMpegCommand generateConversionCommand(@NotNull String executable, @NotNull StreamProbeResult probeResult,
|
|
@NotNull String outFile) {
|
|
FFMpegCommand command = FFMpegHelper.getFFMpegGeneralFileCommand(executable, probeResult.parsedFiles());
|
|
List<ConverterModule> modules = new ArrayList<>();
|
|
|
|
if (this.debug) {
|
|
modules.add(new DebugModule());
|
|
}
|
|
|
|
// Copy stream info
|
|
modules.add(new CopyAllModule());
|
|
|
|
//Add streams to output file
|
|
modules.add(new MapAllModule<>(probeResult.getVideoStreams()));
|
|
modules.add(new MapAllModule<>(probeResult.getAudioStreams()));
|
|
modules.add(new MapAllModule<>(probeResult.getSubtitleStreams()));
|
|
modules.add(new MapAllModule<>(probeResult.getOtherStreams()));
|
|
command.addOutputFileOption("-bsf:v", "filter_units=remove_types=39");
|
|
|
|
modules.add(new SetOutputFileModule(outFile));
|
|
|
|
new ModuleExecutor(command, modules).execute();
|
|
return command;
|
|
}
|
|
|
|
}
|