Search in sources :

Example 1 with OutputTextLogger

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);
}
Also used : DLNAMediaInfo(net.pms.dlna.DLNAMediaInfo) ArrayList(java.util.ArrayList) OutputTextLogger(net.pms.io.OutputTextLogger)

Aggregations

ArrayList (java.util.ArrayList)1 DLNAMediaInfo (net.pms.dlna.DLNAMediaInfo)1 OutputTextLogger (net.pms.io.OutputTextLogger)1