Videoreader¶
ReadError ¶
Bases: Exception
Base class for file read errors.
mg_videoreader ¶
mg_videoreader(filename, starttime=0, endtime=0, skip=0, frames=0, rotate=0, contrast=0, brightness=0, crop='None', color=True, keep_all=False, returned_by_process=False)
Reads in a video file, and optionally apply several different processes on it. These include: - trimming, - skipping, - fixing, - rotating, - applying brightness and contrast, - cropping, - converting to grayscale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the input video file. |
required |
starttime
|
int / float
|
Trims the video from this start time (s). Defaults to 0. |
0
|
endtime
|
int / float
|
Trims the video until this end time (s). Defaults to 0 (which will make the algorithm use the full length of the input video instead). |
0
|
skip
|
int
|
Time-shrinks the video by skipping (discarding) every n frames determined by |
0
|
frames
|
int
|
Specify a fixed target number of frames to extract from the video. Defaults to 0. |
0
|
rotate
|
int / float
|
Rotates the video by a |
0
|
contrast
|
int / float
|
Applies +/- 100 contrast to video. Defaults to 0. |
0
|
brightness
|
int / float
|
Applies +/- 100 brightness to video. Defaults to 0. |
0
|
crop
|
str
|
If 'manual', opens a window displaying the first frame of the input video file, where the user can draw a rectangle to which cropping is applied. If 'auto' the cropping function attempts to determine the area of significant motion and applies the cropping to that area. Defaults to 'None'. |
'None'
|
color
|
bool
|
If False, converts the video to grayscale and sets every method in grayscale mode. Defaults to True. |
True
|
keep_all
|
bool
|
If True, preserves an output video file after each used preprocessing stage. Defaults to False. |
False
|
returned_by_process
|
bool
|
This parameter is only for internal use, do not use it. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
The number of frames in the output video file. |
|
int |
The pixel width of the output video file. |
|
int |
The pixel height of the output video file. |
|
int |
The FPS (frames per second) of the output video file. |
|
float |
The length of the output video file in seconds. |
|
str |
The path to the output video file without its extension. The file name gets a suffix for each used process. |
|
str |
The file extension of the output video file. |
|
bool |
Whether the video has an audio track. |
Source code in musicalgestures/_videoreader.py
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 104 105 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 | |