From e9d9ef252f96c6da4ecebfba3a27dba7ea3e0b09 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 28 Sep 2020 02:33:27 +0200 Subject: [PATCH] Frames directory should be created in 0o755 mode --- platypush/plugins/camera/__init__.py | 10 +++++++++- platypush/plugins/camera/ffmpeg/__init__.py | 13 +++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/platypush/plugins/camera/__init__.py b/platypush/plugins/camera/__init__.py index f51dd7a6b3..232c55b290 100644 --- a/platypush/plugins/camera/__init__.py +++ b/platypush/plugins/camera/__init__.py @@ -118,7 +118,7 @@ class CameraPlugin(Plugin, ABC): super().__init__(**kwargs) self.workdir = os.path.join(Config.get('workdir'), get_plugin_name_by_class(self)) - pathlib.Path(self.workdir).mkdir(mode=0o644, exist_ok=True, parents=True) + pathlib.Path(self.workdir).mkdir(mode=0o755, exist_ok=True, parents=True) # noinspection PyArgumentList self.camera_info = self._camera_info_class(device, color_transform=color_transform, warmup_frames=warmup_frames, @@ -750,5 +750,13 @@ class CameraPlugin(Plugin, ABC): frame.save(buf, format=encoding) return buf.getvalue() + @staticmethod + def _get_warmup_seconds(camera: Camera) -> float: + if camera.info.warmup_seconds: + return camera.info.warmup_seconds + if camera.info.warmup_frames and camera.info.fps: + return camera.info.warmup_frames / camera.info.fps + return 0 + # vim:sw=4:ts=4:et: diff --git a/platypush/plugins/camera/ffmpeg/__init__.py b/platypush/plugins/camera/ffmpeg/__init__.py index 78ecc49e6a..e2149efb02 100644 --- a/platypush/plugins/camera/ffmpeg/__init__.py +++ b/platypush/plugins/camera/ffmpeg/__init__.py @@ -22,9 +22,10 @@ class CameraFfmpegPlugin(CameraPlugin): _camera_class = FFmpegCamera _camera_info_class = FFmpegCameraInfo - def __init__(self, device: Optional[str] = None, input_format: str = 'v4l2', ffmpeg_args: Tuple[str] = (), **opts): + def __init__(self, device: Optional[str] = '/dev/video0', input_format: str = 'v4l2', ffmpeg_args: Tuple[str] = (), + **opts): """ - :param device: Path to the camera device (e.g. ``/dev/video0``). + :param device: Path to the camera device (default: ``/dev/video0``). :param input_format: FFmpeg input format for the the camera device (default: ``v4l2``). :param ffmpeg_args: Extra options to be passed to the FFmpeg executable. :param opts: Camera options - see constructor of :class:`platypush.plugins.camera.CameraPlugin`. @@ -32,14 +33,6 @@ class CameraFfmpegPlugin(CameraPlugin): super().__init__(device=device, input_format=input_format, **opts) self.camera_info.ffmpeg_args = ffmpeg_args or () - @staticmethod - def _get_warmup_seconds(camera: FFmpegCamera) -> float: - if camera.info.warmup_seconds: - return camera.info.warmup_seconds - if camera.info.warmup_frames and camera.info.fps: - return camera.info.warmup_frames / camera.info.fps - return 0 - def prepare_device(self, camera: FFmpegCamera) -> subprocess.Popen: warmup_seconds = self._get_warmup_seconds(camera) ffmpeg = [camera.info.ffmpeg_bin, '-y', '-f', camera.info.input_format, '-i', camera.info.device, '-s',