All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ws.schild.jave.encode.ValueArgument Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.5.0
Show newest version
package ws.schild.jave.encode;

import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;

/**
 * A ValueArgument is an EncodingArgument that is optionally present based on the presence of the
 * provided valueGetter.
 *
 * @author mressler
 */
public class ValueArgument implements EncodingArgument {

  private ArgType argumentType;
  private String argumentName;
  private Function> valueGetter;

  public ValueArgument(
      ArgType argType,
      String argumentName,
      Function> valueGetter) {
    this.argumentType = argType;
    this.argumentName = argumentName;
    this.valueGetter = valueGetter;
  }

  protected Boolean isPresent(EncodingAttributes context) {
    return getValue(context).isPresent();
  }

  @Override
  public Stream getArguments(EncodingAttributes context) {
    return getValue(context).map(value -> Stream.of(getName(), value)).orElseGet(Stream::empty);
  }

  private String getName() {
    return argumentName;
  }

  private Optional getValue(EncodingAttributes context) {
    return valueGetter.apply(context);
  }

  @Override
  public ArgType getArgType() {
    return argumentType;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy