def camera_image(self): """Return a still image response from the camera.""" from haffmpeg import ImageSingle, IMAGE_JPEG ffmpeg = ImageSingle(self._ffmpeg_bin) return ffmpeg.get_image(self._input, output_format=IMAGE_JPEG, extra_cmd=self._extra_arguments)
def cli(ffmpeg, source, format_img, output, extra): """FFMPEG capture frame as image.""" stream = ImageSingle(ffmpeg_bin=ffmpeg) image = stream.get_image( input_source=source, output_format=format_img, extra_cmd=extra ) if image is not None: with open(output, "wb") as fh_img: fh_img.write(image)
def __init__(self, name, interval, api, input_source, extra_arguments=None): """Init image processing.""" from haffmpeg import ImageStream, ImageSingle super().__init__(name, interval, api) self._input_source = input_source self._extra_arguments = extra_arguments if self._interval > 0: self._ffmpeg = ImageStream(get_binary(), self._process_image) else: self._ffmpeg = ImageSingle(get_binary()) self._start_ffmpeg()