package com.annimon.tsvc.model;

/**
 * FFmpeg command line options
 * 
 * @author aNNiMON
 */
public final class FFmpegOptions {

    private String input;
    private double speedFactor;
    private boolean isAudio;
    private String output;

    public FFmpegOptions() {
        speedFactor = 1d;
        isAudio = true;
    }

    public FFmpegOptions(String input, double speedFactor, boolean isAudio, String output) {
        this.input = input;
        this.speedFactor = speedFactor;
        this.isAudio = isAudio;
        this.output = output;
    }

    public String getInput() {
        return input;
    }

    public void setInput(String input) {
        this.input = input;
    }

    public double getSpeedFactor() {
        return speedFactor;
    }

    public void setSpeedFactor(double speedFactor) {
        this.speedFactor = speedFactor;
    }

    public boolean isIsAudio() {
        return isAudio;
    }

    public void setIsAudio(boolean isAudio) {
        this.isAudio = isAudio;
    }

    public String getOutput() {
        return output;
    }

    public void setOutput(String output) {
        this.output = output;
    }
    
    public String buildOptions() {
        final StringBuilder sb = new StringBuilder();
        sb.append(" -i ").append('"').append(input).append('"');
        if (speedFactor < 1d) {
            sb.append(" -filter:v ").append('"').append("setpts=").append(speedFactor).append("*PTS").append('"');
        }
        if (!isAudio) {
            sb.append(" -an");
        }
        sb.append(' ').append('"').append(output).append('"');
        return sb.toString();
    }

    @Override
    public String toString() {
        return buildOptions();
    }
}

@@ -26,16 +26,164 @@
 model;%0A%0A
+import java.text.DecimalFormat;%0Aimport java.text.DecimalFormatSymbols;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Locale;%0A%0A
 /**%0A * F
@@ -1540,76 +1540,27 @@
 end(
-'%22').append(%22setpts=%22).append(speedFactor).append(%22*PTS%22).append('%22'
+speedFactorFormat()
 );%0A 
@@ -1688,32 +1688,32 @@
 t).append('%22');%0A
-
         return s
@@ -1727,24 +1727,661 @@
 ing();%0A    %7D
+%0A    %0A    public List%3CString%3E buildOptionsAsList() %7B%0A        final List%3CString%3E args = new ArrayList%3C%3E(10);%0A        args.add(%22-i%22);%0A        args.add(input);%0A        if (speedFactor %3C 1d) %7B%0A            args.add(%22-filter:v%22);%0A            args.add(speedFactorFormat());%0A        %7D%0A        if (!isAudio) %7B%0A            args.add(%22-an%22);%0A        %7D%0A        args.add(output);%0A        return args;%0A    %7D%0A    %0A    private String speedFactorFormat() %7B%0A        return String.format(%22%5C%22setpts=%25s*PTS%5C%22%22, %0A                new DecimalFormat(%22#.#####%22, DecimalFormatSymbols.getInstance(Locale.ENGLISH))%0A                        .format(speedFactor));%0A    %7D
 %0A%0A    @Overr

Fix speedFactor formatting