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);
}
};
}
Aggregations