Adds a converter for converting video audio to vorbis
This commit is contained in:
parent
5238697c70
commit
da67b195de
@ -3,6 +3,7 @@ package net.knarcraft.ffmpegconverter;
|
||||
import net.knarcraft.ffmpegconverter.config.Configuration;
|
||||
import net.knarcraft.ffmpegconverter.converter.AnimeConverter;
|
||||
import net.knarcraft.ffmpegconverter.converter.AudioConverter;
|
||||
import net.knarcraft.ffmpegconverter.converter.AudioToVorbisConverter;
|
||||
import net.knarcraft.ffmpegconverter.converter.Converter;
|
||||
import net.knarcraft.ffmpegconverter.converter.DownScaleConverter;
|
||||
import net.knarcraft.ffmpegconverter.converter.LetterboxCropper;
|
||||
@ -98,7 +99,8 @@ public class FFMpegConvert {
|
||||
9. mp4 Subtitle Embed
|
||||
10. Anime to h265 all streams
|
||||
11. Stream reorder
|
||||
12. Letterbox cropper""", 1, 12);
|
||||
12. Letterbox cropper
|
||||
13. Video's Audio to vorbis converter""", 1, 13);
|
||||
|
||||
return switch (choice) {
|
||||
case 1 -> generateWebAnimeConverter();
|
||||
@ -113,6 +115,7 @@ public class FFMpegConvert {
|
||||
case 10 -> generateAnimeConverter();
|
||||
case 11 -> generateStreamOrderConverter();
|
||||
case 12 -> new LetterboxCropper(FFPROBE_PATH, FFMPEG_PATH);
|
||||
case 13 -> new AudioToVorbisConverter(FFPROBE_PATH, FFMPEG_PATH);
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,84 @@
|
||||
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.CopySubtitlesModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.output.CopyVideoModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.output.SetOutputFileModule;
|
||||
import net.knarcraft.ffmpegconverter.streams.AudioStream;
|
||||
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
|
||||
import net.knarcraft.ffmpegconverter.streams.VideoStream;
|
||||
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 converter to convert a video's audio into flac
|
||||
*/
|
||||
public class AudioToVorbisConverter 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 AudioToVorbisConverter(String ffprobePath, String ffmpegPath) {
|
||||
super("mkv");
|
||||
this.ffprobePath = ffprobePath;
|
||||
this.ffmpegPath = ffmpegPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> getValidFormats() {
|
||||
return this.videoFormats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable 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());
|
||||
}
|
||||
|
||||
// Map video if present
|
||||
List<VideoStream> videoStreams = probeResult.getVideoStreams();
|
||||
if (!videoStreams.isEmpty()) {
|
||||
modules.add(new MapAllModule<>(videoStreams));
|
||||
modules.add(new CopyVideoModule());
|
||||
}
|
||||
|
||||
// Map audio if present
|
||||
List<AudioStream> audioStreams = probeResult.getAudioStreams();
|
||||
if (!audioStreams.isEmpty()) {
|
||||
modules.add(new MapAllModule<>(audioStreams));
|
||||
setOutputIndexes(audioStreams);
|
||||
}
|
||||
|
||||
// Map subtitles if present
|
||||
List<SubtitleStream> subtitleStreams = probeResult.getSubtitleStreams();
|
||||
if (!subtitleStreams.isEmpty()) {
|
||||
modules.add(new MapAllModule<>(subtitleStreams));
|
||||
setOutputIndexes(subtitleStreams);
|
||||
modules.add(new CopySubtitlesModule());
|
||||
}
|
||||
|
||||
// Map any fonts, cover images or similar
|
||||
modules.add(new MapAllModule<>(probeResult.getOtherStreams()));
|
||||
|
||||
// Set output file and execute
|
||||
modules.add(new SetOutputFileModule(outFile));
|
||||
new ModuleExecutor(command, modules).execute();
|
||||
return command;
|
||||
}
|
||||
|
||||
}
|
@ -8,7 +8,6 @@ import net.knarcraft.ffmpegconverter.converter.module.ModuleExecutor;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.hardwarecoding.H265HardwareEncodingModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.hardwarecoding.HardwareDecodeModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.mapping.MapAllModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.output.CopyAudioModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.output.CopySubtitlesModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.output.FastStartModule;
|
||||
import net.knarcraft.ffmpegconverter.converter.module.output.SetOutputFileModule;
|
||||
@ -70,7 +69,8 @@ public class MkvH265ReducedConverter extends AbstractConverter {
|
||||
if (!audioStreams.isEmpty()) {
|
||||
modules.add(new MapAllModule<>(audioStreams));
|
||||
setOutputIndexes(audioStreams);
|
||||
modules.add(new CopyAudioModule(audioStreams));
|
||||
command.addOutputFileOption("-c:a", "flac");
|
||||
command.addOutputFileOption("-compression_level", "12");
|
||||
}
|
||||
|
||||
// Map subtitles if present
|
||||
|
Loading…
Reference in New Issue
Block a user