diff --git a/src/editors/common.py b/src/editors/common.py index 0d0c68d..906270c 100644 --- a/src/editors/common.py +++ b/src/editors/common.py @@ -5,7 +5,7 @@ def find_moving_average_highlights(short_ma, long_ma, scaling_factor=1): in_a_clip = False m = None ret_list = [] - for t in range(1, len(long_ma)): + for t in range(1, min(len(short_ma), len(long_ma))): if ( not in_a_clip and (short_ma[t - 1] < long_ma[t - 1]) diff --git a/src/editors/sentiment/editor.py b/src/editors/sentiment/editor.py index 3db556a..d2db4b9 100644 --- a/src/editors/sentiment/editor.py +++ b/src/editors/sentiment/editor.py @@ -4,6 +4,7 @@ import random import tempfile from dataclasses import dataclass from pathlib import Path +import time import numpy as np import structlog @@ -151,6 +152,7 @@ class SentimentEditor: best_large=large_window_center, best_small=small_window_center, duration=durations[index_min], + sp_multiplier=spread_multiplier, ) if ( durations[index_min] > desired * 0.95 @@ -168,7 +170,9 @@ class SentimentEditor: spread_multiplier = spread_multiplier - spread_decay if spread_multiplier < 0: self.logger.warn("spread reached 0, resetting") + time.sleep(3) large_window_center = random.uniform(30, 50) small_window_center = random.uniform(5, 15) spread_multiplier = random.uniform(0.15, 0.18) spread_decay = random.uniform(0.0001, 0.001) + iterations = int(iterations / 2) diff --git a/src/mediautils/video.py b/src/mediautils/video.py index ead8de0..7be7253 100644 --- a/src/mediautils/video.py +++ b/src/mediautils/video.py @@ -24,7 +24,7 @@ def render_moments( iclip.resize(height=size[1]) clips.insert(0, iclip) composite = mp.concatenate_videoclips(clips, method="compose") - composite.write_videofile(output_path, logger=None, threads=parallelism) + composite.write_videofile(output_path, audio_codec='aac', threads=parallelism) def filter_moments(moments, min_length, max_length):