Search in sources :

Example 1 with InputProcessor

use of org.fagu.fmv.ffmpeg.operation.InputProcessor 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 InputProcessor

use of org.fagu.fmv.ffmpeg.operation.InputProcessor 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)

Example 3 with InputProcessor

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

the class ConcatTestCase method mockInputProcessor.

// *****************************************************
/**
 * @param index
 * @return
 */
private InputProcessor mockInputProcessor(int index) {
    InputProcessor inputProcessor = mock(InputProcessor.class);
    doReturn(Collections.singletonList(Integer.toString(index))).when(inputProcessor).getOutputKeys();
    MediaInput mediaInput = mock(MediaInput.class);
    doReturn(Collections.singletonList(mediaInput)).when(inputProcessor).getInputs();
    return inputProcessor;
}
Also used : InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput)

Example 4 with InputProcessor

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

the class FFMPEGExecutorBuilderTestCase method testInputProcessor_getInput.

/**
 */
@Test
public void testInputProcessor_getInput() {
    MediaInput input = mockInput("/path/file");
    InputProcessor inputProcessor = ffmpegExecutorBuilder.addMediaInput(input);
    assertSame(input, inputProcessor.getInput());
}
Also used : InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput) Test(org.junit.Test)

Example 5 with InputProcessor

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

the class FFMPEGExecutorBuilderTestCase method testInputProcessor_duration.

// ======================== INPUT PROCESSOR ========================
/**
 */
@Test
public void testInputProcessor_duration() {
    MediaInput input = mockInput("/path/file");
    InputProcessor inputProcessor = ffmpegExecutorBuilder.addMediaInput(input);
    inputProcessor.duration(new Duration(1, 2, 3.4));
    assertArgs("-t", "01:02:03.400", "-i", "/path/file");
}
Also used : InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Duration(org.fagu.fmv.utils.time.Duration) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput) Test(org.junit.Test)

Aggregations

InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)43 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)27 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)13 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)12 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)11 MediaInput (org.fagu.fmv.ffmpeg.operation.MediaInput)11 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)9 File (java.io.File)8 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)6 Test (org.junit.Test)6 NullSourceVideo (org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo)5 Duration (org.fagu.fmv.utils.time.Duration)5 Time (org.fagu.fmv.utils.time.Time)5 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 PixelFormat (org.fagu.fmv.ffmpeg.utils.PixelFormat)4