@Override
  public int read(byte[] b) throws IOException {
    if (readCount == -1) {
      parsing.start();
      readCount = 0;
    }

    int c = 0;

    while ((realIS == null || videosize == 0 || audiosize == 0) && c < 15) {
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        LOGGER.trace("Sleep interrupted", e);
      }

      c++;
    }

    if (realIS != null) {
      int n = realIS.read(b);
      readCount += n;
      return n;
    } else {
      return -1;
    }
  }
  private int readBytes(InputStream input, int number) throws IOException {
    byte[] buffer = new byte[number];
    int read = input.read(buffer);

    if (read < number) {
      if (read < 0) {
        throw new IOException("End of stream");
      }

      for (int i = read; i < number; i++) {
        buffer[i] = (byte) readByte(input);
      }
    }

    /** Create integer */
    switch (number) {
      case 1:
        return (buffer[0] & 0xff);
      case 2:
        return (buffer[0] & 0xff) | ((buffer[1] & 0xff) << 8);
      case 3:
        return (buffer[0] & 0xff) | ((buffer[1] & 0xff) << 8) | ((buffer[2] & 0xff) << 16);
      case 4:
        return (buffer[0] & 0xff)
            | ((buffer[1] & 0xff) << 8)
            | ((buffer[2] & 0xff) << 16)
            | ((buffer[3] & 0xff) << 24);
      default:
        throw new IOException("Illegal Read quantity");
    }
  }
  private byte[] getBytes(InputStream input, int sz) throws IOException {
    byte[] bb = new byte[sz];
    int n = input.read(bb);

    while (n < sz) {
      int u = input.read(bb, n, sz - n);

      if (u == -1) {
        break;
      }

      n += u;
    }

    return bb;
  }
  @Override
  public void close() throws IOException {
    if (process != null) {
      ProcessUtil.destroy(process);
    }

    super.close();
  }
 private int readByte(InputStream input) throws IOException {
   return input.read();
 }