Search in sources :

Example 1 with AvailableHelp

use of org.fagu.fmv.ffmpeg.utils.AvailableHelp in project fmv by f-agu.

the class Filters method runnable.

/**
 * @return
 */
private static Runnable runnable() {
    return () -> {
        LinesFFMPEGOperation operation = new LinesFFMPEGOperation();
        operation.addParameter("-filters");
        try {
            FFExecutor<List<String>> executor = new FFExecutor<>(operation);
            Consumer<FilterHelp> cacheConsumer = HELP_CACHE.consumer();
            final Pattern PATTERN = Pattern.compile("([AVN\\|]+)-\\>([AVN\\|]+)\\s+(\\w+.*)");
            Function<String, FilterHelp> factory = name -> new FilterHelp(name);
            Consumer<FilterHelp> consumer = help -> {
                Matcher matcher = PATTERN.matcher(help.getText());
                if (matcher.matches()) {
                    help.inputType = IOType.parse(matcher.group(1));
                    help.outputType = IOType.parse(matcher.group(2));
                    help.description = matcher.group(3);
                    cacheConsumer.accept(help);
                } else {
                    throw new RuntimeException("Filter description unparsable: " + help.getText());
                }
            };
            AvailableHelp<FilterHelp> availableHelp = AvailableHelp.create();
            availableHelp.title().legend(true).values(factory, consumer).parse(executor.execute().getResult());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    };
}
Also used : Pattern(java.util.regex.Pattern) Function(java.util.function.Function) Consumer(java.util.function.Consumer) AvailableHelp(org.fagu.fmv.ffmpeg.utils.AvailableHelp) Matcher(java.util.regex.Matcher) FFExecutor(org.fagu.fmv.ffmpeg.executor.FFExecutor) LinesFFMPEGOperation(org.fagu.fmv.ffmpeg.operation.LinesFFMPEGOperation) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 FFExecutor (org.fagu.fmv.ffmpeg.executor.FFExecutor)1 LinesFFMPEGOperation (org.fagu.fmv.ffmpeg.operation.LinesFFMPEGOperation)1 AvailableHelp (org.fagu.fmv.ffmpeg.utils.AvailableHelp)1