MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / split

Method split

deeplabcut/utils/auxfun_videos.py:253–291  ·  view source on GitHub ↗

Split a video into several shorter ones of equal duration. Parameters ---------- n_splits : int Number of shorter videos to produce suffix: str, optional String added to the name of the splits ('short' by default). dest_folder: str,

(self, n_splits, suffix="split", dest_folder=None)

Source from the content-addressed store, hash-verified

251 return output_path
252
253 def split(self, n_splits, suffix="split", dest_folder=None):
254 """Split a video into several shorter ones of equal duration.
255
256 Parameters
257 ----------
258 n_splits : int
259 Number of shorter videos to produce
260
261 suffix: str, optional
262 String added to the name of the splits ('short' by default).
263
264 dest_folder: str, optional
265 Folder the video splits are saved into (by default, same as the original video)
266
267 Returns
268 -------
269 list
270 Paths of the video splits
271 """
272 if not n_splits > 1:
273 raise ValueError("The video should at least be split in half.")
274 chunk_dur = self.calc_duration() / n_splits
275 splits = np.arange(n_splits + 1) * chunk_dur
276
277 def time_formatter(val):
278 return str(datetime.timedelta(seconds=val))
279
280 clips = []
281 for n, (start, end) in enumerate(zip(splits, splits[1:], strict=False), start=1):
282 clips.append(
283 self.shorten(
284 time_formatter(start),
285 time_formatter(end),
286 f"{suffix}{n}",
287 dest_folder,
288 validate_inputs=False,
289 )
290 )
291 return clips
292
293 def crop(self, suffix="crop", dest_folder=None):
294 x1, _, y1, _ = self.get_bbox()

Callers 15

resolve_relative_importFunction · 0.45
_normalize_relpathFunction · 0.45
_compact_reasonsFunction · 0.45
save_dataFunction · 0.45
get_deeplabcut_pathFunction · 0.45
get_scorer_nameFunction · 0.45
get_camerawise_videosFunction · 0.45
keypoint_matchingFunction · 0.45

Calls 2

shortenMethod · 0.95
calc_durationMethod · 0.80

Tested by 4

_normalize_relpathFunction · 0.36
_compact_reasonsFunction · 0.36
test_writer_splitFunction · 0.36
_to_windows_pathFunction · 0.36