diff --git a/musicalgestures/_history.py b/musicalgestures/_history.py index d4196636..004a68f3 100644 --- a/musicalgestures/_history.py +++ b/musicalgestures/_history.py @@ -50,9 +50,9 @@ def history_ffmpeg(self, filename: str | None = None, history_length: int = 10, weights_map += weights str_weights = ' '.join([str(weight) for weight in weights_map]) elif type(weights) == str: - weights_as_list = weights.split() + weights_as_text = weights.split() try: - weights_as_list = [float(item) for item in weights_as_list] + weights_as_list = [float(item) for item in weights_as_text] except ValueError: raise MgInputError( 'Found wrong type(s) in the list of weights. Use ints and floats.') @@ -150,10 +150,11 @@ def history_cv2(self, filename: str | None = None, history_length: int = 10, wei out = cv2.VideoWriter(target_name, fourcc, fps, (width, height)) ii = 0 - history = [] + history: list = [] weights_map = [1 for weight in range(history_length+1)] if type(weights) in [int, float]: + assert isinstance(weights, (int, float)) offset = weights - 1 weights_map[0] = weights elif type(weights) == list: diff --git a/musicalgestures/_subtract.py b/musicalgestures/_subtract.py index 4a68ad8a..7fbc3205 100644 --- a/musicalgestures/_subtract.py +++ b/musicalgestures/_subtract.py @@ -107,8 +107,8 @@ def mg_subtract( cmd_filter += 'format=gray,smartblur=1,smartblur=3,' cmd_filter += f'format=gray [mask];[matte][video][mask] maskedmerge, format={pixformat}' - cmd_filter = ['-filter_complex', cmd_filter] - cmd = cmd + cmd_filter + cmd_end + filter_flags = ['-filter_complex', cmd_filter] + cmd = cmd + filter_flags + cmd_end ffmpeg_cmd(cmd, get_length(self.filename), pb_prefix='Subtracting background:', stream=True)