Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions musicalgestures/_motionvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,11 @@ def mg_motion(
self.motiongram_vertical_image = MgImage(target_name_mgx)
self.motiongram_horizontal_image = MgImage(target_name_mgy)

# `audio_descriptors` arrives as a flag and travels on as the video to read
# audio from, which save_analysis expects. Two meanings, two names.
audio_descriptors_source: "bool | musicalgestures.MgVideo" = audio_descriptors
if audio_descriptors:
audio_descriptors = self
audio_descriptors_source = self

if save_data:
# `normalize` was declared on mg_motion and never used. It now
Expand All @@ -327,7 +330,7 @@ def mg_motion(
if title is None:
title = os.path.basename(of + fex)
# save plot as an MgImage at motion_plot_image for parent MgVideo
self.motion_plot_image = MgImage(save_analysis(of, self.fps, aom, com, qom, motion_analysis, audio_descriptors, self.width,
self.motion_plot_image = MgImage(save_analysis(of, self.fps, aom, com, qom, motion_analysis, audio_descriptors_source, self.width,
self.height, unit, title, target_name_plot=target_name_plot, overwrite=overwrite))

# Resetting numpy warnings for dividing by 0
Expand Down
2 changes: 2 additions & 0 deletions musicalgestures/_posetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def _read_result(lms, wlms):
frame_bytes = w * h * 3
stopped_early = False
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# stdout=PIPE guarantees a stream; the annotation is Optional for the general case
assert proc.stdout is not None, "ffmpeg was started without a readable output stream"
# Drain FFmpeg's stderr on a background thread as it is produced, rather
# than only reading it in the `finally` block below: the stdout-reading
# loop can run far longer than the OS pipe buffer takes to fill (a few
Expand Down
1 change: 1 addition & 0 deletions musicalgestures/_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ def mg_ssm(

else:
print(f'Unrecognized feature: "{features}". Try "motiongrams", "videograms, "spectrogram", "chromagram" or "tempogram".')
return None



2 changes: 2 additions & 0 deletions musicalgestures/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def __enter__(self) -> "MgVideoReader":
self._process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, bufsize=-1
)
# stdout=PIPE guarantees a stream; the annotation is Optional for the general case
assert self._process.stdout is not None, "ffmpeg was started without a readable output stream"
self._frame_index = 0
return self

Expand Down
2 changes: 1 addition & 1 deletion musicalgestures/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class MgFigure():
Class for working with figures and plots within the Musical Gestures Toolbox.
"""

def __init__(self, figure=None, figure_type: str | None = None, data: dict | None = None,
def __init__(self, figure=None, figure_type: str | None = None, data: Any = None,
layers: list | None = None, image=None):
"""
Initializes the MgFigure object.
Expand Down
1 change: 1 addition & 0 deletions musicalgestures/_videoadjust.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import cv2
import os
import musicalgestures
from musicalgestures._utils import scale_num, get_length, ffmpeg_cmd, has_audio, generate_outfilename, convert_to_mp4


Expand Down
Loading