use of net.pms.io.OutputTextLogger in project UniversalMediaServer by UniversalMediaServer.
the class modAwareHashMap method parseMediaInfo.
/**
* Parse media info from ffmpeg headers during playback
*/
public void parseMediaInfo(String filename, final DLNAResource dlna, final ProcessWrapperImpl pw) {
if (dlna.getMedia() == null) {
dlna.setMedia(new DLNAMediaInfo());
} else if (dlna.getMedia().isFFmpegparsed()) {
return;
}
final ArrayList<String> lines = new ArrayList<>();
final String input = filename.length() > 200 ? filename.substring(0, 199) : filename;
OutputTextLogger ffParser = new OutputTextLogger(null) {
@Override
public boolean filter(String line) {
if (endOfHeader.reset(line).find()) {
dlna.getMedia().parseFFmpegInfo(lines, input);
LOGGER.trace("[{}] parsed media from headers: {}", ID, dlna.getMedia());
dlna.getParent().updateChild(dlna);
// done, stop filtering
return false;
}
lines.add(line);
// keep filtering
return true;
}
};
ffParser.setFiltered(true);
pw.setStderrConsumer(ffParser);
}
Aggregations