def _ffmpeg_stream(self): """Return a FFmpeg process object.""" from haffmpeg import CameraMjpeg ffmpeg = CameraMjpeg(self._ffmpeg_bin) ffmpeg.open_camera(self._input, extra_cmd=self._extra_arguments) return ffmpeg
def mjpeg_stream(self, response): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg stream = CameraMjpeg(self._ffmpeg_bin) stream.open_camera(self._input, extra_cmd=self._extra_arguments) return response(stream, mimetype='multipart/x-mixed-replace;boundary=ffserver', direct_passthrough=True)
def mjpeg_stream(self, response): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg stream = CameraMjpeg(get_binary()) stream.open_camera(self._input, extra_cmd=self._extra_arguments) return response( stream, mimetype='multipart/x-mixed-replace;boundary=ffserver', direct_passthrough=True )
def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop) yield from stream.open_camera( self._input, extra_cmd=self._extra_arguments) response = web.StreamResponse() response.content_type = 'multipart/x-mixed-replace;boundary=ffserver' yield from response.prepare(request) try: while True: data = yield from stream.read(102400) if not data: break response.write(data) except asyncio.CancelledError: _LOGGER.debug("Close stream by frontend.") response = None finally: yield from stream.close() if response is not None: yield from response.write_eof()
def handle_async_mjpeg_stream(self, request): """Return an MJPEG stream.""" # The snapshot implementation is handled by the parent class if self._stream_source == STREAM_SOURCE_LIST['snapshot']: yield from super().handle_async_mjpeg_stream(request) return if self._stream_source == STREAM_SOURCE_LIST['mjpeg']: # stream an MJPEG image stream directly from the camera websession = async_get_clientsession(self.hass) streaming_url = self._camera.mjpeg_url(typeno=self._resolution) stream_coro = websession.get( streaming_url, auth=self._token, timeout=TIMEOUT) yield from async_aiohttp_proxy_web(self.hass, request, stream_coro) else: # streaming via fmpeg from haffmpeg import CameraMjpeg streaming_url = self._camera.rtsp_url(typeno=self._resolution) stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop) yield from stream.open_camera( streaming_url, extra_cmd=self._ffmpeg_arguments) yield from async_aiohttp_proxy_stream( self.hass, request, stream, 'multipart/x-mixed-replace;boundary=ffserver') yield from stream.close()
def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop) yield from stream.open_camera(self._input, extra_cmd=self._extra_arguments) response = web.StreamResponse() response.content_type = 'multipart/x-mixed-replace;boundary=ffserver' yield from response.prepare(request) try: while True: data = yield from stream.read(102400) if not data: break response.write(data) except asyncio.CancelledError: _LOGGER.debug("Close stream by frontend.") response = None finally: yield from stream.close() if response is not None: yield from response.write_eof()
def handle_async_mjpeg_stream(self, request): """Return an MJPEG stream.""" # The snapshot implementation is handled by the parent class if self._stream_source == STREAM_SOURCE_LIST['snapshot']: yield from super().handle_async_mjpeg_stream(request) return elif self._stream_source == STREAM_SOURCE_LIST['mjpeg']: # stream an MJPEG image stream directly from the camera websession = async_get_clientsession(self.hass) streaming_url = self._camera.mjpeg_url(typeno=self._resolution) stream_coro = websession.get( streaming_url, auth=self._token, timeout=TIMEOUT) yield from async_aiohttp_proxy_web(self.hass, request, stream_coro) else: # streaming via fmpeg from haffmpeg import CameraMjpeg streaming_url = self._camera.rtsp_url(typeno=self._resolution) stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop) yield from stream.open_camera( streaming_url, extra_cmd=self._ffmpeg_arguments) yield from async_aiohttp_proxy_stream( self.hass, request, stream, 'multipart/x-mixed-replace;boundary=ffserver') yield from stream.close()
def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop) yield from stream.open_camera(self._input, extra_cmd=self._extra_arguments) yield from async_aiohttp_proxy_stream( self.hass, request, stream, 'multipart/x-mixed-replace;boundary=ffserver') yield from stream.close()
def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg stream = CameraMjpeg(self._manager.binary, loop=self.hass.loop) yield from stream.open_camera( self._input, extra_cmd=self._extra_arguments) yield from async_aiohttp_proxy_stream( self.hass, request, stream, 'multipart/x-mixed-replace;boundary=ffserver') yield from stream.close()
def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" from haffmpeg import CameraMjpeg video = self._camera.last_video if not video: return stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop) yield from stream.open_camera( video.video_url, extra_cmd=self._ffmpeg_arguments) yield from async_aiohttp_proxy_stream( self.hass, request, stream, 'multipart/x-mixed-replace;boundary=ffserver') yield from stream.close()
def handle_async_mjpeg_stream(self, request): """Generate an HTTP MJPEG stream from the camera.""" if self._live_stream_session is None: return from haffmpeg import CameraMjpeg stream = CameraMjpeg(self._ffmpeg.binary, loop=self.hass.loop) yield from stream.open_camera( self._live_stream_session.live_stream_url, extra_cmd=self._ffmpeg_arguments) yield from async_aiohttp_proxy_stream( self.hass, request, stream, 'multipart/x-mixed-replace;boundary=ffserver') yield from stream.close()