Video utilities
Kano provides some video-related functions:
get_frame_at_second
: get a frame at the given second of a video.extract_frames
: save frames of a video.cut_video
: save a part of a video.concatenate_videos
: concatenate a 2-dimensional list of videos.
kano.video_utils.get_frame_at_second(video_path, target_second)
Get numpy array of a frame from a video at the given second
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path |
str
|
path of the video |
required |
target_second |
int
|
second timestamp to get frame |
required |
Returns:
Name | Type | Description |
---|---|---|
frame |
ndarray
|
numpy array of the frame at the given second |
Source code in kano\video_utils.py
kano.video_utils.extract_frames(video_path, target_folder, seconds_interval)
Extract frames from a video with a given seconds interval
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path |
str
|
path of the video |
required |
target_folder |
str
|
path to save extracted frames |
required |
seconds_interval |
float
|
amount of seconds between two extracted frames |
required |
Source code in kano\video_utils.py
kano.video_utils.cut_video(input_video_path, output_video_path, start_second, end_second)
Cut a segment from a video file and save it as a new video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_video_path |
str
|
Path to the input video file. |
required |
output_video_path |
str
|
Path to save the output video file. |
required |
start_second |
float
|
Start time of the segment to be cut in seconds. |
required |
end_second |
float
|
End time of the segment to be cut in seconds. |
required |
Source code in kano\video_utils.py
kano.video_utils.concatenate_videos(video_paths, titles=None, output_video_path='concatenated_video.mp4', total_seconds=None, font_scale=2, font_thickness=3, title_padding_size=10, frame_padding_size=10)
Concatenate multiple video files into a single video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_paths |
list
|
A 2D list of video file paths to be concatenated. |
required |
titles |
list
|
A 2D list of titles corresponding to each video segment. |
None
|
output_video_path |
str
|
Path to save the concatenated video file. |
'concatenated_video.mp4'
|
total_seconds |
float
|
Total duration of the output video in seconds. |
None
|
font_scale |
int
|
Font scale for titles. |
2
|
font_thickness |
int
|
Font thickness for titles. |
3
|
title_padding_size |
int
|
Padding size for titles. |
10
|
frame_padding_size |
int
|
Padding size between frames. |
10
|
Source code in kano\video_utils.py
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 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 |
|