augly.video package
Subpackages
Submodules
augly.video.composition module
- class augly.video.composition.BaseComposition(transforms, p=1.0)
Bases:
augly.video.transforms.VidAugBaseClass
- __init__(transforms, p=1.0)
- Parameters
transforms (
List
[VidAugBaseClass
]) – a list of transformsp (
float
) – the probability of the transform being applied; default value is 1.0
- class augly.video.composition.Compose(transforms, p=1.0)
Bases:
augly.video.composition.BaseComposition
- __call__(video_path, output_path=None, seed=None, metadata=None)
Applies the list of transforms in order to the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenseed (
Optional
[int
]) – if provided, the random seed will be set to this before calling the transformmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.composition.OneOf(transforms, p=1.0)
Bases:
augly.video.composition.BaseComposition
- __call__(video_path, output_path=None, seed=None, metadata=None)
Applies one of the transforms to the video (with probability p)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenseed (
Optional
[int
]) – if provided, the random seed will be set to this before calling the transformmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- __init__(transforms, p=1.0)
- Parameters
transforms (
List
[VidAugBaseClass
]) – a list of transforms to select from; one of which will be chosen to be applied to the videop (
float
) – the probability of the transform being applied; default value is 1.0
augly.video.functional module
- augly.video.functional.add_noise(video_path, output_path=None, level=25, metadata=None)
Adds noise to a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenlevel (
int
) – noise strength for specific pixel component. Default value is 25. Allowed range is [0, 100], where 0 indicates no changemetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.apply_lambda(video_path, output_path=None, aug_function=<function identity_function>, metadata=None, **kwargs)
Apply a user-defined lambda on a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenaug_function (
Callable
[...
,Any
]) – the augmentation function to be applied onto the video (should expect a video path and output path as input and output the augmented video to the output path. Nothing needs to be returned)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned**kwargs –
the input attributes to be passed into aug_function
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.audio_swap(video_path, audio_path, output_path=None, offset=0.0, metadata=None)
Swaps the video audio for the audio passed in provided an offset
- Parameters
video_path (
str
) – the path to the video to be augmentedaudio_path (
str
) – the iopath uri to the audio you’d like to swap with the video’s audiooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoffset (
float
) – starting point in seconds such that an audio clip of offset to offset + video_duration is used in the audio swap. Default value is zerometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.augment_audio(video_path, output_path=None, audio_aug_function=<function apply_lambda>, metadata=None, **audio_aug_kwargs)
Augments the audio track of the input video using a given AugLy audio augmentation
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenaudio_aug_function (
Callable
[...
,Tuple
[ndarray
,int
]]) – the augmentation function to be applied onto the video’s audio track. Should have the standard API of an AugLy audio augmentation, i.e. expect input audio as a numpy array or path & output path as input, and output the augmented audio to the output pathmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returnedaudio_aug_kwargs – the input attributes to be passed into audio_aug
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.blend_videos(video_path, overlay_path, output_path=None, opacity=0.5, overlay_size=1.0, x_pos=0.0, y_pos=0.0, use_second_audio=True, metadata=None)
Overlays a video onto another video at position (width * x_pos, height * y_pos) at a lower opacity
- Parameters
video_path (
str
) – the path to the video to be augmentedoverlay_path (
str
) – the path to the video that will be overlaid onto the background videooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenopacity (
float
) – the lower the opacity, the more transparent the overlaid videooverlay_size (
float
) – size of the overlaid video is overlay_size * height of the background videox_pos (
float
) – position of overlaid video relative to the background video widthy_pos (
float
) – position of overlaid video relative to the background video heightuse_second_audio (
bool
) – use the audio of the overlaid video rather than the audio of the background videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.blur(video_path, output_path=None, sigma=1, metadata=None)
Blurs a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittensigma (
float
) – horizontal sigma, standard deviation of Gaussian blurmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.brightness(video_path, output_path=None, level=0.15, metadata=None)
Brightens or darkens a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenlevel (
float
) – the value must be a float value in range -1.0 to 1.0, where a negative value darkens and positive brightensmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.change_aspect_ratio(video_path, output_path=None, ratio=1.0, metadata=None)
Changes the sample aspect ratio attribute of the video, and resizes the video to reflect the new aspect ratio
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenratio (
Union
[float
,str
]) – aspect ratio of the new video, either as a float i.e. width/height, or as a string representing the ratio in the form “num:denom”metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.change_video_speed(video_path, output_path=None, factor=1.0, metadata=None)
Changes the speed of the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenfactor (
float
) – the factor by which to alter the speed of the video. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.color_jitter(video_path, output_path=None, brightness_factor=0, contrast_factor=1.0, saturation_factor=1.0, metadata=None)
Color jitters the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenbrightness_factor (
float
) – set the brightness expression. The value must be a float value in range -1.0 to 1.0. The default value is 0contrast_factor (
float
) – set the contrast expression. The value must be a float value in range -1000.0 to 1000.0. The default value is 1saturation_factor (
float
) – set the saturation expression. The value must be a float in range 0.0 to 3.0. The default value is 1metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.concat(video_paths, output_path=None, src_video_path_index=0, metadata=None)
Concatenates videos together. Resizes all other videos to the size of the source video (video_paths[src_video_path_index]), and modifies the sample aspect ratios to match (ffmpeg will fail to concat if SARs don’t match)
- Parameters
video_paths (
List
[str
]) – a list of paths to all the videos to be concatenated (in order)output_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittensrc_video_path_index (
int
) – for metadata purposes, this indicates which video in the list video_paths should be considered the source or original videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.contrast(video_path, output_path=None, level=1.0, metadata=None)
Alters the contrast of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenlevel (
float
) – the value must be a float value in range -1000.0 to 1000.0, where a negative value removes contrast and a positive value adds contrastmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.crop(video_path, output_path=None, left=0.25, top=0.25, right=0.75, bottom=0.75, metadata=None)
Crops the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenleft (
float
) – left positioning of the crop; between 0 and 1, relative to the video widthtop (
float
) – top positioning of the crop; between 0 and 1, relative to the video heightright (
float
) – right positioning of the crop; between 0 and 1, relative to the video widthbottom (
float
) – bottom positioning of the crop; between 0 and 1, relative to the video heightmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.encoding_quality(video_path, output_path=None, quality=23, metadata=None)
Alters the encoding quality of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenquality (
int
) – CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.fps(video_path, output_path=None, fps=15, metadata=None)
Alters the FPS of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenfps (
int
) – the desired output frame rate. Note that a FPS value greater than the original FPS of the video will result in an unaltered videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.grayscale(video_path, output_path=None, metadata=None)
Changes a video to be grayscale
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.hflip(video_path, output_path=None, metadata=None)
Horizontally flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.hstack(video_path, second_video_path, output_path=None, use_second_audio=False, metadata=None)
Horizontally stacks two videos
- Parameters
video_path (
str
) – the path to the video that will be stacked to the leftsecond_video_path (
str
) – the path to the video that will be stacked to the rightoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenuse_second_audio (
bool
) – if set to True, the audio of the right video will be used instead of the left’smetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.insert_in_background(video_path, output_path=None, background_path=None, offset_factor=0.0, source_percentage=None, seed=None, metadata=None)
Puts the video in the middle of the background video (at offset_factor * background.duration)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenbackground_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framesoffset_factor (
float
) – the point in the background video in which the main video starts to play (this factor is multiplied by the background video duration to determine the start point)source_percentage (
Optional
[float
]) – when set, source_percentage of the duration of the final video (background + source) will be taken up by the source video. Randomly crops the background video to the correct duration. If the background video isn’t long enough to get the desired source_percentage, it will be looped.seed (
Optional
[int
]) – if provided, this will set the random seed to ensure consistency between runsmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.loop(video_path, output_path=None, num_loops=0, metadata=None)
Loops a video num_loops times
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittennum_loops (
int
) – the number of times to loop the video. 0 means that the video will play once (i.e. no loops)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.meme_format(video_path, output_path=None, text='LOL', font_file='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/fonts/Raleway-ExtraBold.ttf', opacity=1.0, text_color=(0, 0, 0), caption_height=250, meme_bg_color=(255, 255, 255), metadata=None)
Creates a new video that looks like a meme, given text and video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittentext (
str
) – the text to be overlaid/used in the meme. note: if using a very long string, please add in newline characters such that the text remains in a readable font sizefont_file (
str
) – iopath uri to the .ttf font fileopacity (
float
) – the lower the opacity, the more transparent the texttext_color (
Tuple
[int
,int
,int
]) – color of the text in RGB valuescaption_height (
int
) – the height of the meme captionmeme_bg_color (
Tuple
[int
,int
,int
]) – background color of the meme caption in RGB valuesmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay(video_path, overlay_path, output_path=None, overlay_size=None, x_factor=0.0, y_factor=0.0, use_overlay_audio=False, metadata=None)
Overlays media onto the video at position (width * x_factor, height * y_factor)
- Parameters
video_path (
str
) – the path to the video to be augmentedoverlay_path (
str
) – the path to the media (image or video) that will be overlaid onto the videooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_overlay_audio (
bool
) – if set to True and the media type is a video, the audio of the overlaid video will be used instead of the main/background video’s audiometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay_dots(video_path, output_path=None, num_dots=100, dot_type='colored', random_movement=True, metadata=None, **kwargs)
Overlays dots onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittennum_dots (
int
) – the number of dots to add to each framedot_type (
str
) – specify if you would like “blur” or “colored”random_movement (
bool
) – whether or not you want the dots to randomly move around across the frame or to move across in a “linear” waymetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay_emoji(video_path, output_path=None, emoji_path='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys/smiling_face_with_heart_eyes.png', x_factor=0.4, y_factor=0.4, opacity=1.0, emoji_size=0.15, metadata=None)
Overlays an emoji onto each frame of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenemoji_path (
str
) – iopath uri to the emoji imagex_factor (
float
) – specifies where the left side of the emoji should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the emoji should be placed, relative to the video heightopacity (
float
) – opacity of the emoji imageemoji_size (
float
) – emoji size relative to the height of the video framemetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay_onto_background_video(video_path, background_path, output_path=None, overlay_size=0.7, x_factor=0.0, y_factor=0.0, use_background_audio=False, metadata=None)
Overlays the video onto a background video, pointed to by background_path.
- Parameters
video_path (
str
) – the path to the video to be augmentedbackground_path (
str
) – the path to the background videooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_background_audio (
bool
) – if set to True and the media type is a video, the audio of the background video will be used instead of the src video’s audiometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay_onto_screenshot(video_path, output_path=None, template_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/web.png', template_bboxes_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/bboxes.json', max_image_size_pixels=None, crop_src_to_fit=False, metadata=None)
Overlays the video onto a screenshot template so it looks like it was screen-recorded on Instagram
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittentemplate_filepath (
str
) – iopath uri to the screenshot templatetemplate_bboxes_filepath (
str
) – iopath uri to the file containing the bounding box for each templatemax_image_size_pixels (
Optional
[int
]) – if provided, the template image and/or src video will be scaled down to avoid an output image with an area greater than this size (in pixels)crop_src_to_fit (
bool
) – if True, the src image will be cropped if necessary to fit into the template image. If False, the src image will instead be resized if necessarymetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay_shapes(video_path, output_path=None, num_shapes=1, shape_type=None, colors=None, thickness=None, radius=None, random_movement=True, topleft=None, bottomright=None, metadata=None, **kwargs)
Overlays random shapes onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittennum_shapes (
int
) – the number of shapes to add to each frameshape_type (
Optional
[str
]) – specify if you would like circles or rectanglescolors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the shapesrandom_movement (
bool
) – whether or not you want the shapes to randomly move around across the frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.overlay_text(video_path, output_path=None, text_len=10, text_change_nth=None, fonts=None, fontscales=None, colors=None, thickness=None, random_movement=False, topleft=None, bottomright=None, metadata=None, **kwargs)
Overlays random text onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittentext_len (
int
) – length of string for randomized texts.text_change_nth (
Optional
[int
]) – change random text every nth frame. None means using same text for all frames.fonts (
Optional
[List
[Tuple
[Any
,Optional
[str
]]]]) – list of fonts to sample from. Each font can be a cv2 fontFace, a PIL ImageFont, or a path to a PIL ImageFont file. Each font is coupled with a chars file (the second item in the tuple) - a path to a file which contains the characters associated with the given font. For example, non-western alphabets have different valid characters than the roman alphabet, and these must be specified in order to construct random valid text in that font. If the chars file path is None, the roman alphabet will be used.fontscales (
Optional
[Tuple
[float
,float
]]) – 2-tuple of float (min_scale, max_scale).colors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the text.random_movement (
bool
) – whether or not you want the text to randomly move around across frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.pad(video_path, output_path=None, w_factor=0.25, h_factor=0.25, color=(0, 0, 0), metadata=None)
Pads the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenw_factor (
float
) – pad right and left with w_factor * frame widthh_factor (
float
) – pad bottom and top with h_factor * frame heightcolor (
Tuple
[int
,int
,int
]) – RGB color of the padded marginmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.perspective_transform_and_shake(video_path, output_path=None, sigma=50.0, shake_radius=0.0, seed=None, metadata=None)
Apply a perspective transform to the video so it looks like it was taken as a photo from another device (e.g. taking a video from your phone of a video on a computer). Also has a shake factor to mimic the shakiness of someone holding a phone.
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittensigma (
float
) – the standard deviation of the distribution of destination coordinates. The larger the sigma value, the more intense the transformshake_radius (
float
) – determines the amount by which to “shake” the video; the larger the radius, the more intense the shake.seed (
Optional
[int
]) – if provided, this will set the random seed to ensure consistency between runsmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.pixelization(video_path, output_path=None, ratio=1.0, metadata=None)
Pixelizes the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenratio (
float
) – smaller values result in a more pixelated video, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.remove_audio(video_path, output_path=None, metadata=None)
Removes the audio stream from a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.replace_with_background(video_path, output_path=None, background_path=None, source_offset=0.0, background_offset=0.0, source_percentage=0.5, metadata=None)
Replaces the beginning and end of the source video with the background video, keeping the total duration of the output video equal to the original duration of the source video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenbackground_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framessource_offset (
float
) – the starting point where the background video transitions to the source video. Prior to this point, the source video is replaced with the background video. A value of 0 means all background is at the beginning. A value of 1 means all background is at the end of the videobackground_offset (
float
) – the starting point from which the background video starts to play, as a proportion of the background video duration (i.e. this factor is multiplied by the background video duration to determine the start point)source_percentage (
float
) – the percentage of the source video that remains unreplaced by the background video. The source percentage plus source offset should be less than 1. If it is greater, the output video duration will be longer than the source. If the background video is not long enough to get the desired source percentage, it will be loopedmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.replace_with_color_frames(video_path, output_path=None, offset_factor=0.0, duration_factor=1.0, color=(0, 0, 0), metadata=None)
Replaces part of the video with frames of the specified color
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoffset_factor (
float
) – start point of the replacement relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the replacement relative to the video duration (this parameter is multiplied by the video duration)color (
Tuple
[int
,int
,int
]) – RGB color of the replaced frames. Default color is blackmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.resize(video_path, output_path=None, height=None, width=None, metadata=None)
Resizes a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenheight (
Optional
[int
]) – the height in which the video should be resized to. If None, the original video height will be usedwidth (
Optional
[int
]) – the width in which the video should be resized to. If None, the original video width will be usedmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.rotate(video_path, output_path=None, degrees=15.0, metadata=None)
Rotates a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittendegrees (
float
) – expression for the angle by which to rotate the input video clockwise, expressed in degrees (supports negative values as well)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.scale(video_path, output_path=None, factor=0.5, metadata=None)
Alters the resolution of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenfactor (
float
) – the ratio by which the video should be downscaled or upscaledmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.shift(video_path, output_path=None, x_factor=0.0, y_factor=0.0, color=(0, 0, 0), metadata=None)
Shifts the original frame position from the center by a vector (width * x_factor, height * y_factor) and pads the rest with a colored margin
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenx_factor (
float
) – the horizontal amount that the video should be shifted, relative to the width of the videoy_factor (
float
) – the vertical amount that the video should be shifted, relative to the height of the videocolor (
Tuple
[int
,int
,int
]) – RGB color of the margin generated by the shift. Default color is blackmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.time_crop(video_path, output_path=None, offset_factor=0.0, duration_factor=1.0, metadata=None)
Crops the video using the specified offset and duration factors
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoffset_factor (
float
) – start point of the crop relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the crop relative to the video duration (this parameter is multiplied by the video duration)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.time_decimate(video_path, output_path=None, on_factor=0.2, off_factor=0.5, metadata=None)
Removes evenly sized (off) chunks, and concatenates evenly spaced (on) chunks from the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenon_factor (
float
) – relative to the video duration; the amount of time each “on” video chunk should beoff_factor (
float
) – relative to the “on” duration; the amount of time each “off” video chunk should bemetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.trim(video_path, output_path=None, start=None, end=None, metadata=None)
Trims the video using the specified start and end parameters
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenstart (
Optional
[float
]) – starting point in seconds of when the trimmed video should start. If None, start will be 0end (
Optional
[float
]) – ending point in seconds of when the trimmed video should end. If None, the end will be the duration of the videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.vflip(video_path, output_path=None, metadata=None)
Vertically flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.functional.vstack(video_path, second_video_path, output_path=None, use_second_audio=False, metadata=None)
Vertically stacks two videos
- Parameters
video_path (
str
) – the path to the video that will be stacked on topsecond_video_path (
str
) – the path to the video that will be stacked on the bottomoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenuse_second_audio (
bool
) – if set to True, the audio of the bottom video will be used instead of the top’smetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
augly.video.transforms module
- class augly.video.transforms.AddNoise(level=25, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(level=25, p=1.0)
- Parameters
level (
int
) – noise strength for specific pixel component. Default value is 25. Allowed range is [0, 100], where 0 indicates no changep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Adds noise to a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.ApplyLambda(aug_function=<function identity_function>, p=1.0, **kwargs)
Bases:
augly.video.transforms.BaseTransform
- __init__(aug_function=<function identity_function>, p=1.0, **kwargs)
- Parameters
aug_function (
Callable
[...
,str
]) – the augmentation function to be applied onto the video (should expect a video path and output path as input and output the augmented video to the output path, then return the output path)p (
float
) – the probability of the transform being applied; default value is 1.0**kwargs –
the input attributes to be passed into aug_function
- apply_transform(video_path, output_path, metadata=None)
Apply a user-defined lambda on a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.AudioSwap(audio_path, offset=0.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(audio_path, offset=0.0, p=1.0)
- Parameters
audio_path (
str
) – the iopath uri to the audio you’d like to swap with the video’s audiooffset (
float
) – starting point in seconds such that an audio clip of offset to offset + video_duration is used in the audio swap. Default value is zerop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Swaps the video audio for the audio passed in provided an offset
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.AugmentAudio(audio_aug_function=<function apply_lambda>, p=1.0, **audio_aug_kwargs)
Bases:
augly.video.transforms.BaseTransform
- __init__(audio_aug_function=<function apply_lambda>, p=1.0, **audio_aug_kwargs)
- Parameters
audio_aug_function (
Callable
[...
,Tuple
[ndarray
,int
]]) – the augmentation function to be applied onto the video’s audio track. Should have the standard API of an AugLy audio augmentation, i.e. expect input audio as a numpy array or path & output path as input, and output the augmented audio to the output pathp (
float
) – the probability of the transform being applied; default value is 1.0audio_aug_kwargs – the input attributes to be passed into audio_aug
- apply_transform(video_path, output_path, metadata=None)
Augments the audio track of the input video using a given AugLy audio augmentation
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.BaseRandomRangeTransform(min_val, max_val, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(min_val, max_val, p=1.0)
- Parameters
min_val (
float
) – the lower value of the rangemax_val (
float
) – the upper value of the rangep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
This function is to be implemented in the child classes. It has access to self.chosen_value which is the randomly chosen value from the range specified to pass into the augmentation function
- Return type
str
- apply_transform(video_path, output_path, metadata=None)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.BaseTransform(p=1.0)
Bases:
augly.video.transforms.VidAugBaseClass
- __call__(video_path, output_path=None, force=False, seed=None, metadata=None)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenforce (
bool
) – if set to True, the transform will be applied. Otherwise, application is determined by the probability setseed (
Optional
[int
]) – if provided, the random seed will be set to this before calling the transformmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- apply_transform(video_path, output_path, metadata=None)
This function is to be implemented in the child classes. From this function, call the augmentation function with the parameters specified
- Return type
str
- class augly.video.transforms.BlendVideos(overlay_path, opacity=0.5, overlay_size=1.0, x_pos=0.0, y_pos=0.0, use_second_audio=True, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(overlay_path, opacity=0.5, overlay_size=1.0, x_pos=0.0, y_pos=0.0, use_second_audio=True, p=1.0)
- Parameters
overlay_path (
str
) – the path to the video that will be overlaid onto the background videoopacity (
float
) – the lower the opacity, the more transparent the overlaid videooverlay_size (
float
) – size of the overlaid video is overlay_size * height of the background videox_pos (
float
) – position of overlaid video relative to the background video widthy_pos (
float
) – position of overlaid video relative to the background video heightuse_second_audio (
bool
) – use the audio of the overlaid video rather than the audio of the background videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays a video onto another video at position (width * x_pos, height * y_pos) at a lower opacity
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Blur(sigma=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(sigma=1.0, p=1.0)
- Parameters
sigma (
float
) – horizontal sigma, standard deviation of Gaussian blurp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Blurs a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Brightness(level=0.15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(level=0.15, p=1.0)
- Parameters
level (
float
) – the value must be a float value in range -1.0 to 1.0, where a negative value darkens and positive brightensp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Brightens or darkens a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.ChangeAspectRatio(ratio=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(ratio=1.0, p=1.0)
- Parameters
ratio (
float
) – aspect ratio, i.e. width/height, of the new videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Changes the aspect ratio of the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.ChangeVideoSpeed(factor=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(factor=1.0, p=1.0)
- Parameters
factor (
float
) – the factor by which to alter the speed of the video. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Changes the speed of the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.ColorJitter(brightness_factor=0, contrast_factor=1.0, saturation_factor=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(brightness_factor=0, contrast_factor=1.0, saturation_factor=1.0, p=1.0)
- Parameters
brightness_factor (
float
) – set the brightness expression. The value must be a float value in range -1.0 to 1.0. The default value is 0contrast_factor (
float
) – set the contrast expression. The value must be a float value in range -1000.0 to 1000.0. The default value is 1saturation_factor (
float
) – set the saturation expression. The value must be a float in range 0.0 to 3.0. The default value is 1p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Color jitters the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Concat(other_video_paths, src_video_path_index=0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(other_video_paths, src_video_path_index=0, p=1.0)
- Parameters
other_video_paths (
List
[str
]) – a list of paths to the videos to be concatenated (in order) with the given video_path when called (which will be inserted in with this list of video paths at index src_video_path_index)src_video_path_index (
int
) – for metadata purposes, this indicates which video in the list video_paths should be considered the source or original videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Concatenates videos together. Resizes all other videos to the size of the source video (video_paths[src_video_path_index]), and modifies the sample aspect ratios to match (ffmpeg will fail to concat if SARs don’t match)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Contrast(level=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(level=1.0, p=1.0)
- Parameters
level (
float
) – the value must be a float value in range -1000.0 to 1000.0, where a negative value removes contrast and a positive value adds contrastp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the contrast of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Crop(left=0.25, top=0.25, right=0.75, bottom=0.75, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(left=0.25, top=0.25, right=0.75, bottom=0.75, p=1.0)
- Parameters
left (
float
) – left positioning of the crop; between 0 and 1, relative to the video widthtop (
float
) – top positioning of the crop; between 0 and 1, relative to the video heightright (
float
) – right positioning of the crop; between 0 and 1, relative to the video widthbottom (
float
) – bottom positioning of the crop; between 0 and 1, relative to the video heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Crops the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.EncodingQuality(quality=23, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(quality=23, p=1.0)
- Parameters
quality (
int
) – CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the encoding quality of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.FPS(fps=15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(fps=15, p=1.0)
- Parameters
fps (
int
) – the desired output frame rate. Note that a FPS value greater than the original FPS of the video will result in an unaltered videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the FPS of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Grayscale(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Changes a video to be grayscale
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.HFlip(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Horizontally flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.HStack(second_video_path, use_second_audio=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(second_video_path, use_second_audio=False, p=1.0)
- Parameters
second_video_path (
str
) – the path to the video that will be stacked to the rightuse_second_audio (
bool
) – if set to True, the audio of the right video will be used instead of the left’sp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Horizontally stacks two videos
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.InsertInBackground(background_path=None, offset_factor=0.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(background_path=None, offset_factor=0.0, p=1.0)
- Parameters
background_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framesoffset_factor (
float
) – the point in the background video in which the main video starts to play (this factor is multiplied by the background video duration to determine the start point)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Puts the video in the middle of the background video (at offset_factor * background.duration)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Loop(num_loops=0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(num_loops=0, p=1.0)
- Parameters
num_loops (
int
) – the number of times to loop the video. 0 means that the video will play once (i.e. no loops)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Loops a video num_loops times
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.MemeFormat(text='LOL', font_file='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/fonts/Raleway-ExtraBold.ttf', opacity=1.0, text_color=(0, 0, 0), caption_height=250, meme_bg_color=(255, 255, 255), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(text='LOL', font_file='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/fonts/Raleway-ExtraBold.ttf', opacity=1.0, text_color=(0, 0, 0), caption_height=250, meme_bg_color=(255, 255, 255), p=1.0)
- Parameters
text (
str
) – the text to be overlaid/used in the meme. note: if using a very long string, please add in newline characters such that the text remains in a readable font sizefont_file (
str
) – iopath uri to the .ttf font fileopacity (
float
) – the lower the opacity, the more transparent the texttext_color (
Tuple
[int
,int
,int
]) – color of the text in RGB valuescaption_height (
int
) – the height of the meme captionmeme_bg_color (
Tuple
[int
,int
,int
]) – background color of the meme caption in RGB valuesp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Creates a new video that looks like a meme, given text and video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Overlay(overlay_path, overlay_size=None, x_factor=0.0, y_factor=0.0, use_overlay_audio=False, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(overlay_path, overlay_size=None, x_factor=0.0, y_factor=0.0, use_overlay_audio=False, metadata=None, p=1.0)
- Parameters
overlay_path (
str
) – the path to the media (image or video) that will be overlaid onto the videooverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_overlay_audio (
bool
) – if set to True and the media type is a video, the audio of the overlaid video will be used instead of the main/background video’s audiop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays media onto the video at position (width * x_factor, height * y_factor)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.OverlayDots(num_dots=100, dot_type='colored', random_movement=True, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(num_dots=100, dot_type='colored', random_movement=True, metadata=None, p=1.0)
- Parameters
num_dots (
int
) – the number of dots to add to each framedot_type (
str
) – specify if you would like “blur” or “colored”random_movement (
bool
) – whether or not you want the dots to randomly move around across the frame or to move across in a “linear” wayp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays dots onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.OverlayEmoji(emoji_path='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys/smiling_face_with_heart_eyes.png', x_factor=0.4, y_factor=0.4, opacity=1.0, emoji_size=0.15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(emoji_path='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys/smiling_face_with_heart_eyes.png', x_factor=0.4, y_factor=0.4, opacity=1.0, emoji_size=0.15, p=1.0)
- Parameters
emoji_path (
str
) – iopath uri to the emoji imagex_factor (
float
) – specifies where the left side of the emoji should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the emoji should be placed, relative to the video heightopacity (
float
) – opacity of the emoji imageemoji_size (
float
) – emoji size relative to the height of the video framep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays an emoji onto each frame of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.OverlayOntoBackgroundVideo(background_path, overlay_size=0.7, x_factor=0.0, y_factor=0.0, use_background_audio=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(background_path, overlay_size=0.7, x_factor=0.0, y_factor=0.0, use_background_audio=False, p=1.0)
- Parameters
background_path (
str
) – the path to the background videooverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_background_audio (
bool
) – if set to True and the media type is a video, the audio of the background video will be used instead of the src video’s audiop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays the video onto a background video, pointed to by background_path
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.OverlayOntoScreenshot(template_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/web.png', template_bboxes_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/bboxes.json', max_image_size_pixels=None, crop_src_to_fit=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(template_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/web.png', template_bboxes_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/bboxes.json', max_image_size_pixels=None, crop_src_to_fit=False, p=1.0)
- Parameters
template_filepath (
str
) – iopath uri to the screenshot templatetemplate_bboxes_filepath (
str
) – iopath uri to the file containing the bounding box for each templatemax_image_size_pixels (
Optional
[int
]) – if provided, the template image and/or src video will be scaled down to avoid an output image with an area greater than this size (in pixels)crop_src_to_fit (
bool
) – if True, the src image will be cropped if necessary to fit into the template image. If False, the src image will instead be resized if necessaryp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays the video onto a screenshot template so it looks like it was screen-recorded on Instagram
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.OverlayShapes(num_shapes=1, shape_type=None, colors=None, thickness=None, radius=None, random_movement=True, topleft=None, bottomright=None, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(num_shapes=1, shape_type=None, colors=None, thickness=None, radius=None, random_movement=True, topleft=None, bottomright=None, metadata=None, p=1.0)
- Parameters
num_shapes (
int
) – the number of shapes to add to each frameshape_type (
Optional
[str
]) – specify if you would like circles or rectanglescolors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the shapesrandom_movement (
bool
) – whether or not you want the shapes to randomly move around across the frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] epresenting the fraction w.r.t width/heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays random shapes onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.OverlayText(text_len=10, text_change_nth=None, fonts=None, fontscales=None, colors=None, thickness=None, random_movement=False, topleft=None, bottomright=None, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(text_len=10, text_change_nth=None, fonts=None, fontscales=None, colors=None, thickness=None, random_movement=False, topleft=None, bottomright=None, metadata=None, p=1.0)
- Parameters
text_len (
int
) – length of string for randomized texts.text_change_nth (
Optional
[int
]) – change random text every nth frame. None means using same text for all framesfonts (
Optional
[List
[Tuple
[Any
,Optional
[str
]]]]) – list of fonts to sample from. Each font can be a cv2 fontFace, a PIL ImageFont, or a path to a PIL ImageFont file. Each font is coupled with a chars file (the second item in the tuple) - a path to a file which contains the characters associated with the given font. For example, non- western alphabets have different valid characters than the roman alphabet, and these must be specified in order to construct random valid text in that font. If the chars file path is None, the roman alphabet will be usedfontscales (
Optional
[Tuple
[float
,float
]]) – 2-tuple of float (min_scale, max_scale)colors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the textrandom_movement (
bool
) – whether or not you want the text to randomly move around across frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays random text onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Pad(w_factor=0.25, h_factor=0.25, color=(0, 0, 0), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(w_factor=0.25, h_factor=0.25, color=(0, 0, 0), p=1.0)
- Parameters
w_factor (
float
) – pad right and left with w_factor * frame widthh_factor (
float
) – pad bottom and top with h_factor * frame heightcolor (
Tuple
[int
,int
,int
]) – RGB color of the padded marginp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Pads the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.PerspectiveTransformAndShake(sigma=50.0, shake_radius=0.0, seed=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(sigma=50.0, shake_radius=0.0, seed=None, p=1.0)
- Parameters
sigma (
float
) – the standard deviation of the distribution of destination coordinates. the larger the sigma value, the more intense the transformshake_radius (
float
) – determines the amount by which to “shake” the video; the larger the radius, the more intense the shakeseed (
Optional
[int
]) – if provided, this will set the random seed to ensure consistency between runsp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Apply a perspective transform to the video so it looks like it was taken as a photo from another device (e.g. taking a video from your phone of a video on a computer). Also has a shake factor to mimic the shakiness of someone holding a phone
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Pixelization(ratio=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(ratio=1.0, p=1.0)
- Parameters
ratio (
float
) – smaller values result in a more pixelated image, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Pixelizes the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomAspectRatio(min_ratio=0.5, max_ratio=2.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_ratio=0.5, max_ratio=2.0, p=1.0)
- Parameters
min_ratio (
float
) – the lower value on the range of aspect ratio values to choose from, i.e. the width/height ratiomax_ratio (
float
) – the upper value on the range of aspect ratio values to choose from, i.e. the width/height ratiop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the aspect ratio of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomBlur(min_sigma=0.0, max_sigma=10.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_sigma=0.0, max_sigma=10.0, p=1.0)
- Parameters
min_sigma (
float
) – the lower value on the range of blur values to choose from. The larger the radius, the blurrier the videomax_sigma (
float
) – the upper value on the range of blur values to choose from. The larger the radius, the blurrier the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly blurs a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomBrightness(min_level=- 1.0, max_level=1.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_level=- 1.0, max_level=1.0, p=1.0)
- Parameters
min_level (
float
) – the lower value on the range of brightness values to choose from. The lower the factor, the darker the videomax_level (
float
) – the upper value on the range of brightness values to choose from. The higher the factor, the brighter the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the brightness of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomContrast(min_factor=- 5.0, max_factor=5.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_factor=- 5.0, max_factor=5.0, p=1.0)
- Parameters
min_factor (
float
) – the lower value on the range of contrast values to choose from. The lower the factor, the less contrastmax_factor (
float
) – the upper value on the range of contrast values to choose from. The higher the factor, the more contrastp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the contrast of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomEmojiOverlay(emoji_directory='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys', opacity=1.0, emoji_size=0.15, x_factor=0.4, y_factor=0.4, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(emoji_directory='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys', opacity=1.0, emoji_size=0.15, x_factor=0.4, y_factor=0.4, p=1.0)
- Parameters
emoji_directory (
str
) – iopath directory uri containing the emoji imagesopacity (
float
) – the lower the opacity, the more transparent the overlaid emojiemoji_size (
float
) – size of the emoji is emoji_size * height of the original videox_factor (
float
) – position of emoji relative to the video widthy_factor (
float
) – position of emoji relative to the video heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Transform that overlays a random emoji onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomEncodingQuality(min_quality=10, max_quality=40, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_quality=10, max_quality=40, p=1.0)
- Parameters
min_quality (
int
) – the lower value on the range of encoding quality values to choose from. CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. a lower value generally leads to higher quality, and a subjectively sane range is 17–28max_quality (
int
) – the upper value on the range of encoding quality values to choose from. CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. a lower value generally leads to higher quality, and a subjectively sane range is 17–28p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the encoding quality of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomFPS(min_fps=5.0, max_fps=30.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_fps=5.0, max_fps=30.0, p=1.0)
- Parameters
min_fps (
float
) – the lower value on the range of fps values to choose frommax_fps (
float
) – the upper value on the range of fps values to choose from. Note that a FPS value greater than the original FPS of the video will result in an unaltered videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the FPS of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomNoise(min_level=0, max_level=50, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_level=0, max_level=50, p=1.0)
- Parameters
min_level (
int
) – the lower value on the range of noise strength level values to choose from. 0 indicates no change, allowed range is [0, 100]max_level (
int
) – the upper value on the range of noise strength level values to choose from. 0 indicates no change, allowed range is [0, 100]p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly adds noise to a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomPixelization(min_ratio=0.1, max_ratio=1.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_ratio=0.1, max_ratio=1.0, p=1.0)
- Parameters
min_ratio (
float
) – the lower value on the range of pixelization ratio values to choose from. Smaller values result in a more pixelated video, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectmax_ratio (
float
) – the upper value on the range of pixelization ratio values to choose from. Smaller values result in a more pixelated video, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly pixelizes a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomRotation(min_degrees=0.0, max_degrees=180.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_degrees=0.0, max_degrees=180.0, p=1.0)
- Parameters
min_degrees (
float
) – the lower value on the range of degree values to choose frommax_degrees (
float
) – the upper value on the range of degree values to choose fromp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly rotates a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RandomVideoSpeed(min_factor=0.25, max_factor=4.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_factor=0.25, max_factor=4.0, p=1.0)
- Parameters
min_factor (
float
) – the lower value on the range of speed values to choose from. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the video relative to the original speedmax_factor (
float
) – the upper value on the range of speed values to choose from. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the video relative to the original speedp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the video speed
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.RemoveAudio(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Removes the audio stream from a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.ReplaceWithBackground(background_path=None, source_offset=0.0, background_offset=0.0, source_percentage=0.5, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(background_path=None, source_offset=0.0, background_offset=0.0, source_percentage=0.5, p=1.0)
- Parameters
background_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framesoffset_factor – the point in the background video in which the main video starts to play (this factor is multiplied by the background video duration to determine the start point)
p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Puts the video in the middle of the background video (at offset_factor * background.duration)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.ReplaceWithColorFrames(offset_factor=0.0, duration_factor=1.0, color=(0, 0, 0), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(offset_factor=0.0, duration_factor=1.0, color=(0, 0, 0), p=1.0)
- Parameters
offset_factor (
float
) – start point of the replacement relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the replacement relative to the video duration (this parameter is multiplied by the video duration)color (
Tuple
[int
,int
,int
]) – RGB color of the replaced frames. Default color is blackp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Replaces part of the video with frames of the specified color
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Resize(height=None, width=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(height=None, width=None, p=1.0)
- Parameters
height (
Optional
[int
]) – the height in which the video should be resized to. If None, the original video height will be usedwidth (
Optional
[int
]) – the width in which the video should be resized to. If None, the original video width will be usedp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Resizes a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Rotate(degrees=15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(degrees=15, p=1.0)
- Parameters
degrees (
float
) – expression for the angle by which to rotate the input video clockwise, expressed in degrees (supports negative values as well)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Rotates a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Scale(factor=0.5, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(factor=0.5, p=1.0)
- Parameters
factor (
float
) – the ratio by which the video should be down-scaled or upscaledp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the resolution of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Shift(x_factor=0.0, y_factor=0.0, color=(0, 0, 0), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(x_factor=0.0, y_factor=0.0, color=(0, 0, 0), p=1.0)
- Parameters
x_factor (
float
) – the horizontal amount that the video should be shifted, relative to the width of the videoy_factor (
float
) – the vertical amount that the video should be shifted, relative to the height of the videocolor (
Tuple
[int
,int
,int
]) – RGB color of the margin generated by the shift. Default color is blackp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Shifts the original frame position from the center by a vector (width * x_factor, height * y_factor) and pads the rest with a colored margin
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.TimeCrop(offset_factor=0.0, duration_factor=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(offset_factor=0.0, duration_factor=1.0, p=1.0)
- Parameters
offset_factor (
float
) – start point of the crop relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the crop relative to the video duration (this parameter is multiplied by the video duration)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Crops the video using the specified offset and duration factors
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.TimeDecimate(on_factor=0.2, off_factor=0.5, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(on_factor=0.2, off_factor=0.5, p=1.0)
- Parameters
on_factor (
float
) – relative to the video duration; the amount of time each “on” video chunk should beoff_factor (
float
) – relative to the “on” duration; the amount of time each “off” video chunk should bep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Removes evenly sized (off) chunks, and concatenates evenly spaced (on) chunks from the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.Trim(start=None, end=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(start=None, end=None, p=1.0)
- Parameters
start (
Optional
[float
]) – starting point in seconds of when the trimmed video should start. If None, start will be 0end (
Optional
[float
]) – ending point in seconds of when the trimmed video should end. If None, the end will be the duration of the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Trims the video using the specified start and end parameters
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.VFlip(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Vertically flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.VStack(second_video_path, use_second_audio=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(second_video_path, use_second_audio=False, p=1.0)
- Parameters
second_video_path (
str
) – the path to the video that will be stacked on the bottomuse_second_audio (
bool
) – if set to True, the audio of the bottom video will be used instead of the top’sp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Vertically stacks two videos
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.transforms.VidAugBaseClass(p=1.0)
Bases:
object
- __call__(*args, **kwargs)
This function is to be implemented in the child classes. From this function, call the transform to be applied
- Return type
Any
- __init__(p=1.0)
- Parameters
p (
float
) – the probability of the transform being applied; default value is 1.0
Module contents
- class augly.video.AddNoise(level=25, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(level=25, p=1.0)
- Parameters
level (
int
) – noise strength for specific pixel component. Default value is 25. Allowed range is [0, 100], where 0 indicates no changep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Adds noise to a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.ApplyLambda(aug_function=<function identity_function>, p=1.0, **kwargs)
Bases:
augly.video.transforms.BaseTransform
- __init__(aug_function=<function identity_function>, p=1.0, **kwargs)
- Parameters
aug_function (
Callable
[...
,str
]) – the augmentation function to be applied onto the video (should expect a video path and output path as input and output the augmented video to the output path, then return the output path)p (
float
) – the probability of the transform being applied; default value is 1.0**kwargs –
the input attributes to be passed into aug_function
- apply_transform(video_path, output_path, metadata=None)
Apply a user-defined lambda on a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.AudioSwap(audio_path, offset=0.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(audio_path, offset=0.0, p=1.0)
- Parameters
audio_path (
str
) – the iopath uri to the audio you’d like to swap with the video’s audiooffset (
float
) – starting point in seconds such that an audio clip of offset to offset + video_duration is used in the audio swap. Default value is zerop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Swaps the video audio for the audio passed in provided an offset
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.AugmentAudio(audio_aug_function=<function apply_lambda>, p=1.0, **audio_aug_kwargs)
Bases:
augly.video.transforms.BaseTransform
- __init__(audio_aug_function=<function apply_lambda>, p=1.0, **audio_aug_kwargs)
- Parameters
audio_aug_function (
Callable
[...
,Tuple
[ndarray
,int
]]) – the augmentation function to be applied onto the video’s audio track. Should have the standard API of an AugLy audio augmentation, i.e. expect input audio as a numpy array or path & output path as input, and output the augmented audio to the output pathp (
float
) – the probability of the transform being applied; default value is 1.0audio_aug_kwargs – the input attributes to be passed into audio_aug
- apply_transform(video_path, output_path, metadata=None)
Augments the audio track of the input video using a given AugLy audio augmentation
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.BlendVideos(overlay_path, opacity=0.5, overlay_size=1.0, x_pos=0.0, y_pos=0.0, use_second_audio=True, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(overlay_path, opacity=0.5, overlay_size=1.0, x_pos=0.0, y_pos=0.0, use_second_audio=True, p=1.0)
- Parameters
overlay_path (
str
) – the path to the video that will be overlaid onto the background videoopacity (
float
) – the lower the opacity, the more transparent the overlaid videooverlay_size (
float
) – size of the overlaid video is overlay_size * height of the background videox_pos (
float
) – position of overlaid video relative to the background video widthy_pos (
float
) – position of overlaid video relative to the background video heightuse_second_audio (
bool
) – use the audio of the overlaid video rather than the audio of the background videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays a video onto another video at position (width * x_pos, height * y_pos) at a lower opacity
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Blur(sigma=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(sigma=1.0, p=1.0)
- Parameters
sigma (
float
) – horizontal sigma, standard deviation of Gaussian blurp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Blurs a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Brightness(level=0.15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(level=0.15, p=1.0)
- Parameters
level (
float
) – the value must be a float value in range -1.0 to 1.0, where a negative value darkens and positive brightensp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Brightens or darkens a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.ChangeAspectRatio(ratio=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(ratio=1.0, p=1.0)
- Parameters
ratio (
float
) – aspect ratio, i.e. width/height, of the new videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Changes the aspect ratio of the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.ChangeVideoSpeed(factor=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(factor=1.0, p=1.0)
- Parameters
factor (
float
) – the factor by which to alter the speed of the video. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Changes the speed of the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.ColorJitter(brightness_factor=0, contrast_factor=1.0, saturation_factor=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(brightness_factor=0, contrast_factor=1.0, saturation_factor=1.0, p=1.0)
- Parameters
brightness_factor (
float
) – set the brightness expression. The value must be a float value in range -1.0 to 1.0. The default value is 0contrast_factor (
float
) – set the contrast expression. The value must be a float value in range -1000.0 to 1000.0. The default value is 1saturation_factor (
float
) – set the saturation expression. The value must be a float in range 0.0 to 3.0. The default value is 1p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Color jitters the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Compose(transforms, p=1.0)
Bases:
augly.video.composition.BaseComposition
- __call__(video_path, output_path=None, seed=None, metadata=None)
Applies the list of transforms in order to the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenseed (
Optional
[int
]) – if provided, the random seed will be set to this before calling the transformmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Concat(other_video_paths, src_video_path_index=0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(other_video_paths, src_video_path_index=0, p=1.0)
- Parameters
other_video_paths (
List
[str
]) – a list of paths to the videos to be concatenated (in order) with the given video_path when called (which will be inserted in with this list of video paths at index src_video_path_index)src_video_path_index (
int
) – for metadata purposes, this indicates which video in the list video_paths should be considered the source or original videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Concatenates videos together. Resizes all other videos to the size of the source video (video_paths[src_video_path_index]), and modifies the sample aspect ratios to match (ffmpeg will fail to concat if SARs don’t match)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Contrast(level=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(level=1.0, p=1.0)
- Parameters
level (
float
) – the value must be a float value in range -1000.0 to 1000.0, where a negative value removes contrast and a positive value adds contrastp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the contrast of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Crop(left=0.25, top=0.25, right=0.75, bottom=0.75, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(left=0.25, top=0.25, right=0.75, bottom=0.75, p=1.0)
- Parameters
left (
float
) – left positioning of the crop; between 0 and 1, relative to the video widthtop (
float
) – top positioning of the crop; between 0 and 1, relative to the video heightright (
float
) – right positioning of the crop; between 0 and 1, relative to the video widthbottom (
float
) – bottom positioning of the crop; between 0 and 1, relative to the video heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Crops the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.EncodingQuality(quality=23, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(quality=23, p=1.0)
- Parameters
quality (
int
) – CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the encoding quality of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.FPS(fps=15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(fps=15, p=1.0)
- Parameters
fps (
int
) – the desired output frame rate. Note that a FPS value greater than the original FPS of the video will result in an unaltered videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the FPS of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Grayscale(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Changes a video to be grayscale
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.HFlip(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Horizontally flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.HStack(second_video_path, use_second_audio=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(second_video_path, use_second_audio=False, p=1.0)
- Parameters
second_video_path (
str
) – the path to the video that will be stacked to the rightuse_second_audio (
bool
) – if set to True, the audio of the right video will be used instead of the left’sp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Horizontally stacks two videos
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.InsertInBackground(background_path=None, offset_factor=0.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(background_path=None, offset_factor=0.0, p=1.0)
- Parameters
background_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framesoffset_factor (
float
) – the point in the background video in which the main video starts to play (this factor is multiplied by the background video duration to determine the start point)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Puts the video in the middle of the background video (at offset_factor * background.duration)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Loop(num_loops=0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(num_loops=0, p=1.0)
- Parameters
num_loops (
int
) – the number of times to loop the video. 0 means that the video will play once (i.e. no loops)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Loops a video num_loops times
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.MemeFormat(text='LOL', font_file='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/fonts/Raleway-ExtraBold.ttf', opacity=1.0, text_color=(0, 0, 0), caption_height=250, meme_bg_color=(255, 255, 255), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(text='LOL', font_file='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/fonts/Raleway-ExtraBold.ttf', opacity=1.0, text_color=(0, 0, 0), caption_height=250, meme_bg_color=(255, 255, 255), p=1.0)
- Parameters
text (
str
) – the text to be overlaid/used in the meme. note: if using a very long string, please add in newline characters such that the text remains in a readable font sizefont_file (
str
) – iopath uri to the .ttf font fileopacity (
float
) – the lower the opacity, the more transparent the texttext_color (
Tuple
[int
,int
,int
]) – color of the text in RGB valuescaption_height (
int
) – the height of the meme captionmeme_bg_color (
Tuple
[int
,int
,int
]) – background color of the meme caption in RGB valuesp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Creates a new video that looks like a meme, given text and video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OneOf(transforms, p=1.0)
Bases:
augly.video.composition.BaseComposition
- __call__(video_path, output_path=None, seed=None, metadata=None)
Applies one of the transforms to the video (with probability p)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenseed (
Optional
[int
]) – if provided, the random seed will be set to this before calling the transformmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- __init__(transforms, p=1.0)
- Parameters
transforms (
List
[VidAugBaseClass
]) – a list of transforms to select from; one of which will be chosen to be applied to the videop (
float
) – the probability of the transform being applied; default value is 1.0
- class augly.video.Overlay(overlay_path, overlay_size=None, x_factor=0.0, y_factor=0.0, use_overlay_audio=False, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(overlay_path, overlay_size=None, x_factor=0.0, y_factor=0.0, use_overlay_audio=False, metadata=None, p=1.0)
- Parameters
overlay_path (
str
) – the path to the media (image or video) that will be overlaid onto the videooverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_overlay_audio (
bool
) – if set to True and the media type is a video, the audio of the overlaid video will be used instead of the main/background video’s audiop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays media onto the video at position (width * x_factor, height * y_factor)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OverlayDots(num_dots=100, dot_type='colored', random_movement=True, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(num_dots=100, dot_type='colored', random_movement=True, metadata=None, p=1.0)
- Parameters
num_dots (
int
) – the number of dots to add to each framedot_type (
str
) – specify if you would like “blur” or “colored”random_movement (
bool
) – whether or not you want the dots to randomly move around across the frame or to move across in a “linear” wayp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays dots onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OverlayEmoji(emoji_path='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys/smiling_face_with_heart_eyes.png', x_factor=0.4, y_factor=0.4, opacity=1.0, emoji_size=0.15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(emoji_path='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys/smiling_face_with_heart_eyes.png', x_factor=0.4, y_factor=0.4, opacity=1.0, emoji_size=0.15, p=1.0)
- Parameters
emoji_path (
str
) – iopath uri to the emoji imagex_factor (
float
) – specifies where the left side of the emoji should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the emoji should be placed, relative to the video heightopacity (
float
) – opacity of the emoji imageemoji_size (
float
) – emoji size relative to the height of the video framep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays an emoji onto each frame of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OverlayOntoBackgroundVideo(background_path, overlay_size=0.7, x_factor=0.0, y_factor=0.0, use_background_audio=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(background_path, overlay_size=0.7, x_factor=0.0, y_factor=0.0, use_background_audio=False, p=1.0)
- Parameters
background_path (
str
) – the path to the background videooverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_background_audio (
bool
) – if set to True and the media type is a video, the audio of the background video will be used instead of the src video’s audiop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays the video onto a background video, pointed to by background_path
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OverlayOntoScreenshot(template_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/web.png', template_bboxes_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/bboxes.json', max_image_size_pixels=None, crop_src_to_fit=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(template_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/web.png', template_bboxes_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/bboxes.json', max_image_size_pixels=None, crop_src_to_fit=False, p=1.0)
- Parameters
template_filepath (
str
) – iopath uri to the screenshot templatetemplate_bboxes_filepath (
str
) – iopath uri to the file containing the bounding box for each templatemax_image_size_pixels (
Optional
[int
]) – if provided, the template image and/or src video will be scaled down to avoid an output image with an area greater than this size (in pixels)crop_src_to_fit (
bool
) – if True, the src image will be cropped if necessary to fit into the template image. If False, the src image will instead be resized if necessaryp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays the video onto a screenshot template so it looks like it was screen-recorded on Instagram
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OverlayShapes(num_shapes=1, shape_type=None, colors=None, thickness=None, radius=None, random_movement=True, topleft=None, bottomright=None, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(num_shapes=1, shape_type=None, colors=None, thickness=None, radius=None, random_movement=True, topleft=None, bottomright=None, metadata=None, p=1.0)
- Parameters
num_shapes (
int
) – the number of shapes to add to each frameshape_type (
Optional
[str
]) – specify if you would like circles or rectanglescolors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the shapesrandom_movement (
bool
) – whether or not you want the shapes to randomly move around across the frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] epresenting the fraction w.r.t width/heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays random shapes onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.OverlayText(text_len=10, text_change_nth=None, fonts=None, fontscales=None, colors=None, thickness=None, random_movement=False, topleft=None, bottomright=None, metadata=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(text_len=10, text_change_nth=None, fonts=None, fontscales=None, colors=None, thickness=None, random_movement=False, topleft=None, bottomright=None, metadata=None, p=1.0)
- Parameters
text_len (
int
) – length of string for randomized texts.text_change_nth (
Optional
[int
]) – change random text every nth frame. None means using same text for all framesfonts (
Optional
[List
[Tuple
[Any
,Optional
[str
]]]]) – list of fonts to sample from. Each font can be a cv2 fontFace, a PIL ImageFont, or a path to a PIL ImageFont file. Each font is coupled with a chars file (the second item in the tuple) - a path to a file which contains the characters associated with the given font. For example, non- western alphabets have different valid characters than the roman alphabet, and these must be specified in order to construct random valid text in that font. If the chars file path is None, the roman alphabet will be usedfontscales (
Optional
[Tuple
[float
,float
]]) – 2-tuple of float (min_scale, max_scale)colors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the textrandom_movement (
bool
) – whether or not you want the text to randomly move around across frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Overlays random text onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Pad(w_factor=0.25, h_factor=0.25, color=(0, 0, 0), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(w_factor=0.25, h_factor=0.25, color=(0, 0, 0), p=1.0)
- Parameters
w_factor (
float
) – pad right and left with w_factor * frame widthh_factor (
float
) – pad bottom and top with h_factor * frame heightcolor (
Tuple
[int
,int
,int
]) – RGB color of the padded marginp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Pads the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.PerspectiveTransformAndShake(sigma=50.0, shake_radius=0.0, seed=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(sigma=50.0, shake_radius=0.0, seed=None, p=1.0)
- Parameters
sigma (
float
) – the standard deviation of the distribution of destination coordinates. the larger the sigma value, the more intense the transformshake_radius (
float
) – determines the amount by which to “shake” the video; the larger the radius, the more intense the shakeseed (
Optional
[int
]) – if provided, this will set the random seed to ensure consistency between runsp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Apply a perspective transform to the video so it looks like it was taken as a photo from another device (e.g. taking a video from your phone of a video on a computer). Also has a shake factor to mimic the shakiness of someone holding a phone
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Pixelization(ratio=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(ratio=1.0, p=1.0)
- Parameters
ratio (
float
) – smaller values result in a more pixelated image, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Pixelizes the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomAspectRatio(min_ratio=0.5, max_ratio=2.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_ratio=0.5, max_ratio=2.0, p=1.0)
- Parameters
min_ratio (
float
) – the lower value on the range of aspect ratio values to choose from, i.e. the width/height ratiomax_ratio (
float
) – the upper value on the range of aspect ratio values to choose from, i.e. the width/height ratiop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the aspect ratio of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomBlur(min_sigma=0.0, max_sigma=10.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_sigma=0.0, max_sigma=10.0, p=1.0)
- Parameters
min_sigma (
float
) – the lower value on the range of blur values to choose from. The larger the radius, the blurrier the videomax_sigma (
float
) – the upper value on the range of blur values to choose from. The larger the radius, the blurrier the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly blurs a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomBrightness(min_level=- 1.0, max_level=1.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_level=- 1.0, max_level=1.0, p=1.0)
- Parameters
min_level (
float
) – the lower value on the range of brightness values to choose from. The lower the factor, the darker the videomax_level (
float
) – the upper value on the range of brightness values to choose from. The higher the factor, the brighter the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the brightness of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomContrast(min_factor=- 5.0, max_factor=5.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_factor=- 5.0, max_factor=5.0, p=1.0)
- Parameters
min_factor (
float
) – the lower value on the range of contrast values to choose from. The lower the factor, the less contrastmax_factor (
float
) – the upper value on the range of contrast values to choose from. The higher the factor, the more contrastp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the contrast of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomEmojiOverlay(emoji_directory='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys', opacity=1.0, emoji_size=0.15, x_factor=0.4, y_factor=0.4, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(emoji_directory='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys', opacity=1.0, emoji_size=0.15, x_factor=0.4, y_factor=0.4, p=1.0)
- Parameters
emoji_directory (
str
) – iopath directory uri containing the emoji imagesopacity (
float
) – the lower the opacity, the more transparent the overlaid emojiemoji_size (
float
) – size of the emoji is emoji_size * height of the original videox_factor (
float
) – position of emoji relative to the video widthy_factor (
float
) – position of emoji relative to the video heightp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Transform that overlays a random emoji onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomEncodingQuality(min_quality=10, max_quality=40, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_quality=10, max_quality=40, p=1.0)
- Parameters
min_quality (
int
) – the lower value on the range of encoding quality values to choose from. CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. a lower value generally leads to higher quality, and a subjectively sane range is 17–28max_quality (
int
) – the upper value on the range of encoding quality values to choose from. CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. a lower value generally leads to higher quality, and a subjectively sane range is 17–28p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the encoding quality of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomFPS(min_fps=5.0, max_fps=30.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_fps=5.0, max_fps=30.0, p=1.0)
- Parameters
min_fps (
float
) – the lower value on the range of fps values to choose frommax_fps (
float
) – the upper value on the range of fps values to choose from. Note that a FPS value greater than the original FPS of the video will result in an unaltered videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the FPS of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomNoise(min_level=0, max_level=50, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_level=0, max_level=50, p=1.0)
- Parameters
min_level (
int
) – the lower value on the range of noise strength level values to choose from. 0 indicates no change, allowed range is [0, 100]max_level (
int
) – the upper value on the range of noise strength level values to choose from. 0 indicates no change, allowed range is [0, 100]p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly adds noise to a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomPixelization(min_ratio=0.1, max_ratio=1.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_ratio=0.1, max_ratio=1.0, p=1.0)
- Parameters
min_ratio (
float
) – the lower value on the range of pixelization ratio values to choose from. Smaller values result in a more pixelated video, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectmax_ratio (
float
) – the upper value on the range of pixelization ratio values to choose from. Smaller values result in a more pixelated video, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly pixelizes a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomRotation(min_degrees=0.0, max_degrees=180.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_degrees=0.0, max_degrees=180.0, p=1.0)
- Parameters
min_degrees (
float
) – the lower value on the range of degree values to choose frommax_degrees (
float
) – the upper value on the range of degree values to choose fromp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly rotates a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RandomVideoSpeed(min_factor=0.25, max_factor=4.0, p=1.0)
Bases:
augly.video.transforms.BaseRandomRangeTransform
- __init__(min_factor=0.25, max_factor=4.0, p=1.0)
- Parameters
min_factor (
float
) – the lower value on the range of speed values to choose from. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the video relative to the original speedmax_factor (
float
) – the upper value on the range of speed values to choose from. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the video relative to the original speedp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_random_transform(video_path, output_path, metadata=None)
Transform that randomly changes the video speed
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.RemoveAudio(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Removes the audio stream from a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.ReplaceWithBackground(background_path=None, source_offset=0.0, background_offset=0.0, source_percentage=0.5, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(background_path=None, source_offset=0.0, background_offset=0.0, source_percentage=0.5, p=1.0)
- Parameters
background_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framesoffset_factor – the point in the background video in which the main video starts to play (this factor is multiplied by the background video duration to determine the start point)
p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Puts the video in the middle of the background video (at offset_factor * background.duration)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.ReplaceWithColorFrames(offset_factor=0.0, duration_factor=1.0, color=(0, 0, 0), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(offset_factor=0.0, duration_factor=1.0, color=(0, 0, 0), p=1.0)
- Parameters
offset_factor (
float
) – start point of the replacement relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the replacement relative to the video duration (this parameter is multiplied by the video duration)color (
Tuple
[int
,int
,int
]) – RGB color of the replaced frames. Default color is blackp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Replaces part of the video with frames of the specified color
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Resize(height=None, width=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(height=None, width=None, p=1.0)
- Parameters
height (
Optional
[int
]) – the height in which the video should be resized to. If None, the original video height will be usedwidth (
Optional
[int
]) – the width in which the video should be resized to. If None, the original video width will be usedp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Resizes a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Rotate(degrees=15, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(degrees=15, p=1.0)
- Parameters
degrees (
float
) – expression for the angle by which to rotate the input video clockwise, expressed in degrees (supports negative values as well)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Rotates a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Scale(factor=0.5, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(factor=0.5, p=1.0)
- Parameters
factor (
float
) – the ratio by which the video should be down-scaled or upscaledp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Alters the resolution of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Shift(x_factor=0.0, y_factor=0.0, color=(0, 0, 0), p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(x_factor=0.0, y_factor=0.0, color=(0, 0, 0), p=1.0)
- Parameters
x_factor (
float
) – the horizontal amount that the video should be shifted, relative to the width of the videoy_factor (
float
) – the vertical amount that the video should be shifted, relative to the height of the videocolor (
Tuple
[int
,int
,int
]) – RGB color of the margin generated by the shift. Default color is blackp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Shifts the original frame position from the center by a vector (width * x_factor, height * y_factor) and pads the rest with a colored margin
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.TimeCrop(offset_factor=0.0, duration_factor=1.0, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(offset_factor=0.0, duration_factor=1.0, p=1.0)
- Parameters
offset_factor (
float
) – start point of the crop relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the crop relative to the video duration (this parameter is multiplied by the video duration)p (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Crops the video using the specified offset and duration factors
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.TimeDecimate(on_factor=0.2, off_factor=0.5, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(on_factor=0.2, off_factor=0.5, p=1.0)
- Parameters
on_factor (
float
) – relative to the video duration; the amount of time each “on” video chunk should beoff_factor (
float
) – relative to the “on” duration; the amount of time each “off” video chunk should bep (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Removes evenly sized (off) chunks, and concatenates evenly spaced (on) chunks from the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.Trim(start=None, end=None, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(start=None, end=None, p=1.0)
- Parameters
start (
Optional
[float
]) – starting point in seconds of when the trimmed video should start. If None, start will be 0end (
Optional
[float
]) – ending point in seconds of when the trimmed video should end. If None, the end will be the duration of the videop (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Trims the video using the specified start and end parameters
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.VFlip(p=1.0)
Bases:
augly.video.transforms.BaseTransform
- apply_transform(video_path, output_path, metadata=None)
Vertically flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- class augly.video.VStack(second_video_path, use_second_audio=False, p=1.0)
Bases:
augly.video.transforms.BaseTransform
- __init__(second_video_path, use_second_audio=False, p=1.0)
- Parameters
second_video_path (
str
) – the path to the video that will be stacked on the bottomuse_second_audio (
bool
) – if set to True, the audio of the bottom video will be used instead of the top’sp (
float
) – the probability of the transform being applied; default value is 1.0
- apply_transform(video_path, output_path, metadata=None)
Vertically stacks two videos
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
str
) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.add_noise(video_path, output_path=None, level=25, metadata=None)
Adds noise to a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenlevel (
int
) – noise strength for specific pixel component. Default value is 25. Allowed range is [0, 100], where 0 indicates no changemetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.apply_lambda(video_path, output_path=None, aug_function=<function identity_function>, metadata=None, **kwargs)
Apply a user-defined lambda on a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenaug_function (
Callable
[...
,Any
]) – the augmentation function to be applied onto the video (should expect a video path and output path as input and output the augmented video to the output path. Nothing needs to be returned)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned**kwargs –
the input attributes to be passed into aug_function
- Return type
str
- Returns
the path to the augmented video
- augly.video.audio_swap(video_path, audio_path, output_path=None, offset=0.0, metadata=None)
Swaps the video audio for the audio passed in provided an offset
- Parameters
video_path (
str
) – the path to the video to be augmentedaudio_path (
str
) – the iopath uri to the audio you’d like to swap with the video’s audiooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoffset (
float
) – starting point in seconds such that an audio clip of offset to offset + video_duration is used in the audio swap. Default value is zerometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.augment_audio(video_path, output_path=None, audio_aug_function=<function apply_lambda>, metadata=None, **audio_aug_kwargs)
Augments the audio track of the input video using a given AugLy audio augmentation
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenaudio_aug_function (
Callable
[...
,Tuple
[ndarray
,int
]]) – the augmentation function to be applied onto the video’s audio track. Should have the standard API of an AugLy audio augmentation, i.e. expect input audio as a numpy array or path & output path as input, and output the augmented audio to the output pathmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returnedaudio_aug_kwargs – the input attributes to be passed into audio_aug
- Return type
str
- Returns
the path to the augmented video
- augly.video.blend_videos(video_path, overlay_path, output_path=None, opacity=0.5, overlay_size=1.0, x_pos=0.0, y_pos=0.0, use_second_audio=True, metadata=None)
Overlays a video onto another video at position (width * x_pos, height * y_pos) at a lower opacity
- Parameters
video_path (
str
) – the path to the video to be augmentedoverlay_path (
str
) – the path to the video that will be overlaid onto the background videooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenopacity (
float
) – the lower the opacity, the more transparent the overlaid videooverlay_size (
float
) – size of the overlaid video is overlay_size * height of the background videox_pos (
float
) – position of overlaid video relative to the background video widthy_pos (
float
) – position of overlaid video relative to the background video heightuse_second_audio (
bool
) – use the audio of the overlaid video rather than the audio of the background videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.blur(video_path, output_path=None, sigma=1, metadata=None)
Blurs a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittensigma (
float
) – horizontal sigma, standard deviation of Gaussian blurmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.brightness(video_path, output_path=None, level=0.15, metadata=None)
Brightens or darkens a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenlevel (
float
) – the value must be a float value in range -1.0 to 1.0, where a negative value darkens and positive brightensmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.change_aspect_ratio(video_path, output_path=None, ratio=1.0, metadata=None)
Changes the sample aspect ratio attribute of the video, and resizes the video to reflect the new aspect ratio
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenratio (
Union
[float
,str
]) – aspect ratio of the new video, either as a float i.e. width/height, or as a string representing the ratio in the form “num:denom”metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.change_video_speed(video_path, output_path=None, factor=1.0, metadata=None)
Changes the speed of the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenfactor (
float
) – the factor by which to alter the speed of the video. A factor less than one will slow down the video, a factor equal to one won’t alter the video, and a factor greater than one will speed up the videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.color_jitter(video_path, output_path=None, brightness_factor=0, contrast_factor=1.0, saturation_factor=1.0, metadata=None)
Color jitters the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenbrightness_factor (
float
) – set the brightness expression. The value must be a float value in range -1.0 to 1.0. The default value is 0contrast_factor (
float
) – set the contrast expression. The value must be a float value in range -1000.0 to 1000.0. The default value is 1saturation_factor (
float
) – set the saturation expression. The value must be a float in range 0.0 to 3.0. The default value is 1metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.concat(video_paths, output_path=None, src_video_path_index=0, metadata=None)
Concatenates videos together. Resizes all other videos to the size of the source video (video_paths[src_video_path_index]), and modifies the sample aspect ratios to match (ffmpeg will fail to concat if SARs don’t match)
- Parameters
video_paths (
List
[str
]) – a list of paths to all the videos to be concatenated (in order)output_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittensrc_video_path_index (
int
) – for metadata purposes, this indicates which video in the list video_paths should be considered the source or original videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.contrast(video_path, output_path=None, level=1.0, metadata=None)
Alters the contrast of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenlevel (
float
) – the value must be a float value in range -1000.0 to 1000.0, where a negative value removes contrast and a positive value adds contrastmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.crop(video_path, output_path=None, left=0.25, top=0.25, right=0.75, bottom=0.75, metadata=None)
Crops the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenleft (
float
) – left positioning of the crop; between 0 and 1, relative to the video widthtop (
float
) – top positioning of the crop; between 0 and 1, relative to the video heightright (
float
) – right positioning of the crop; between 0 and 1, relative to the video widthbottom (
float
) – bottom positioning of the crop; between 0 and 1, relative to the video heightmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.encoding_quality(video_path, output_path=None, quality=23, metadata=None)
Alters the encoding quality of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenquality (
int
) – CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.fps(video_path, output_path=None, fps=15, metadata=None)
Alters the FPS of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenfps (
int
) – the desired output frame rate. Note that a FPS value greater than the original FPS of the video will result in an unaltered videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.grayscale(video_path, output_path=None, metadata=None)
Changes a video to be grayscale
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.hflip(video_path, output_path=None, metadata=None)
Horizontally flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.hstack(video_path, second_video_path, output_path=None, use_second_audio=False, metadata=None)
Horizontally stacks two videos
- Parameters
video_path (
str
) – the path to the video that will be stacked to the leftsecond_video_path (
str
) – the path to the video that will be stacked to the rightoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenuse_second_audio (
bool
) – if set to True, the audio of the right video will be used instead of the left’smetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.insert_in_background(video_path, output_path=None, background_path=None, offset_factor=0.0, source_percentage=None, seed=None, metadata=None)
Puts the video in the middle of the background video (at offset_factor * background.duration)
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenbackground_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framesoffset_factor (
float
) – the point in the background video in which the main video starts to play (this factor is multiplied by the background video duration to determine the start point)source_percentage (
Optional
[float
]) – when set, source_percentage of the duration of the final video (background + source) will be taken up by the source video. Randomly crops the background video to the correct duration. If the background video isn’t long enough to get the desired source_percentage, it will be looped.seed (
Optional
[int
]) – if provided, this will set the random seed to ensure consistency between runsmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.loop(video_path, output_path=None, num_loops=0, metadata=None)
Loops a video num_loops times
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittennum_loops (
int
) – the number of times to loop the video. 0 means that the video will play once (i.e. no loops)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.meme_format(video_path, output_path=None, text='LOL', font_file='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/fonts/Raleway-ExtraBold.ttf', opacity=1.0, text_color=(0, 0, 0), caption_height=250, meme_bg_color=(255, 255, 255), metadata=None)
Creates a new video that looks like a meme, given text and video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittentext (
str
) – the text to be overlaid/used in the meme. note: if using a very long string, please add in newline characters such that the text remains in a readable font sizefont_file (
str
) – iopath uri to the .ttf font fileopacity (
float
) – the lower the opacity, the more transparent the texttext_color (
Tuple
[int
,int
,int
]) – color of the text in RGB valuescaption_height (
int
) – the height of the meme captionmeme_bg_color (
Tuple
[int
,int
,int
]) – background color of the meme caption in RGB valuesmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay(video_path, overlay_path, output_path=None, overlay_size=None, x_factor=0.0, y_factor=0.0, use_overlay_audio=False, metadata=None)
Overlays media onto the video at position (width * x_factor, height * y_factor)
- Parameters
video_path (
str
) – the path to the video to be augmentedoverlay_path (
str
) – the path to the media (image or video) that will be overlaid onto the videooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_overlay_audio (
bool
) – if set to True and the media type is a video, the audio of the overlaid video will be used instead of the main/background video’s audiometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay_dots(video_path, output_path=None, num_dots=100, dot_type='colored', random_movement=True, metadata=None, **kwargs)
Overlays dots onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittennum_dots (
int
) – the number of dots to add to each framedot_type (
str
) – specify if you would like “blur” or “colored”random_movement (
bool
) – whether or not you want the dots to randomly move around across the frame or to move across in a “linear” waymetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay_emoji(video_path, output_path=None, emoji_path='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/twemojis/smileys/smiling_face_with_heart_eyes.png', x_factor=0.4, y_factor=0.4, opacity=1.0, emoji_size=0.15, metadata=None)
Overlays an emoji onto each frame of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenemoji_path (
str
) – iopath uri to the emoji imagex_factor (
float
) – specifies where the left side of the emoji should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the emoji should be placed, relative to the video heightopacity (
float
) – opacity of the emoji imageemoji_size (
float
) – emoji size relative to the height of the video framemetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay_onto_background_video(video_path, background_path, output_path=None, overlay_size=0.7, x_factor=0.0, y_factor=0.0, use_background_audio=False, metadata=None)
Overlays the video onto a background video, pointed to by background_path.
- Parameters
video_path (
str
) – the path to the video to be augmentedbackground_path (
str
) – the path to the background videooutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoverlay_size (
Optional
[float
]) – size of the overlaid media with respect to the background video. If set to None, the original size of the overlaid media is usedx_factor (
float
) – specifies where the left side of the overlaid media should be placed, relative to the video widthy_factor (
float
) – specifies where the top side of the overlaid media should be placed, relative to the video heightuse_background_audio (
bool
) – if set to True and the media type is a video, the audio of the background video will be used instead of the src video’s audiometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay_onto_screenshot(video_path, output_path=None, template_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/web.png', template_bboxes_filepath='/home/docs/checkouts/readthedocs.org/user_builds/augly/checkouts/latest/augly/assets/screenshot_templates/bboxes.json', max_image_size_pixels=None, crop_src_to_fit=False, metadata=None)
Overlays the video onto a screenshot template so it looks like it was screen-recorded on Instagram
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittentemplate_filepath (
str
) – iopath uri to the screenshot templatetemplate_bboxes_filepath (
str
) – iopath uri to the file containing the bounding box for each templatemax_image_size_pixels (
Optional
[int
]) – if provided, the template image and/or src video will be scaled down to avoid an output image with an area greater than this size (in pixels)crop_src_to_fit (
bool
) – if True, the src image will be cropped if necessary to fit into the template image. If False, the src image will instead be resized if necessarymetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay_shapes(video_path, output_path=None, num_shapes=1, shape_type=None, colors=None, thickness=None, radius=None, random_movement=True, topleft=None, bottomright=None, metadata=None, **kwargs)
Overlays random shapes onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittennum_shapes (
int
) – the number of shapes to add to each frameshape_type (
Optional
[str
]) – specify if you would like circles or rectanglescolors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the shapesrandom_movement (
bool
) – whether or not you want the shapes to randomly move around across the frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of shape region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.overlay_text(video_path, output_path=None, text_len=10, text_change_nth=None, fonts=None, fontscales=None, colors=None, thickness=None, random_movement=False, topleft=None, bottomright=None, metadata=None, **kwargs)
Overlays random text onto a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittentext_len (
int
) – length of string for randomized texts.text_change_nth (
Optional
[int
]) – change random text every nth frame. None means using same text for all frames.fonts (
Optional
[List
[Tuple
[Any
,Optional
[str
]]]]) – list of fonts to sample from. Each font can be a cv2 fontFace, a PIL ImageFont, or a path to a PIL ImageFont file. Each font is coupled with a chars file (the second item in the tuple) - a path to a file which contains the characters associated with the given font. For example, non-western alphabets have different valid characters than the roman alphabet, and these must be specified in order to construct random valid text in that font. If the chars file path is None, the roman alphabet will be used.fontscales (
Optional
[Tuple
[float
,float
]]) – 2-tuple of float (min_scale, max_scale).colors (
Optional
[List
[Tuple
[int
,int
,int
]]]) – list of (R, G, B) colors to sample fromthickness (
Optional
[int
]) – specify the thickness desired for the text.random_movement (
bool
) – whether or not you want the text to randomly move around across frame or to move across in a “linear” waytopleft (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightbottomright (
Optional
[Tuple
[float
,float
]]) – specifying the boundary of text region. The boundary are all floats [0, 1] representing the fraction w.r.t width/heightmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.pad(video_path, output_path=None, w_factor=0.25, h_factor=0.25, color=(0, 0, 0), metadata=None)
Pads the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenw_factor (
float
) – pad right and left with w_factor * frame widthh_factor (
float
) – pad bottom and top with h_factor * frame heightcolor (
Tuple
[int
,int
,int
]) – RGB color of the padded marginmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.perspective_transform_and_shake(video_path, output_path=None, sigma=50.0, shake_radius=0.0, seed=None, metadata=None)
Apply a perspective transform to the video so it looks like it was taken as a photo from another device (e.g. taking a video from your phone of a video on a computer). Also has a shake factor to mimic the shakiness of someone holding a phone.
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittensigma (
float
) – the standard deviation of the distribution of destination coordinates. The larger the sigma value, the more intense the transformshake_radius (
float
) – determines the amount by which to “shake” the video; the larger the radius, the more intense the shake.seed (
Optional
[int
]) – if provided, this will set the random seed to ensure consistency between runsmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.pixelization(video_path, output_path=None, ratio=1.0, metadata=None)
Pixelizes the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenratio (
float
) – smaller values result in a more pixelated video, 1.0 indicates no change, and any value above one doesn’t have a noticeable effectmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.remove_audio(video_path, output_path=None, metadata=None)
Removes the audio stream from a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.replace_with_background(video_path, output_path=None, background_path=None, source_offset=0.0, background_offset=0.0, source_percentage=0.5, metadata=None)
Replaces the beginning and end of the source video with the background video, keeping the total duration of the output video equal to the original duration of the source video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenbackground_path (
Optional
[str
]) – the path to the video in which to insert the main video. If set to None, the main video will play in the middle of a silent video with black framessource_offset (
float
) – the starting point where the background video transitions to the source video. Prior to this point, the source video is replaced with the background video. A value of 0 means all background is at the beginning. A value of 1 means all background is at the end of the videobackground_offset (
float
) – the starting point from which the background video starts to play, as a proportion of the background video duration (i.e. this factor is multiplied by the background video duration to determine the start point)source_percentage (
float
) – the percentage of the source video that remains unreplaced by the background video. The source percentage plus source offset should be less than 1. If it is greater, the output video duration will be longer than the source. If the background video is not long enough to get the desired source percentage, it will be loopedmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.replace_with_color_frames(video_path, output_path=None, offset_factor=0.0, duration_factor=1.0, color=(0, 0, 0), metadata=None)
Replaces part of the video with frames of the specified color
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoffset_factor (
float
) – start point of the replacement relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the replacement relative to the video duration (this parameter is multiplied by the video duration)color (
Tuple
[int
,int
,int
]) – RGB color of the replaced frames. Default color is blackmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.resize(video_path, output_path=None, height=None, width=None, metadata=None)
Resizes a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenheight (
Optional
[int
]) – the height in which the video should be resized to. If None, the original video height will be usedwidth (
Optional
[int
]) – the width in which the video should be resized to. If None, the original video width will be usedmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.rotate(video_path, output_path=None, degrees=15.0, metadata=None)
Rotates a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittendegrees (
float
) – expression for the angle by which to rotate the input video clockwise, expressed in degrees (supports negative values as well)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.scale(video_path, output_path=None, factor=0.5, metadata=None)
Alters the resolution of a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenfactor (
float
) – the ratio by which the video should be downscaled or upscaledmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.shift(video_path, output_path=None, x_factor=0.0, y_factor=0.0, color=(0, 0, 0), metadata=None)
Shifts the original frame position from the center by a vector (width * x_factor, height * y_factor) and pads the rest with a colored margin
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenx_factor (
float
) – the horizontal amount that the video should be shifted, relative to the width of the videoy_factor (
float
) – the vertical amount that the video should be shifted, relative to the height of the videocolor (
Tuple
[int
,int
,int
]) – RGB color of the margin generated by the shift. Default color is blackmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.time_crop(video_path, output_path=None, offset_factor=0.0, duration_factor=1.0, metadata=None)
Crops the video using the specified offset and duration factors
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenoffset_factor (
float
) – start point of the crop relative to the video duration (this parameter is multiplied by the video duration)duration_factor (
float
) – the length of the crop relative to the video duration (this parameter is multiplied by the video duration)metadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.time_decimate(video_path, output_path=None, on_factor=0.2, off_factor=0.5, metadata=None)
Removes evenly sized (off) chunks, and concatenates evenly spaced (on) chunks from the video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenon_factor (
float
) – relative to the video duration; the amount of time each “on” video chunk should beoff_factor (
float
) – relative to the “on” duration; the amount of time each “off” video chunk should bemetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.trim(video_path, output_path=None, start=None, end=None, metadata=None)
Trims the video using the specified start and end parameters
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenstart (
Optional
[float
]) – starting point in seconds of when the trimmed video should start. If None, start will be 0end (
Optional
[float
]) – ending point in seconds of when the trimmed video should end. If None, the end will be the duration of the videometadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.vflip(video_path, output_path=None, metadata=None)
Vertically flips a video
- Parameters
video_path (
str
) – the path to the video to be augmentedoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenmetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video
- augly.video.vstack(video_path, second_video_path, output_path=None, use_second_audio=False, metadata=None)
Vertically stacks two videos
- Parameters
video_path (
str
) – the path to the video that will be stacked on topsecond_video_path (
str
) – the path to the video that will be stacked on the bottomoutput_path (
Optional
[str
]) – the path in which the resulting video will be stored. If not passed in, the original video file will be overwrittenuse_second_audio (
bool
) – if set to True, the audio of the bottom video will be used instead of the top’smetadata (
Optional
[List
[Dict
[str
,Any
]]]) – if set to be a list, metadata about the function execution including its name, the source & dest duration, fps, etc. will be appended to the inputted list. If set to None, no metadata will be appended or returned
- Return type
str
- Returns
the path to the augmented video