MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / DownSampleVideo

Function DownSampleVideo

deeplabcut/utils/auxfun_videos.py:496–551  ·  view source on GitHub ↗

Auxiliary function to downsample a video and output it to the same folder with "outsuffix" appended in its name. Width and height will control the new dimensions. You can also pass only height or width and set the other one to -1, this will keep the aspect ratio identical. Returns t

(
    vname,
    width=-1,
    height=200,
    outsuffix="downsampled",
    outpath=None,
    rotatecw="No",
    angle=0.0,
)

Source from the content-addressed store, hash-verified

494
495
496def DownSampleVideo(
497 vname,
498 width=-1,
499 height=200,
500 outsuffix="downsampled",
501 outpath=None,
502 rotatecw="No",
503 angle=0.0,
504):
505 """Auxiliary function to downsample a video and output it to the same folder with
506 "outsuffix" appended in its name. Width and height will control the new dimensions.
507 You can also pass only height or width and set the other one to -1, this will keep
508 the aspect ratio identical.
509
510 Returns the full path to the downsampled video!
511
512 Parameter
513 ----------
514 vname : string
515 A string containing the full path of the video.
516
517 width: int
518 width of output video
519
520 height: int
521 height of output video.
522
523 outsuffix: str
524 Suffix for output videoname (see example).
525
526 outpath: str
527 Output path for saving video to (by default will be the same folder as the video)
528
529 rotatecw: str
530 Default "No", rotates clockwise if "Yes", "Arbitrary" for arbitrary rotation by specified angle.
531
532 angle: float
533 Angle to rotate by in degrees, default 0.0. Negative values rotate counter-clockwise
534
535 Examples
536 ----------
537
538 Linux/MacOs
539 >>> deeplabcut.DownSampleVideo('/data/videos/mouse1.avi')
540
541 Downsamples the video using default values and saves it in /data/videos as mouse1cropped.avi
542
543 Windows:
544 >>> shortenedvideoname=deeplabcut.DownSampleVideo('C:\\yourusername\\rig-95\\Videos\\reachingvideo1.avi',
545 ... width=220,height=320,outsuffix='cropped')
546
547 Downsamples the video to a width of 220 and height of 320 and
548 saves it in C:\\yourusername\\rig-95\\Videos as reachingvideo1cropped.avi
549 """
550 writer = VideoWriter(vname)
551 return writer.rescale(width, height, rotatecw, angle, outsuffix, outpath)
552
553

Callers

nothing calls this directly

Calls 2

rescaleMethod · 0.95
VideoWriterClass · 0.85

Tested by

no test coverage detected