Search in sources :

Example 1 with GeneratedSource

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

the class Concat method beforeAddAround.

// ****************************************************
/**
 * @param operation
 * @param filterNaming
 */
@Override
protected void beforeAddAround(Operation<?, ?> operation, FilterNaming filterNaming) {
    // copy pour acces concurrent
    ArrayList<Object> arrayList = new ArrayList<>(inputs);
    for (Object input : arrayList) {
        Object inputObj = null;
        Set<Type> types = Collections.emptySet();
        if (input instanceof File) {
            InputProcessor inputProcessor = builder.addMediaInputFile((File) input);
            inputObj = inputProcessor;
            types = getTypes(inputProcessor);
        } else if (input instanceof InputProcessor) {
            types = getTypes((InputProcessor) input);
            inputObj = input;
        } else if (input instanceof FilterComplex) {
            inputObj = input;
            types = ((FilterComplex) input).getTypes();
        } else if (input instanceof Filter) {
            throw new IllegalArgumentException("Filter forbidden: " + input.getClass().getName() + ". Wrap it with FilterComplex.create(...).");
        }
        if (startAtStartTime && inputObj != null) {
            boolean startAt = true;
            FilterInput filterInput = (FilterInput) inputObj;
            for (MediaInput mediaInput : filterInput.getInputs()) {
                if (mediaInput instanceof GeneratedSource) {
                    startAt = false;
                    break;
                }
            }
            if (startAt) {
                if (types.contains(Type.VIDEO) && (countVideo == null || countVideo != 0)) {
                    addPTS(builder, SetPTSVideo.build(), inputObj);
                }
                if (types.contains(Type.AUDIO) && (countAudio == null || countAudio != 0)) {
                    addPTS(builder, SetPTSAudio.build(), inputObj);
                }
            } else {
                builder.filter((Filter) inputObj);
                super.addInput((FilterInput) inputObj);
            }
        } else if (input instanceof FilterInput) {
            builder.filter((Filter) inputObj);
            super.addInput((FilterInput) input);
        } else {
            throw new IllegalArgumentException(input.getClass().getName());
        }
    }
}
Also used : FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) ArrayList(java.util.ArrayList) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) GeneratedSource(org.fagu.fmv.ffmpeg.filter.GeneratedSource) Type(org.fagu.fmv.ffmpeg.operation.Type) Filter(org.fagu.fmv.ffmpeg.filter.Filter) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) File(java.io.File) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput)

Example 2 with GeneratedSource

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

the class FilterGraph method of.

/**
 * @param operation
 * @param filterNaming
 * @return
 */
public static FilterGraph of(Operation<?, ?> operation) {
    FilterGraph filterGraph = new FilterGraph(operation.getFilterNaming());
    List<FilterComplex> filterComplexs = operation.getFilterComplexs();
    for (FilterComplex filterComplex : filterComplexs) {
        // System.out.println(filterComplex);
        Map<IOKey, In> inputMap = filterComplex.getInputMap();
        if (inputMap.isEmpty()) {
            for (MediaInput mediaInput : filterComplex.getInputs()) {
                if (mediaInput instanceof GeneratedSource) {
                    filterGraph.roots.add(filterComplex);
                    for (OutputKey outputKey : filterComplex.getOutputKeys()) {
                        filterGraph.byOutMap.add(outputKey.getLabel(), filterComplex);
                    }
                }
            }
        } else {
            for (Entry<IOKey, In> entry : inputMap.entrySet()) {
                FilterInput filterInput = entry.getValue().getFilterInput();
                for (OutputKey inputKey : filterInput.getOutputKeys()) {
                    filterGraph.byInMap.add(inputKey.getLabel(), filterComplex);
                }
                if (filterInput instanceof InputProcessor) {
                    filterGraph.roots.add(filterComplex);
                }
                for (OutputKey outputKey : filterComplex.getOutputKeys()) {
                    filterGraph.byOutMap.add(outputKey.getLabel(), filterComplex);
                }
            }
        }
    }
    return filterGraph;
}
Also used : IOKey(org.fagu.fmv.ffmpeg.filter.IOKey) FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) In(org.fagu.fmv.ffmpeg.filter.FilterComplexBase.In) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) GeneratedSource(org.fagu.fmv.ffmpeg.filter.GeneratedSource) OutputKey(org.fagu.fmv.ffmpeg.filter.OutputKey) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput)

Aggregations

FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)2 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)2 GeneratedSource (org.fagu.fmv.ffmpeg.filter.GeneratedSource)2 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)2 MediaInput (org.fagu.fmv.ffmpeg.operation.MediaInput)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Filter (org.fagu.fmv.ffmpeg.filter.Filter)1 In (org.fagu.fmv.ffmpeg.filter.FilterComplexBase.In)1 IOKey (org.fagu.fmv.ffmpeg.filter.IOKey)1 OutputKey (org.fagu.fmv.ffmpeg.filter.OutputKey)1 Type (org.fagu.fmv.ffmpeg.operation.Type)1