Frames directory should be created in 0o755 mode

This commit is contained in:
Fabio Manganiello 2020-09-28 02:33:27 +02:00
parent f2a654bdec
commit e9d9ef252f
2 changed files with 12 additions and 11 deletions

View file

@ -118,7 +118,7 @@ class CameraPlugin(Plugin, ABC):
super().__init__(**kwargs) super().__init__(**kwargs)
self.workdir = os.path.join(Config.get('workdir'), get_plugin_name_by_class(self)) 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 # noinspection PyArgumentList
self.camera_info = self._camera_info_class(device, color_transform=color_transform, warmup_frames=warmup_frames, 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) frame.save(buf, format=encoding)
return buf.getvalue() 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: # vim:sw=4:ts=4:et:

View file

@ -22,9 +22,10 @@ class CameraFfmpegPlugin(CameraPlugin):
_camera_class = FFmpegCamera _camera_class = FFmpegCamera
_camera_info_class = FFmpegCameraInfo _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 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 ffmpeg_args: Extra options to be passed to the FFmpeg executable.
:param opts: Camera options - see constructor of :class:`platypush.plugins.camera.CameraPlugin`. :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) super().__init__(device=device, input_format=input_format, **opts)
self.camera_info.ffmpeg_args = ffmpeg_args or () 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: def prepare_device(self, camera: FFmpegCamera) -> subprocess.Popen:
warmup_seconds = self._get_warmup_seconds(camera) warmup_seconds = self._get_warmup_seconds(camera)
ffmpeg = [camera.info.ffmpeg_bin, '-y', '-f', camera.info.input_format, '-i', camera.info.device, '-s', ffmpeg = [camera.info.ffmpeg_bin, '-y', '-f', camera.info.input_format, '-i', camera.info.device, '-s',