History¶
history_ffmpeg ¶
history_ffmpeg(self, filename=None, history_length=10, weights=1, normalize=False, norm_strength=1, norm_smooth=0, target_name=None, overwrite=True)
This function creates a video where each frame is the average of the N previous frames, where n is determined by history_length. The history frames are summed up and normalized, and added to the current frame to show the history. Uses ffmpeg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input video file. If None, the video file of the MgVideo is used. Defaults to None. |
None
|
history_length
|
int
|
Number of frames to be saved in the history tail. Defaults to 10. |
10
|
weights
|
int / float / list / str
|
Defines the weight or weights applied to the frames in the history tail. If given as list the first element in the list will correspond to the weight of the newest frame in the tail. If given as a str - like "3 1.2 1" - it will be automatically converted to a list - like [3, 1.2, 1]. Defaults to 1. |
1
|
normalize
|
bool
|
If True, the history video will be normalized. This can be useful when processing motion (frame difference) videos. Defaults to False. |
False
|
norm_strength
|
int / float
|
Defines the strength of the normalization where 1 represents full strength. Defaults to 1. |
1
|
norm_smooth
|
int
|
Defines the number of previous frames to use for temporal smoothing. The input range of each channel is smoothed using a rolling average over the current frame and the |
0
|
target_name
|
str
|
Target output name for the video. Defaults to None (which assumes that the input filename with the suffix "_history" should be used). |
None
|
overwrite
|
bool
|
Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
MgVideo |
A new MgVideo pointing to the output video file. |
Source code in musicalgestures/_history.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
history_cv2 ¶
history_cv2(self, filename=None, history_length=10, weights=1, convert=True, target_name=None, overwrite=True)
This function creates a video where each frame is the average of the N previous frames, where n is determined by history_length. The history frames are summed up and normalized, and added to the current frame to show the history. Uses cv2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input video file. If None, the video file of the MgVideo is used. Defaults to None. |
None
|
history_length
|
int
|
Number of frames to be saved in the history tail. Defaults to 10. |
10
|
weights
|
int / float / list
|
Defines the weight or weights applied to the frames in the history tail. If given as list the first element in the list will correspond to the weight of the newest frame in the tail. Defaults to 1. |
1
|
convert
|
bool
|
If True (default), non-AVI input is first converted to an all-intra MJPEG |
True
|
target_name
|
str
|
Target output name for the video. Defaults to None (which assumes that the input filename with the suffix "_history" should be used). |
None
|
overwrite
|
bool
|
Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
MgVideo |
A new MgVideo pointing to the output video file. |
Source code in musicalgestures/_history.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |