def probe(self):
		""" Probe the video device to get height and width info """

		# Running this command on ffmpeg unfortunately returns with an exit code of 1, which is silly.
		# Returns an error code of 1 and this text:  "/dev/video2: Immediate exit requested"
		args = ["ffmpeg", "-f", self.device_format, "-list_formats", "all", "-i", self.device_path]
		process = Popen(args, stdout=PIPE, stderr=PIPE)
		out, err = process.communicate()
		return_code = process.poll()

		# Worst case scenario, err will equal en empty byte string, b'', so probe will get set to [] here.
		regex = re.compile(r"\s\d{3,4}x\d{3,4}")
		probe = regex.findall(str(err.decode("utf-8")))

		if not return_code == 1 or len(probe) < 1:
			# Could not determine the resolution from ffmpeg call. Reverting to ffmpeg.probe()
			probe = ffmpeg.probe(self.device_path)
			height = probe["streams"][0]["height"]
			width = probe["streams"][0]["width"]
		else:
			(height, width) = [x.strip() for x in probe[0].split("x")]

		# Set height and width from probe if they haven't been set already
		if height.isdigit() and self.get(CAP_PROP_FRAME_HEIGHT) == 0:
			self.set(CAP_PROP_FRAME_HEIGHT, int(height))
		if width.isdigit() and self.get(CAP_PROP_FRAME_WIDTH) == 0:
			self.set(CAP_PROP_FRAME_WIDTH, int(width))
 Probe the video device to get height and width info 
howdy/src/recorders/ffmpeg_reader.py