Skip to content

Commit

Permalink
Add ID constant for all parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
aNNiMON committed Jul 2, 2024
1 parent 1ba8208 commit 72a623e
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import java.util.List;

public class AudioBitrate extends StringParameter {
public static final String ID = "abitrate";
private static final List<String> VALUES = List.of(
"4k", "16k", "32k", "", "64k", "128k",
"256k", "320k", "512k"
);

public AudioBitrate() {
super("abitrate", "\uD83D\uDD08 Bitrate", VALUES, "");
super(ID, "\uD83D\uDD08 Bitrate", VALUES, "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import java.util.List;

public class AudioCrystalizer extends StringParameter {
public static final String ID = "crystalizer";
private static final List<String> VALUES = List.of(
"-8", "-4", "-2", "0", "2", "4", "8"
);

public AudioCrystalizer() {
super("crystalizer", "\uD83D\uDD08 Crystalizer", VALUES, "0");
super(ID, "\uD83D\uDD08 Crystalizer", VALUES, "0");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.List;

public class AudioEffect extends StringParameter {
public static final String ID = "aeffect";

public static final String ROBOT = "Robot";
public static final String ECHO = "Echo";
public static final String ECHO_2 = "Echo 2";
Expand All @@ -18,7 +20,7 @@ public class AudioEffect extends StringParameter {
);

public AudioEffect() {
super("aeffect", "\uD83D\uDD08 Effect", VALUES, "");
super(ID, "\uD83D\uDD08 Effect", VALUES, "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import java.util.List;

public class AudioPitch extends StringParameter {
public static final String ID = "apitch";
private static final List<String> VALUES = List.of(
"0.6", "0.8", "0.9",
"1",
"1.15", "1.25", "1.5", "2"
);

public AudioPitch() {
super("apitch", "\uD83D\uDD08 Pitch", VALUES, "1");
super(ID, "\uD83D\uDD08 Pitch", VALUES, "1");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import java.util.List;

public class AudioStreamByLanguage extends StringParameter {
public static final String ID = "asellang";
private static final List<String> VALUES = List.of(
"", "eng", "fra", "ita", "ukr", "spa"
);

public AudioStreamByLanguage() {
super("asellang", "Audio Track", VALUES, "");
super(ID, "Audio Track", VALUES, "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import java.util.List;

public class AudioVolume extends StringParameter {
public static final String ID = "volume";
private static final List<String> VALUES = List.of(
"-15dB", "-10dB", "-5dB", "-2dB",
"", "2dB", "5dB", "10dB",
"15dB", "30dB", "50dB"
);

public AudioVolume() {
super("volume", "\uD83D\uDD08 Volume", VALUES, "");
super(ID, "\uD83D\uDD08 Volume", VALUES, "");
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/annimon/ffmpegbot/parameters/Contrast.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import java.util.List;

public class Contrast extends StringParameter {
public static final String ID = "contrast";
private static final List<String> 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");
super(ID, "Contrast", VALUES, "1");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.annimon.ffmpegbot.commands.ffmpeg.Visitor;

public class DisableAudio extends BooleanParameter {
public static final String ID = "noaud";

public DisableAudio() {
super("noaud", "Disable audio", false);
super(ID, "Disable audio", false);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/annimon/ffmpegbot/parameters/Gamma.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import java.util.List;

public class Gamma extends StringParameter {
public static final String ID = "gamma";
private static final List<String> 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");
super(ID, "Gamma", VALUES, "1");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import java.util.List;

public class OutputFormat extends StringParameter {
public static final String ID = "output";

public static final String VIDEO = "VIDEO";
public static final String AUDIO = "AUDIO";
public static final String VIDEO_NOTE = "VIDEO NOTE";

public OutputFormat(List<String> values, String initialValue) {
super("output", "➡\uFE0F Output", values, initialValue);
super(ID, "➡\uFE0F Output", values, initialValue);
}

@Override
Expand Down
24 changes: 18 additions & 6 deletions src/main/java/com/annimon/ffmpegbot/parameters/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,41 @@

public class Parameters extends AbstractCollection<Parameter<?>> {

private final Map<String, Parameter<?>> parameters;
private final Map<String, Parameter<?>> enabledParameters;
private final Map<String, Parameter<?>> disabledParameters;

public Parameters() {
parameters = new LinkedHashMap<>();
enabledParameters = new LinkedHashMap<>();
disabledParameters = new LinkedHashMap<>();
}

@Override
public boolean add(Parameter<?> parameter) {
return !Objects.equals(parameter, parameters.put(parameter.id, parameter));
return !Objects.equals(parameter, enabledParameters.put(parameter.id, parameter));
}

public Parameter<?> findById(String id) {
return parameters.get(id);
return enabledParameters.get(id);
}

public void disable(String id) {
Optional.ofNullable(findById(id))
.ifPresent(p -> disabledParameters.put(p.id, p));
}

public void enable(String id) {
Optional.ofNullable(disabledParameters.get(id))
.ifPresent(this::add);
}

@NotNull
@Override
public Iterator<Parameter<?>> iterator() {
return parameters.values().iterator();
return enabledParameters.values().iterator();
}

@Override
public int size() {
return parameters.size();
return enabledParameters.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import java.util.List;

public class Saturation extends StringParameter {
public static final String ID = "saturation";
private static final List<String> 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");
super(ID, "Saturation", VALUES, "1");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import java.util.List;

public class SpeedFactor extends StringParameter {
public static final String ID = "speed";
private static final List<String> VALUES = List.of(
"0.5", "0.75", "0.8", "0.9",
"1", "1.25", "1.4", "1.5",
"1.6", "1.8", "2", "2.5", "3"
);

public SpeedFactor() {
super("speed", "Speed", VALUES, "1");
super(ID, "Speed", VALUES, "1");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import java.util.List;

public class VideoBitrate extends StringParameter {
public static final String ID = "vbitrate";
private static final List<String> VALUES = List.of(
"16k", "32k", "", "64k", "128k", "256k",
"512k", "1M", "2M", "4M", "8M", "16M"
);

public VideoBitrate() {
super("vbitrate", "Video bitrate", VALUES, "");
super(ID, "Video bitrate", VALUES, "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import java.util.List;

public class VideoFrameRate extends StringParameter {
public static final String ID = "vfr";
private static final List<String> VALUES = List.of(
"5", "10", "15", "20", "25", "", "30", "45", "60"
);

public VideoFrameRate() {
super("vfr", "Frame rate", VALUES, "");
super(ID, "Frame rate", VALUES, "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import java.util.List;

public class VideoScale extends StringParameter {
public static final String ID = "scale";
private static final List<String> VALUES = List.of(
"144", "240", "360", "", "480", "720", "1080"
);

public VideoScale() {
super("scale", "Scale", VALUES, "");
super(ID, "Scale", VALUES, "");
}

@Override
Expand Down

0 comments on commit 72a623e

Please sign in to comment.