diff --git a/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/FFmpegCommandBuilder.java b/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/FFmpegCommandBuilder.java index cf2fb3c..7ec4a43 100644 --- a/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/FFmpegCommandBuilder.java +++ b/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/FFmpegCommandBuilder.java @@ -18,12 +18,14 @@ public class FFmpegCommandBuilder implements Visitor { private final List videoCommands; private final List audioFilters; private final List videoFilters; + private final List eq; public FFmpegCommandBuilder() { audioCommands = new ArrayList<>(); videoCommands = new ArrayList<>(); audioFilters = new ArrayList<>(); videoFilters = new ArrayList<>(); + eq = new ArrayList<>(); } @Override @@ -80,6 +82,27 @@ public class FFmpegCommandBuilder implements Visitor { audioCommands.add("0:m:language:" + p.getValue()); } + @Override + public void visit(Contrast p, MediaSession input) { + String value = p.getValue(); + if (value.equals("1")) return; + eq.add("contrast=" + value); + } + + @Override + public void visit(Gamma p, MediaSession input) { + String value = p.getValue(); + if (value.equals("1")) return; + eq.add("gamma=" + value); + } + + @Override + public void visit(Saturation p, MediaSession input) { + String value = p.getValue(); + if (value.equals("1")) return; + eq.add("saturation=" + value); + } + @Override public void visit(SpeedFactor p, MediaSession input) { if (p.getValue().equals("1")) return; @@ -148,6 +171,9 @@ public class FFmpegCommandBuilder implements Visitor { } if (FileTypes.canContainVideo(session.getFileType())) { commands.addAll(videoCommands); + if (!eq.isEmpty()) { + videoFilters.add("eq=" + String.join(":", eq)); + } if (!videoFilters.isEmpty()) { commands.add("-vf"); commands.add(String.join(",", videoFilters)); diff --git a/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/Visitor.java b/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/Visitor.java index ccb279e..47bb6cc 100644 --- a/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/Visitor.java +++ b/src/main/java/com/annimon/ffmpegbot/commands/ffmpeg/Visitor.java @@ -9,6 +9,9 @@ public interface Visitor { void visit(AudioPitch p, I input); void visit(AudioVolume p, I input); void visit(AudioStreamByLanguage p, I input); + void visit(Contrast p, I input); + void visit(Gamma p, I input); + void visit(Saturation p, I input); void visit(SpeedFactor p, I input); void visit(VideoBitrate p, I input); void visit(VideoScale p, I input); diff --git a/src/main/java/com/annimon/ffmpegbot/parameters/Contrast.java b/src/main/java/com/annimon/ffmpegbot/parameters/Contrast.java new file mode 100644 index 0000000..abfa02c --- /dev/null +++ b/src/main/java/com/annimon/ffmpegbot/parameters/Contrast.java @@ -0,0 +1,26 @@ +package com.annimon.ffmpegbot.parameters; + +import com.annimon.ffmpegbot.commands.ffmpeg.Visitor; +import java.util.List; + +public class Contrast extends StringParameter { + private static final List VALUES = List.of( + "0.4", "0.6", "0.8", + "1", "1.2", "1.4", "1.6", + "1.8", "2" + ); + + public Contrast() { + super("contrast", "Contrast", VALUES, "1"); + } + + @Override + public int defaultColumnsCount() { + return 3; + } + + @Override + public void accept(Visitor visitor, I input) { + visitor.visit(this, input); + } +} diff --git a/src/main/java/com/annimon/ffmpegbot/parameters/Gamma.java b/src/main/java/com/annimon/ffmpegbot/parameters/Gamma.java new file mode 100644 index 0000000..31908b5 --- /dev/null +++ b/src/main/java/com/annimon/ffmpegbot/parameters/Gamma.java @@ -0,0 +1,26 @@ +package com.annimon.ffmpegbot.parameters; + +import com.annimon.ffmpegbot.commands.ffmpeg.Visitor; +import java.util.List; + +public class Gamma extends StringParameter { + private static final List VALUES = List.of( + "0.2", "0.4", "0.6", "0.8", + "1", "1.2", "1.4", "1.6", + "1.8", "2", "2.2", "2.4" + ); + + public Gamma() { + super("gamma", "Gamma", VALUES, "1"); + } + + @Override + public int defaultColumnsCount() { + return 4; + } + + @Override + public void accept(Visitor visitor, I input) { + visitor.visit(this, input); + } +} diff --git a/src/main/java/com/annimon/ffmpegbot/parameters/Saturation.java b/src/main/java/com/annimon/ffmpegbot/parameters/Saturation.java new file mode 100644 index 0000000..b067c16 --- /dev/null +++ b/src/main/java/com/annimon/ffmpegbot/parameters/Saturation.java @@ -0,0 +1,26 @@ +package com.annimon.ffmpegbot.parameters; + +import com.annimon.ffmpegbot.commands.ffmpeg.Visitor; +import java.util.List; + +public class Saturation extends StringParameter { + private static final List VALUES = List.of( + "0", "0.25", "0.5", "0.75", + "1", "1.25", "1.5", "1.75", + "2", "2.25", "2.5", "3" + ); + + public Saturation() { + super("saturation", "Saturation", VALUES, "1"); + } + + @Override + public int defaultColumnsCount() { + return 4; + } + + @Override + public void accept(Visitor visitor, I input) { + visitor.visit(this, input); + } +} diff --git a/src/main/java/com/annimon/ffmpegbot/parameters/resolvers/VideoResolver.java b/src/main/java/com/annimon/ffmpegbot/parameters/resolvers/VideoResolver.java index ced77b6..0bb42d5 100644 --- a/src/main/java/com/annimon/ffmpegbot/parameters/resolvers/VideoResolver.java +++ b/src/main/java/com/annimon/ffmpegbot/parameters/resolvers/VideoResolver.java @@ -16,6 +16,9 @@ public class VideoResolver implements ParametersResolver { if (hasVideo) { parameters.addAll(List.of( + new Contrast(), + new Gamma(), + new Saturation(), new VideoBitrate(), new VideoScale(), new VideoFrameRate()