Search in sources :

Example 1 with Reader

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

the class ChannelLayout method runnable.

/**
 * @return
 */
private static Runnable runnable() {
    return () -> {
        LinesFFMPEGOperation operation = new LinesFFMPEGOperation();
        operation.addParameter("-layouts");
        try {
            FFExecutor<List<String>> executor = new FFExecutor<>(operation);
            Consumer<ChannelLayoutHelp> cacheConsumer = HELP_CACHE.consumer();
            AvailableHelp<ChannelLayoutHelp> availableHelp = AvailableHelp.create();
            Reader individualReader = l -> {
                if (StringUtils.isBlank(l)) {
                    return false;
                }
                String name = StringUtils.substringBefore(l, " ").trim();
                ChannelLayoutHelp channelLayoutHelp = new ChannelLayoutHelp(name, true);
                channelLayoutHelp.text = StringUtils.substringAfter(l, " ").trim();
                cacheConsumer.accept(channelLayoutHelp);
                return true;
            };
            Reader standardReader = l -> {
                if (StringUtils.isBlank(l)) {
                    return false;
                }
                String name = StringUtils.substringBefore(l, " ").trim();
                ChannelLayoutHelp channelLayoutHelp = new ChannelLayoutHelp(name, false);
                channelLayoutHelp.text = StringUtils.substringAfter(l, " ").trim();
                cacheConsumer.accept(channelLayoutHelp);
                return true;
            };
            availableHelp.title().unreadLine().reader(individualReader).unreadLines(3).reader(standardReader).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) Reader(org.fagu.fmv.ffmpeg.utils.AvailableHelp.Reader) LinesFFMPEGOperation(org.fagu.fmv.ffmpeg.operation.LinesFFMPEGOperation) IOException(java.io.IOException)

Aggregations

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