Helper Methods
logger_handler¶
Returns the logger handler
Returns: A logger handler
Source code in vidgear/gears/helper.py
check_gstreamer_support¶
Checks whether OpenCV is compiled with Gstreamer(>=1.0.0
) support.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logging | bool | enables logging for its operations | False |
Returns: A Boolean value
Source code in vidgear/gears/helper.py
get_supported_resolution¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | string | value to be validated | required |
logging | bool | enables logging for its operations | False |
Returns: Valid stream resolution
Source code in vidgear/gears/helper.py
dimensions_to_resolutions¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | list | list of dimensions (e.g. | required |
Returns: list of resolutions (e.g. 360p
)
Source code in vidgear/gears/helper.py
mkdir_safe¶
Safely creates directory at given path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path | string | path to the directory | required |
logging | bool | enables logging for its operations | False |
Source code in vidgear/gears/helper.py
delete_ext_safe¶
Safely deletes files with given extensions at given path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path | string | path to the directory | required |
extensions | list | list of extensions to be deleted | [] |
logging | bool | enables logging for its operations | False |
Source code in vidgear/gears/helper.py
capPropId¶
Retrieves the OpenCV property's Integer(Actual) value from string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
property | string | inputs OpenCV property as string. | required |
logging | bool | enables logging for its operations | True |
Returns: Resultant integer value.
Source code in vidgear/gears/helper.py
reducer¶
Reduces frame size by given percentage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame | ndarray | inputs numpy array(frame). | None |
percentage | int / float | inputs size-reduction percentage. | 0 |
interpolation | int | Change resize interpolation. | INTER_LANCZOS4 |
Returns: A reduced numpy ndarray array.
Source code in vidgear/gears/helper.py
create_blank_frame¶
Create blank frames of given frame size with text
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame | ndarray | inputs numpy array(frame). | None |
text | str | Text to be written on frame. | '' |
Returns: A reduced numpy ndarray array.
Source code in vidgear/gears/helper.py
dict2Args¶
Converts dictionary attributes to list(args)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_dict | dict | Parameters dictionary | required |
Returns: Arguments list
Source code in vidgear/gears/helper.py
get_valid_ffmpeg_path¶
Validate the given FFmpeg path/binaries, and returns a valid FFmpeg executable path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
custom_ffmpeg | string | path to custom FFmpeg executables | '' |
is_windows | boolean | is running on Windows OS? | False |
ffmpeg_download_path | string | FFmpeg static binaries download location (Windows only) | '' |
logging | bool | enables logging for its operations | False |
Returns: A valid FFmpeg executable path string.
Source code in vidgear/gears/helper.py
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 |
|
download_ffmpeg_binaries¶
Generates FFmpeg Static Binaries for windows(if not available)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | path for downloading custom FFmpeg executables | required |
os_windows | boolean | is running on Windows OS? | False |
os_bit | string | 32-bit or 64-bit OS? | '' |
Returns: A valid FFmpeg executable path string.
Source code in vidgear/gears/helper.py
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 |
|
validate_ffmpeg¶
Validate FFmeg Binaries. returns True
if tests are passed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
logging | bool | enables logging for its operations | False |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in vidgear/gears/helper.py
check_output¶
Returns stdin output from subprocess module
Source code in vidgear/gears/helper.py
generate_auth_certificates¶
Auto-Generates, and Auto-validates CURVE ZMQ key-pairs for NetGear API's Secure Mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | path for generating CURVE key-pairs | required |
overwrite | boolean | overwrite existing key-pairs or not? | False |
logging | bool | enables logging for its operations | False |
Returns: A valid CURVE key-pairs path as string.
Source code in vidgear/gears/helper.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 |
|
validate_audio¶
Validates audio by retrieving audio-bitrate from file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
source | string / list | source to be validated. | None |
Returns: A string value, confirming whether audio is present, or not?.
Source code in vidgear/gears/helper.py
extract_time¶
Extract time from give string value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | string | string value. | required |
Returns: Time (in seconds) as integer.
Source code in vidgear/gears/helper.py
validate_video¶
Validates video by retrieving resolution/size and framerate from file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
video_path | string | absolute path to Video. | None |
Returns: A dictionary of retieved Video resolution (as tuple(width, height)) and framerate (as float).
Source code in vidgear/gears/helper.py
is_valid_url¶
Checks URL validity by testing its scheme against FFmpeg's supported protocols
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
url | string | URL to be validated | None |
logging | bool | enables logging for its operations | False |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in vidgear/gears/helper.py
import_dependency_safe¶
Imports specified dependency safely. By default(error = raise
), if a dependency is missing, an ImportError with a meaningful message will be raised. Otherwise if error = log
a warning will be logged and on error = silent
everything will be quit. But If a dependency is present, but older than specified, an error is raised if specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | string | name of dependency to be imported. | required |
error | string | raise or Log or silence ImportError. Possible values are | 'raise' |
pkg_name | string | (Optional) package name of dependency(if different | None |
min_version | string | (Optional) required minimum version of the dependency to be imported. | None |
custom_message | string | (Optional) custom Import error message to be raised or logged. | None |
Returns: The imported module, when found and the version is correct(if specified). Otherwise None
.
Source code in vidgear/gears/helper.py
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 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
get_video_bitrate¶
Calculate optimum Bitrate from resolution, framerate, bits-per-pixels values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width | int | video-width | required |
height | int | video-height | required |
fps | float | video-framerate | required |
bpp | float | bit-per-pixels value | required |
Returns: Video bitrate (in Kbps) as integer.
Source code in vidgear/gears/helper.py
check_WriteAccess¶
Checks whether given path directory has Write-Access.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of directory | required |
is_windows | boolean | is running on Windows OS? | False |
logging | bool | enables logging for its operations | False |
Returns: A boolean value, confirming whether Write-Access available, or not?.
Source code in vidgear/gears/helper.py
check_open_port¶
Checks whether specified port open at given IP address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address | string | given IP address. | required |
port | int | check if port is open at given address. | 22 |
Returns: A boolean value, confirming whether given port is open at given IP address.
Source code in vidgear/gears/helper.py
delete_ext_safe¶
Safely deletes files at given path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path | string | path to the file | required |
Source code in vidgear/gears/helper.py
get_supported_demuxers¶
Find and returns FFmpeg's supported demuxers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
Returns: List of supported demuxers.
Source code in vidgear/gears/helper.py
get_supported_vencoders¶
Find and returns FFmpeg's supported video encoders
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | absolute path of FFmpeg binaries | required |
Returns: List of supported encoders.
Source code in vidgear/gears/helper.py
validate_auth_keys¶
Validates, and also maintains generated ZMQ CURVE Key-pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | string | path of generated CURVE key-pairs | required |
extension | string | type of key-pair to be validated | required |
Returns: A boolean value, confirming whether tests passed, or not?.
Source code in vidgear/gears/helper.py