public TtmlConverter(TtmlConverterCmdLineParams params) throws ParseException {
outputFile = new File(params.getOutputFile());
if (!Files.isWritable(Paths.get((outputFile.getParent() == null) ? "." : outputFile.getParent()))) {
throw new ParseException(String.format(
"Output file %s cannot be written. Please check access rights.", params.getOutputFile()));
}
ttmlTts = params.getTtmlOptions().stream().map((o) -> {
TtEltype tt;
try {
tt = XmlParser.parse(new File(o.getFileName()), new String[]{TTML_SCHEMA}, TTML_PACKAGES, TtEltype.class);
} catch (XmlParsingException | FileNotFoundException e) {
throw new ParseException(e);
}
TtmlUtils.reduceAccordingSegment(tt, o.getOffsetMS(), o.getStartMS(), o.getEndMS(), params.getFrameRate());
TtmlUtils.moveStyleRefToP(tt);
return tt;
}).collect(Collectors.toList());
}