code: public BufferedImage readFrame() throws IOException {
  
  		if (!open) {
  			return null;
  		}
  
  		mark(FRAME_MAX_LENGTH);
  
  		int n = getStartOfSequence(this, SOI_MARKER);
  
  		reset();
  
  		final byte[] header = new byte[n];
  
  		readFully(header);
  
  		int length = -1;
  		try {
  			length = parseContentLength(header);
  		} catch (NumberFormatException e) {
  			length = getEndOfSeqeunce(this, EOI_MARKER);
  		}
  
  		if (length == 0) {
  			LOG.error("Invalid MJPEG stream, EOI (0xFF,0xD9) not found!");
  		}
  
  		reset();
  
  		final byte[] frame = new byte[length];
  
  		skipBytes(n);
  
  		readFully(frame);
  
  		try (final ByteArrayInputStream bais = new ByteArrayInputStream(frame)) {
  			return ImageIO.read(bais);
  		} catch (IOException e) {
  			return null;
  		}
  	}
docs: Read single MJPEG frame (JPEG image) from stram.
  
  @return JPEG image as {@link BufferedImage} or null
  @throws IOException when there is a problem in reading from stream