Search in sources :

Example 21 with FilterComplex

use of org.fagu.fmv.ffmpeg.filter.FilterComplex in project fmv by f-agu.

the class AbstractOperation method toArguments.

/**
 * @see org.fagu.fmv.ffmpeg.operation.Operation#toArguments()
 */
@Override
public List<String> toArguments() {
    OperationListener operationListener = operationListener();
    operationListener.eventPreToArguments(this);
    List<String> arguments = new ArrayList<>();
    // global
    getGlobalParameters().toArguments(arguments);
    // input
    getInputParameters().toArguments(arguments);
    // filter_complex
    if (containsFilterComplexs()) {
        List<FilterComplex> filterComplexs = getFilterComplexs();
        arguments.add("-filter_complex");
        StringBuilder fbuf = new StringBuilder();
        Iterator<FilterComplex> it = filterComplexs.iterator();
        boolean useLabels = autoMap.useLabels();
        for (; ; ) {
            FilterComplex f = it.next();
            if (!useLabels) {
                f.clearInput();
                f.clearOutput();
            }
            fbuf.append(f.toString());
            if (!it.hasNext()) {
                break;
            }
            fbuf.append(';');
        }
        arguments.add(fbuf.toString());
        if (!containsMap()) {
            // auto-map
            try {
                for (Label label : autoMap.find(this)) {
                    arguments.add("-map");
                    arguments.add(filterNaming.generateBrackets(label));
                }
            } catch (RuntimeException e) {
                throw new RuntimeException(arguments.toString(), e);
            }
        }
    } else {
        // filter
        for (Type type : Type.values()) {
            StringBuilder fbuf = new StringBuilder();
            List<Filter> filterSimples = getFilterSimples(type);
            if (!filterSimples.isEmpty()) {
                Iterator<Filter> it = filterSimples.iterator();
                for (; ; ) {
                    Filter f = it.next();
                    fbuf.append(f.toString());
                    if (!it.hasNext()) {
                        break;
                    }
                    fbuf.append(',');
                }
                String fstr = fbuf.toString();
                if (StringUtils.isNotBlank(fstr)) {
                    arguments.add("-filter:" + type.code());
                    arguments.add(fstr);
                }
            }
        }
    }
    // output
    getOutputParameters().toArguments(arguments);
    operationListener.eventPostToArguments(this);
    return arguments;
}
Also used : FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) ArrayList(java.util.ArrayList) Label(org.fagu.fmv.ffmpeg.filter.Label) Filter(org.fagu.fmv.ffmpeg.filter.Filter)

Aggregations

FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)21 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)11 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)11 NullSourceVideo (org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo)5 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)5 Duration (org.fagu.fmv.utils.time.Duration)5 Filter (org.fagu.fmv.ffmpeg.filter.Filter)4 AudioGenerator (org.fagu.fmv.ffmpeg.filter.impl.AudioGenerator)4 MixAudioDuration (org.fagu.fmv.ffmpeg.filter.impl.AudioMix.MixAudioDuration)4 Blend (org.fagu.fmv.ffmpeg.filter.impl.Blend)4 Concat (org.fagu.fmv.ffmpeg.filter.impl.Concat)4 Format (org.fagu.fmv.ffmpeg.filter.impl.Format)4 SetSAR (org.fagu.fmv.ffmpeg.filter.impl.SetSAR)4 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)4 PixelFormat (org.fagu.fmv.ffmpeg.utils.PixelFormat)4 Time (org.fagu.fmv.utils.time.Time)4 ArrayList (java.util.ArrayList)3 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)3 Label (org.fagu.fmv.ffmpeg.filter.Label)3 OutputKey (org.fagu.fmv.ffmpeg.filter.OutputKey)3