code: private VideoFormat getLargestVideoFormat() {
  
  		Format[] formats = device.getFormats();
  		VideoFormat format = null;
  		int area = 0;
  
  		// find the largest picture format
  		for (Format f : formats) {
  
  			if (!(f instanceof VideoFormat) || !"RGB".equalsIgnoreCase(f.getEncoding())) {
  				continue;
  			}
  
  			VideoFormat vf = (VideoFormat) f;
  			Dimension dim = vf.getSize();
  
  			int a = dim.width * dim.height;
  			if (a > area) {
  				area = a;
  				format = vf;
  			}
  		}
  
  		return format;
  	}
docs: Get suitable video format to use (the largest one by default, but this
  can be easily changed).
  
  @param device device to get video format for
  @return Suitable video format