001package net.bramp.ffmpeg;
002
003import static com.google.common.base.Preconditions.checkNotNull;
004
005import java.io.IOException;
006import net.bramp.ffmpeg.builder.FFmpegBuilder;
007import net.bramp.ffmpeg.job.FFmpegJob;
008import net.bramp.ffmpeg.job.SinglePassFFmpegJob;
009import net.bramp.ffmpeg.job.TwoPassFFmpegJob;
010import net.bramp.ffmpeg.progress.ProgressListener;
011
012public class FFmpegExecutor {
013
014  final FFmpeg ffmpeg;
015  final FFprobe ffprobe;
016
017  public FFmpegExecutor() throws IOException {
018    this(new FFmpeg(), new FFprobe());
019  }
020
021  public FFmpegExecutor(FFmpeg ffmpeg) throws IOException {
022    this(ffmpeg, new FFprobe());
023  }
024
025  public FFmpegExecutor(FFmpeg ffmpeg, FFprobe ffprobe) {
026    this.ffmpeg = checkNotNull(ffmpeg);
027    this.ffprobe = checkNotNull(ffprobe);
028  }
029
030  public FFmpegJob createJob(FFmpegBuilder builder) {
031    return new SinglePassFFmpegJob(ffmpeg, builder);
032  }
033
034  public FFmpegJob createJob(FFmpegBuilder builder, ProgressListener listener) {
035    return new SinglePassFFmpegJob(ffmpeg, builder, listener);
036  }
037
038  /**
039   * Creates a two pass job, which will execute FFmpeg twice to produce a better quality output.
040   * More info: https://trac.ffmpeg.org/wiki/x264EncodingGuide#twopass
041   *
042   * @param builder The FFmpegBuilder
043   * @return A new two-pass FFmpegJob
044   */
045  public FFmpegJob createTwoPassJob(FFmpegBuilder builder) {
046    return new TwoPassFFmpegJob(ffmpeg, builder);
047  }
048}