Search in sources :

Example 6 with FFExecutor

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

the class FFHelper method videoMetadatas.

/**
 * @param inFile
 * @return
 * @throws IOException
 */
public static MovieMetadatas videoMetadatas(File inFile) throws IOException {
    MediaInput input = new FileMediaInput(inFile);
    InfoOperation infoOperation = new InfoOperation(input);
    FFExecutor<MovieMetadatas> executor = new FFExecutor<>(infoOperation);
    Executed<MovieMetadatas> execute = executor.execute();
    return execute.getResult();
}
Also used : MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) FFExecutor(org.fagu.fmv.ffmpeg.executor.FFExecutor) FileMediaInput(org.fagu.fmv.ffmpeg.ioe.FileMediaInput) FileMediaInput(org.fagu.fmv.ffmpeg.ioe.FileMediaInput) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput) InfoOperation(org.fagu.fmv.ffmpeg.operation.InfoOperation)

Example 7 with FFExecutor

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

Example 8 with FFExecutor

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

the class AudioSampleFormat method runnable.

/**
 * @return
 */
private static Runnable runnable() {
    return () -> {
        LinesFFMPEGOperation operation = new LinesFFMPEGOperation();
        operation.addParameter("-sample_fmts");
        try {
            FFExecutor<List<String>> executor = new FFExecutor<>(operation);
            Consumer<AudioSampleFormatHelp> cacheConsumer = HELP_CACHE.consumer();
            AvailableHelp<AudioSampleFormatHelp> availableHelp = AvailableHelp.create();
            availableHelp.title().legend().reader(l -> {
                if (StringUtils.isBlank(l)) {
                    return false;
                }
                String name = StringUtils.substringBefore(l, " ");
                int depth = Integer.parseInt(StringUtils.substringAfter(l, " ").trim());
                cacheConsumer.accept(new AudioSampleFormatHelp(name, depth));
                return true;
            }).parse(executor.execute().getResult());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    };
}
Also used : Consumer(java.util.function.Consumer) FFExecutor(org.fagu.fmv.ffmpeg.executor.FFExecutor) LinesFFMPEGOperation(org.fagu.fmv.ffmpeg.operation.LinesFFMPEGOperation) IOException(java.io.IOException)

Aggregations

FFExecutor (org.fagu.fmv.ffmpeg.executor.FFExecutor)8 IOException (java.io.IOException)6 LinesFFMPEGOperation (org.fagu.fmv.ffmpeg.operation.LinesFFMPEGOperation)5 Consumer (java.util.function.Consumer)4 Matcher (java.util.regex.Matcher)3 Pattern (java.util.regex.Pattern)3 HashMap (java.util.HashMap)2 Function (java.util.function.Function)2 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)2 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)2 MediaInput (org.fagu.fmv.ffmpeg.operation.MediaInput)2 File (java.io.File)1 PrintStream (java.io.PrintStream)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 FilenameUtils (org.apache.commons.io.FilenameUtils)1 FFMpegUtils (org.fagu.fmv.ffmpeg.FFMpegUtils)1 FFExecutorFactory (org.fagu.fmv.ffmpeg.executor.FFExecutorFactory)1 FilterNaming (org.fagu.fmv.ffmpeg.filter.FilterNaming)1