ws.schild.jave.encode.PredicateArgument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jave-core Show documentation
Show all versions of jave-core Show documentation
The JAVE (Java Audio Video Encoder) library is Java wrapper on the
ffmpeg project. Developers can take take advantage of JAVE2 to transcode
audio and video files from a format to another. In example you can transcode
an AVI file to a MPEG one, you can change a DivX video stream into a
(youtube like) Flash FLV one, you can convert a WAV audio file to a MP3 or
a Ogg Vorbis one, you can separate and transcode audio and video tracks,
you can resize videos, changing their sizes and proportions and so on.
Many other formats, containers and operations are supported by JAVE2.
package ws.schild.jave.encode;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
/**
* A PredicateArgument is an EncodingArgument that adds its arguments based on the provided
* predicate
*
* @author mressler
*/
public class PredicateArgument implements EncodingArgument {
private ArgType argumentType;
private Supplier> arguments;
private Predicate predicate;
public PredicateArgument(
ArgType argType, String argument, Predicate predicate) {
this.argumentType = argType;
this.arguments = () -> Stream.of(argument);
this.predicate = predicate;
}
public PredicateArgument(
ArgType argType,
String argument1,
String argument2,
Predicate predicate) {
this.argumentType = argType;
this.arguments = () -> Stream.of(argument1, argument2);
this.predicate = predicate;
}
@Override
public Stream getArguments(EncodingAttributes context) {
if (predicate.test(context)) {
return arguments.get();
} else {
return Stream.empty();
}
}
@Override
public ArgType getArgType() {
return argumentType;
}
}