Search in sources :

Example 51 with FFMPEGExecutorBuilder

use of org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder in project fmv by f-agu.

the class ConcatFadeExecutable method execute.

/**
 * @see org.fagu.fmv.core.exec.Executable#execute()
 */
@Override
public void execute(File toFile, Cache cache) throws IOException {
    if (!hasChildren()) {
        return;
    }
    FFMPEGExecutorBuilder builder = FFUtils.builder(getProject());
    List<InputProcessor> inputProcessors = new ArrayList<>();
    // executable
    for (Executable executable : executables) {
        File file = getProject().getFileCache().getFile(executable, cache);
        InputProcessor inputProcessor = builder.addMediaInputFile(file);
        // audioMix.addInput(inputProcessor);
        inputProcessors.add(inputProcessor);
    }
    // source
    for (Source source : sources) {
        FilterInput filterInput = source.createAndAdd(builder);
        if (filterInput instanceof InputProcessor) {
            inputProcessors.add((InputProcessor) filterInput);
        // MovieMetadatas movieMetadatas = ((InputProcessor)filterInput).getMovieMetadatas();
        // if(movieMetadatas.contains(Type.AUDIO)) {
        // audioMix.addInput(filterInput, audioStart);
        // } else {
        // throw new RuntimeException("Source is not an audio stream: " + source);
        // }
        } else {
            throw new RuntimeException("Source is not a InputProcessor: " + source);
        }
    }
    applyConcatFade(builder, inputProcessors, toFile, cache);
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) ArrayList(java.util.ArrayList) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Executable(org.fagu.fmv.core.exec.Executable) File(java.io.File) Source(org.fagu.fmv.core.exec.Source)

Example 52 with FFMPEGExecutorBuilder

use of org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder in project fmv by f-agu.

the class GenericExecutable method execute.

/**
 * @see org.fagu.fmv.core.exec.Executable#execute()
 */
@Override
public void execute(File toFile, Cache cache) throws IOException {
    if (!hasChildren()) {
        return;
    }
    FFMPEGExecutorBuilder builder = FFUtils.builder(getProject());
    populateWithIdentifiables(toFile, cache, builder);
    OutputProcessor outputProcessor = outputProcessor(builder, toFile, cache);
    ObjectInvoker.invoke(outputProcessor, attributeMap);
    fixOutput(outputProcessor);
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) OutputProcessor(org.fagu.fmv.ffmpeg.operation.OutputProcessor)

Example 53 with FFMPEGExecutorBuilder

use of org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder in project fmv by f-agu.

the class FFUtils method builder.

/**
 * @param project
 * @return
 */
public static FFMPEGExecutorBuilder builder(Project project) {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.hideBanner();
    if (project.getProperty(Properties.SHOW_COMMAND_LINE)) {
        builder.addListener(new OperationListener() {

            /**
             * @see org.fagu.fmv.ffmpeg.operation.OperationListenerAdaptor#eventCreate(org.fagu.fmv.ffmpeg.executor.FFExecutor)
             */
            @Override
            public void eventCreate(FFExecutor<?> ffExecutor) {
                try {
                    System.out.println(ffExecutor.getCommandLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    return builder;
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) OperationListener(org.fagu.fmv.ffmpeg.operation.OperationListener)

Example 54 with FFMPEGExecutorBuilder

use of org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder in project fmv by f-agu.

the class RipperTestCase method ffMPEGExecutorBuilder.

/**
 * @return
 * @throws IOException
 */
private FFMPEGExecutorBuilder ffMPEGExecutorBuilder() throws IOException {
    FFMPEGExecutorBuilder builder = mock(FFMPEGExecutorBuilder.class);
    doReturn(builder).when(builder).hideBanner();
    doReturn(builder).when(builder).noStats();
    InputProcessor inputProcessor = mock(InputProcessor.class);
    doReturn(inputProcessor).when(builder).addMediaInputFile(any(File.class));
    MovieMetadatas movieMetadatas = mock(MovieMetadatas.class);
    doReturn(movieMetadatas).when(inputProcessor).getMovieMetadatas();
    OutputProcessor outputProcessor = mock(OutputProcessor.class);
    doReturn(outputProcessor).when(builder).addMediaOutputFile(any(File.class));
    doReturn(outputProcessor).when(outputProcessor).codec(any(Coder.class));
    return builder;
}
Also used : Coder(org.fagu.fmv.ffmpeg.coder.Coder) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) OutputProcessor(org.fagu.fmv.ffmpeg.operation.OutputProcessor) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) File(java.io.File)

Example 55 with FFMPEGExecutorBuilder

use of org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder in project fmv by f-agu.

the class MockFFMPEGExecutorBuilder method mock.

/**
 * @param movieMetadatasSupplier
 * @param commandExecute
 */
public static void mock(Supplier<Function<String, MovieMetadatas>> movieMetadatasSupplier, final Consumer<String> commandExecute) {
    FFMPEGExecutorBuilder.setFactory(() -> {
        final FFExecutorFactory ffExecutorFactory = new FFExecutorFactory() {

            @Override
            public <R> FFExecutor<R> create(Operation<R, ?> operation, FFMPEGExecutorBuilder ffmpegExecutorBuilder) {
                return new FFExecutor<R>(operation) {

                    /**
                     * @see org.fagu.fmv.ffmpeg.executor.FFExecutor#execute()
                     */
                    @Override
                    public Executed<R> execute() throws IOException {
                        commandExecute.accept(getCommandLine());
                        return null;
                    }
                };
            }
        };
        Require require = new Require(false);
        DefaultFFMPEGOperation<?> defaultFFMPEGOperation = new DefaultFFMPEGOperation<Object>(new FilterNaming(), require);
        defaultFFMPEGOperation.getInputParameters().setInputProcessorFactory(new InputProcessorFactory() {

            /**
             * @see org.fagu.fmv.ffmpeg.operation.InputProcessorFactory#create(org.fagu.fmv.ffmpeg.operation.InputParameters,
             *      org.fagu.fmv.ffmpeg.operation.MediaInput, int, org.fagu.fmv.ffmpeg.require.Require)
             */
            @Override
            public InputProcessor create(InputParameters inputParameters, MediaInput input, int index, Require require) {
                return new MyInputProcessor(movieMetadatasSupplier.get(), inputParameters, input, index, require);
            }
        });
        return new MyFFMPEGExecutorBuilder(ffExecutorFactory, defaultFFMPEGOperation);
    });
}
Also used : FFExecutorFactory(org.fagu.fmv.ffmpeg.executor.FFExecutorFactory) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) Require(org.fagu.fmv.ffmpeg.require.Require) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Operation(org.fagu.fmv.ffmpeg.operation.Operation) DefaultFFMPEGOperation(org.fagu.fmv.ffmpeg.operation.DefaultFFMPEGOperation) DefaultFFMPEGOperation(org.fagu.fmv.ffmpeg.operation.DefaultFFMPEGOperation) FFExecutor(org.fagu.fmv.ffmpeg.executor.FFExecutor) InputProcessorFactory(org.fagu.fmv.ffmpeg.operation.InputProcessorFactory) FilterNaming(org.fagu.fmv.ffmpeg.filter.FilterNaming) InputParameters(org.fagu.fmv.ffmpeg.operation.InputParameters) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput)

Aggregations

FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)55 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)27 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)19 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)16 File (java.io.File)12 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)11 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)9 Size (org.fagu.fmv.utils.media.Size)6 Concat (org.fagu.fmv.ffmpeg.filter.impl.Concat)5 IOException (java.io.IOException)4 OptionalInt (java.util.OptionalInt)4 AudioGenerator (org.fagu.fmv.ffmpeg.filter.impl.AudioGenerator)4 NullSourceVideo (org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo)4 Progress (org.fagu.fmv.ffmpeg.operation.Progress)4 Duration (org.fagu.fmv.utils.time.Duration)4 Executable (org.fagu.fmv.core.exec.Executable)3 Source (org.fagu.fmv.core.exec.Source)3 OutputInfos (org.fagu.fmv.core.project.OutputInfos)3 MixAudioDuration (org.fagu.fmv.ffmpeg.filter.impl.AudioMix.MixAudioDuration)3 Blend (org.fagu.fmv.ffmpeg.filter.impl.Blend)3