def make_weekly_movie(cam: Cam, executor): root = Path(conf.root_dir) / 'data' / cam.name path = root / 'regular' / 'imgs' start = pendulum.yesterday() logger.info(f'Running make weekly movie for ww{start.week_of_year}') week_ago = start.subtract(weeks=1).date() sequence = [] morning = pendulum.Time(6) evening = pendulum.Time(18) for day in sorted(list(path.iterdir()), key=lambda x: pendulum.from_format(x.name, 'DD_MM_YYYY')): if pendulum.from_format(day.name, 'DD_MM_YYYY').date() > week_ago: for img in sorted(day.iterdir()): t_img = img.name.split('.')[0] t_img = pendulum.from_format(t_img, 'DD_MM_YYYY_HH-mm-ss').time() if morning < t_img < evening: sequence.append(str(img)) sequence = check_sequence_for_gray_images(sequence, executor) txt_clip = make_txt_movie(sequence, 100, executor) logger.info(f'Composing clip for weekly movie ww{start.week_of_year}') image_clip = ImageSequenceClip(sequence, fps=100) clip = CompositeVideoClip([image_clip, txt_clip.set_position(('right', 'top'))], use_bgclip=True) movie_path = root / 'regular' / 'weekly' / f'ww{start.week_of_year}.mp4' movie_path.parent.mkdir(parents=True, exist_ok=True) clip.write_videofile(str(movie_path), audio=False) logger.info(f'Finished with clip for weekly movie ww{start.week_of_year}') return Movie(clip.h, clip.w, movie_path, sequence[seq_middle(sequence)])
def to_time(text: str, **kwargs) -> pendulum.Time: # pylint: disable=unused-argument if text.endswith("Z"): text = text[:-1] if len(text) >= 15: text = text[:15] text, ms = text.split(".") ts = pendulum.Time(*map(int, text.split(":")), int(ms)) return ts
def p(): return pendulum.Time(12, 34, 56, 123456, tzinfo=pendulum.timezone("Europe/Paris"))
def p(): return pendulum.Time(12, 34, 56, 123456, pytz.timezone('Europe/Paris'))