Cropvideo¶
find_motion_box_ffmpeg ¶
find_motion_box_ffmpeg(filename, motion_box_thresh=0.1, motion_box_margin=12)
Helper function to find the area of motion in a video, using ffmpeg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the video file. |
required |
motion_box_thresh
|
float
|
Pixel threshold to apply to the video before assessing the area of motion. Defaults to 0.1. |
0.1
|
motion_box_margin
|
int
|
Margin (in pixels) to add to the detected motion box. Defaults to 12. |
12
|
Raises:
| Type | Description |
|---|---|
KeyboardInterrupt
|
In case we stop the process manually. |
Returns:
| Name | Type | Description |
|---|---|---|
int |
The width of the motion box. |
|
int |
The height of the motion box. |
|
int |
The X coordinate of the top left corner of the motion box. |
|
int |
The Y coordinate of the top left corner of the motion box. |
Source code in musicalgestures/_cropvideo.py
8 9 10 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 | |
mg_cropvideo_ffmpeg ¶
mg_cropvideo_ffmpeg(filename, crop_movement='Auto', motion_box_thresh=0.1, motion_box_margin=12, target_name=None, overwrite=True)
Crops the video using ffmpeg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the video file. |
required |
crop_movement
|
str
|
'Auto' finds the bounding box that contains the total motion in the video. Motion threshold is given by motion_box_thresh. 'Manual' opens up a simple GUI that is used to crop the video manually by looking at the first frame. Defaults to 'Auto'. |
'Auto'
|
motion_box_thresh
|
float
|
Only meaningful if |
0.1
|
motion_box_margin
|
int
|
Only meaningful if |
12
|
target_name
|
str
|
The name of the output video. Defaults to None (which assumes that the input filename with the suffix "_crop" 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 |
|---|---|---|
str |
Path to the cropped video. |
Source code in musicalgestures/_cropvideo.py
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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
manual_text_input ¶
manual_text_input()
Helper function for mg_crop_video_ffmpeg when its crop_movement is 'manual', but the environment is in Colab. In this case we can't display the windowed cropping UI, so we ask for the values as a text input.
Returns:
| Name | Type | Description |
|---|---|---|
list |
x, y, w, h for crop_ffmpeg. |
Source code in musicalgestures/_cropvideo.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |