Search in sources :

Example 6 with Type

use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.

the class GenericFilterExec method makeFilter.

/**
 * @see org.fagu.fmv.core.exec.FilterExec#makeFilter(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder, Cache)
 */
@Override
public Filter makeFilter(FFMPEGExecutorBuilder builder, Cache cache) {
    Filter filter = getFilter();
    // parameters
    ObjectInvoker.invoke(filter, attributeMap);
    FilterComplexBase filterComplex = filter instanceof FilterComplexBase ? (FilterComplexBase) filter : FilterComplex.create(filter);
    builder.filter(filterComplex);
    Set<Type> undeclaredTypes = populateWithIdentifiables(filterComplex, cache, builder);
    if (!undeclaredTypes.isEmpty()) {
        undeclaredTypes(undeclaredTypes, filterComplex, cache, builder);
    }
    return filterComplex;
}
Also used : Type(org.fagu.fmv.ffmpeg.operation.Type) Filter(org.fagu.fmv.ffmpeg.filter.Filter) FilterComplexBase(org.fagu.fmv.ffmpeg.filter.FilterComplexBase)

Example 7 with Type

use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.

the class GenericFilterExec method populateWithIdentifiables.

// *************************************************************
/**
 * @param filterComplex
 * @param cache
 * @param builder
 * @return
 */
protected Set<Type> populateWithIdentifiables(FilterComplexBase filterComplex, Cache cache, FFMPEGExecutorBuilder builder) {
    Set<Type> undeclaredTypes = new HashSet<>(filterComplex.getTypes());
    for (Identifiable identifiable : getIdentifiableChildren()) {
        if (identifiable.isExecutable()) {
            File file = getProject().getFileCache().getFile((Executable) identifiable, cache);
            InputProcessor inputProcessor = builder.addMediaInputFile(file);
            addInputIntoFilter(filterComplex, inputProcessor, undeclaredTypes);
        } else if (identifiable.isSource()) {
            FilterInput filterInput = ((Source) identifiable).createAndAdd(builder);
            addInputIntoFilter(filterComplex, filterInput, undeclaredTypes);
        } else if (identifiable.isFilterExec()) {
            Filter inFilter = ((FilterExec) identifiable).makeFilter(builder, cache);
            addInputIntoFilter(filterComplex, (FilterComplexBase) inFilter, undeclaredTypes);
        }
    }
    return undeclaredTypes;
}
Also used : FilterExec(org.fagu.fmv.core.exec.FilterExec) Type(org.fagu.fmv.ffmpeg.operation.Type) Filter(org.fagu.fmv.ffmpeg.filter.Filter) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) File(java.io.File) HashSet(java.util.HashSet) Identifiable(org.fagu.fmv.core.exec.Identifiable)

Example 8 with Type

use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.

the class FilterComplexBase method addInput.

/**
 * @param filterInput
 * @param types
 * @return
 */
public FilterComplexBase addInput(FilterInput filterInput, Type... types) {
    if (filterInput == null) {
        return this;
    }
    boolean inserted = false;
    for (OutputKey outputKey : filterInput.getOutputKeys()) {
        if (types.length == 0) {
            inputMap.put(IOKey.of(outputKey), new In(filterInput));
            inserted = true;
        } else {
            for (Type type : types) {
                if (getTypes().contains(type) && outputKey.contains(type)) {
                    // System.out.println(filterInput + "/" + type + " --> " + this);
                    inputMap.put(IOKey.of(outputKey, type, hasExplicitType()), new In(filterInput, type));
                    inserted = true;
                }
            }
        }
    }
    if (inserted && filterInput instanceof AbstractFilter) {
        AbstractFilter filter = (AbstractFilter) filterInput;
        InjectBuilder.inject(this, filter.operation);
    }
    return this;
}
Also used : Type(org.fagu.fmv.ffmpeg.operation.Type)

Example 9 with Type

use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.

the class FilterGraphUI method createOrGetNode.

/**
 * @param filterComplex
 * @return
 */
private Node createOrGetNode(FilterComplex filterComplex) {
    String nodeKey = getNodeKey(filterComplex);
    Node node = graph.getNode(nodeKey);
    if (node == null) {
        node = graph.addNode(nodeKey);
        node.addAttribute("ui.label", nodeKey);
        Collection<Type> types = filterComplex.getTypes();
        String ccsStyle = null;
        if (types.contains(Type.AUDIO) && !types.contains(Type.VIDEO)) {
            ccsStyle = "audio";
        } else if (!types.contains(Type.AUDIO) && types.contains(Type.VIDEO)) {
            ccsStyle = "video";
        }
        if (ccsStyle != null) {
            node.setAttribute("ui.class", ccsStyle);
        }
    }
    return node;
}
Also used : Type(org.fagu.fmv.ffmpeg.operation.Type) Node(org.graphstream.graph.Node)

Aggregations

Type (org.fagu.fmv.ffmpeg.operation.Type)9 File (java.io.File)3 Filter (org.fagu.fmv.ffmpeg.filter.Filter)3 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)3 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)2 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)2 Stream (org.fagu.fmv.ffmpeg.metadatas.Stream)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 StringJoiner (java.util.StringJoiner)1 FilterExec (org.fagu.fmv.core.exec.FilterExec)1 Identifiable (org.fagu.fmv.core.exec.Identifiable)1 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)1 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)1 FilterComplexBase (org.fagu.fmv.ffmpeg.filter.FilterComplexBase)1 GeneratedSource (org.fagu.fmv.ffmpeg.filter.GeneratedSource)1 AudioStream (org.fagu.fmv.ffmpeg.metadatas.AudioStream)1 SubtitleStream (org.fagu.fmv.ffmpeg.metadatas.SubtitleStream)1 MediaInput (org.fagu.fmv.ffmpeg.operation.MediaInput)1 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)1