augly.video.helpers package

Submodules

augly.video.helpers.ffmpeg module

augly.video.helpers.ffmpeg.add_silent_audio(video_path, output_path=None, duration=None)
Return type

None

augly.video.helpers.ffmpeg.combine_frames_and_audio_to_file(raw_frames, audio, output_path, framerate)
Return type

None

augly.video.helpers.ffmpeg.execute_vidgear_command(output_path, ffmpeg_command)
Return type

None

augly.video.helpers.ffmpeg.extract_audio_to_file(video_path, output_audio_path)
Return type

None

augly.video.helpers.ffmpeg.extract_frames_to_dir(video_path, output_dir, output_pattern='raw_frame%08d.jpg', quality=0, scale=1)
Return type

None

augly.video.helpers.ffmpeg.get_audio_info(media_path)

Returns whatever ffprobe returns. Of particular use are things such as the encoder (“codec_name”) used for audio encoding, the sample rate (“sample_rate”), and length in seconds (“duration”)

Accepts as input either an audio or video path.

Return type

Dict[str, Any]

augly.video.helpers.ffmpeg.get_video_fps(video_path)
Return type

Optional[float]

augly.video.helpers.ffmpeg.get_video_info(video_path)

Returns whatever ffprobe returns. Of particular use are things such as the FPS (“avg_frame_rate”), number of raw frames (“nb_frames”), height and width of each frame (“height”, “width”) and length in seconds (“duration”)

Return type

Dict[str, Any]

augly.video.helpers.ffmpeg.has_audio_stream(video_path)
Return type

bool

augly.video.helpers.ffmpeg.merge_video_and_audio(video_path, audio_path, output_path)
Return type

None

augly.video.helpers.intensity module

augly.video.helpers.intensity.add_noise_intensity(level, **kwargs)
Return type

float

augly.video.helpers.intensity.apply_lambda_intensity(aug_function, **kwargs)
Return type

float

augly.video.helpers.intensity.audio_swap_intensity(offset, **kwargs)
Return type

float

augly.video.helpers.intensity.augment_audio_intensity(audio_metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.blend_videos_intensity(opacity, overlay_size, **kwargs)
Return type

float

augly.video.helpers.intensity.blur_intensity(sigma, **kwargs)
Return type

float

augly.video.helpers.intensity.brightness_intensity(level, **kwargs)
Return type

float

augly.video.helpers.intensity.change_aspect_ratio_intensity(ratio, metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.change_video_speed_intensity(factor, **kwargs)
Return type

float

augly.video.helpers.intensity.color_jitter_intensity(brightness_factor, contrast_factor, saturation_factor, **kwargs)
Return type

float

augly.video.helpers.intensity.concat_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.contrast_intensity(level, **kwargs)
Return type

float

augly.video.helpers.intensity.crop_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.distractor_overlay_intensity_helper(topleft, bottomright, num_overlay_content, **kwargs)

Computes intensity of any distractor-type transform, which adds some kind of media (images, emojis, text, dots, logos) on top of the src video within a specified bounding box.

Return type

float

augly.video.helpers.intensity.encoding_quality_intensity(quality, **kwargs)
Return type

float

augly.video.helpers.intensity.fps_intensity(fps, metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.grayscale_intensity(**kwargs)
Return type

float

augly.video.helpers.intensity.hflip_intensity(**kwargs)
Return type

float

augly.video.helpers.intensity.hstack_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.identity_function_intensity(**kwargs)
Return type

float

augly.video.helpers.intensity.insert_in_background_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.loop_intensity(num_loops, **kwargs)
Return type

float

augly.video.helpers.intensity.meme_format_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_dots_intensity(num_dots, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_emoji_intensity(emoji_size, opacity, metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_intensity(overlay_size, overlay_path, metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_onto_background_video_intensity(overlay_size, metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_onto_screenshot_intensity(template_filepath, template_bboxes_filepath, metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_shapes_intensity(topleft, bottomright, num_shapes, **kwargs)
Return type

float

augly.video.helpers.intensity.overlay_text_intensity(topleft, bottomright, **kwargs)
Return type

float

augly.video.helpers.intensity.pad_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.perspective_transform_and_shake_intensity(sigma, shake_radius, **kwargs)
Return type

float

augly.video.helpers.intensity.pixelization_intensity(ratio, **kwargs)
Return type

float

augly.video.helpers.intensity.remove_audio_intensity(**kwargs)
Return type

float

augly.video.helpers.intensity.replace_with_background_intensity(metadata, **kwargs)

The intensity of replace_with_background is the fraction of the source video duration that was replaced with background. Because the overall duration of the video is preserved, the background segments together must be shorter than the source duration so the intensity is never greater than 100.

Return type

float

augly.video.helpers.intensity.replace_with_color_frames_intensity(duration_factor, offset_factor, **kwargs)
Return type

float

augly.video.helpers.intensity.resize_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.rotate_intensity(degrees, **kwargs)
Return type

float

augly.video.helpers.intensity.scale_intensity(factor, **kwargs)
Return type

float

augly.video.helpers.intensity.shift_intensity(x_factor, y_factor, **kwargs)
Return type

float

augly.video.helpers.intensity.time_crop_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.time_crop_or_pad_intensity_helper(metadata)

Computes intensity of a transform that consists of temporal cropping or padding. For these types of transforms the intensity is defined as the percentage of video time that has been cut out (for cropping) or added (for padding). When computing the percentage, the denominator should be the longer of the src & dst durations so the resulting percentage isn’t greater than 100.

Return type

float

augly.video.helpers.intensity.time_decimate_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.trim_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.intensity.vflip_intensity(**kwargs)
Return type

float

augly.video.helpers.intensity.vstack_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.utils module

augly.video.helpers.utils.create_color_video(output_path, duration, height, width, color=(0, 0, 0))

Creates a video with frames of the specified color

Parameters
  • output_path (str) – the path in which the resulting video will be stored

  • duration (float) – how long the video should be, in seconds

  • height (int) – the desired height of the video to be generated

  • width (int) – the desired width of the video to be generated

  • color (Tuple[int, int, int]) – RGB color of the video. Default color is black

Return type

None

augly.video.helpers.utils.create_video_from_image(output_path, image_path, duration)

Creates a video with all frames being the image provided

Parameters
  • output_path (str) – the path in which the resulting video will be stored

  • image_path (str) – the path to the image to use to create the video

  • duration (float) – how long the video should be, in seconds

Return type

None

augly.video.helpers.utils.get_local_path(video_path)
Return type

str

augly.video.helpers.utils.identity_function(video_path, output_path=None, metadata=None)
Return type

str

augly.video.helpers.utils.validate_input_and_output_paths(video_path, output_path)
Return type

Tuple[str, str]

Module contents

augly.video.helpers.add_noise_intensity(level, **kwargs)
Return type

float

augly.video.helpers.add_silent_audio(video_path, output_path=None, duration=None)
Return type

None

augly.video.helpers.apply_lambda_intensity(aug_function, **kwargs)
Return type

float

augly.video.helpers.audio_swap_intensity(offset, **kwargs)
Return type

float

augly.video.helpers.augment_audio_intensity(audio_metadata, **kwargs)
Return type

float

augly.video.helpers.blend_videos_intensity(opacity, overlay_size, **kwargs)
Return type

float

augly.video.helpers.blur_intensity(sigma, **kwargs)
Return type

float

augly.video.helpers.brightness_intensity(level, **kwargs)
Return type

float

augly.video.helpers.change_aspect_ratio_intensity(ratio, metadata, **kwargs)
Return type

float

augly.video.helpers.change_video_speed_intensity(factor, **kwargs)
Return type

float

augly.video.helpers.color_jitter_intensity(brightness_factor, contrast_factor, saturation_factor, **kwargs)
Return type

float

augly.video.helpers.combine_frames_and_audio_to_file(raw_frames, audio, output_path, framerate)
Return type

None

augly.video.helpers.compute_changed_segments(name, src_segments, dst_segments, src_duration, dst_duration, speed_factor, **kwargs)

This function performs the logic of computing the new matching segments based on the old ones, for the set of transforms that temporally change the video.

Returns the lists of new src segments & dst segments, respectively.

Return type

Tuple[List[Segment], List[Segment]]

augly.video.helpers.compute_segments(name, src_duration, dst_duration, metadata, **kwargs)

Compute matching pairs of src_segment -> dst_segment, given the kwargs of the transform, as well as the metadata about previously applied transforms.

Return type

Tuple[List[Segment], List[Segment]]

augly.video.helpers.compute_time_crop_segments(src_segment, dst_segment, speed_factor, crop_start, crop_end, new_src_segments, new_dst_segments)

Calculates how the given matching pair src_segment & dst_segment change given a temporal crop starting at crop_start & ending at crop_end. We can use the same logic here for multiple transforms, by setting the crop_start & crop_end depending on the transform kwargs.

Doesn’t return anything, but appends the new matching segments in the dst video corresponding to the pair passed in to new_src_segments & new_dst_segments, if the segment pair still matches in the dst video. If the passed in segment pair is cropped out as a result of this temporal crop, nothing will be appended to the lists, since the segment pair doesn’t exist in the dst video.

Return type

None

augly.video.helpers.compute_time_decimate_segments(src_segment, dst_segment, src_duration, speed_factor, new_src_segments, new_dst_segments, **kwargs)
Return type

None

augly.video.helpers.concat_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.contrast_intensity(level, **kwargs)
Return type

float

augly.video.helpers.create_color_video(output_path, duration, height, width, color=(0, 0, 0))

Creates a video with frames of the specified color

Parameters
  • output_path (str) – the path in which the resulting video will be stored

  • duration (float) – how long the video should be, in seconds

  • height (int) – the desired height of the video to be generated

  • width (int) – the desired width of the video to be generated

  • color (Tuple[int, int, int]) – RGB color of the video. Default color is black

Return type

None

augly.video.helpers.create_video_from_image(output_path, image_path, duration)

Creates a video with all frames being the image provided

Parameters
  • output_path (str) – the path in which the resulting video will be stored

  • image_path (str) – the path to the image to use to create the video

  • duration (float) – how long the video should be, in seconds

Return type

None

augly.video.helpers.crop_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.encoding_quality_intensity(quality, **kwargs)
Return type

float

augly.video.helpers.extract_audio_to_file(video_path, output_audio_path)
Return type

None

augly.video.helpers.extract_frames_to_dir(video_path, output_dir, output_pattern='raw_frame%08d.jpg', quality=0, scale=1)
Return type

None

augly.video.helpers.fps_intensity(fps, metadata, **kwargs)
Return type

float

augly.video.helpers.get_audio_info(media_path)

Returns whatever ffprobe returns. Of particular use are things such as the encoder (“codec_name”) used for audio encoding, the sample rate (“sample_rate”), and length in seconds (“duration”)

Accepts as input either an audio or video path.

Return type

Dict[str, Any]

augly.video.helpers.get_func_kwargs(metadata, local_kwargs, video_path, **kwargs)
Return type

Dict[str, Any]

augly.video.helpers.get_local_path(video_path)
Return type

str

augly.video.helpers.get_metadata(metadata, function_name, video_path, output_path, src_video_info, src_fps, **kwargs)
Return type

None

augly.video.helpers.get_video_fps(video_path)
Return type

Optional[float]

augly.video.helpers.get_video_info(video_path)

Returns whatever ffprobe returns. Of particular use are things such as the FPS (“avg_frame_rate”), number of raw frames (“nb_frames”), height and width of each frame (“height”, “width”) and length in seconds (“duration”)

Return type

Dict[str, Any]

augly.video.helpers.grayscale_intensity(**kwargs)
Return type

float

augly.video.helpers.has_audio_stream(video_path)
Return type

bool

augly.video.helpers.hflip_intensity(**kwargs)
Return type

float

augly.video.helpers.hstack_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.identity_function(video_path, output_path=None, metadata=None)
Return type

str

augly.video.helpers.insert_in_background_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.loop_intensity(num_loops, **kwargs)
Return type

float

augly.video.helpers.meme_format_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.overlay_dots_intensity(num_dots, **kwargs)
Return type

float

augly.video.helpers.overlay_emoji_intensity(emoji_size, opacity, metadata, **kwargs)
Return type

float

augly.video.helpers.overlay_intensity(overlay_size, overlay_path, metadata, **kwargs)
Return type

float

augly.video.helpers.overlay_onto_background_video_intensity(overlay_size, metadata, **kwargs)
Return type

float

augly.video.helpers.overlay_onto_screenshot_intensity(template_filepath, template_bboxes_filepath, metadata, **kwargs)
Return type

float

augly.video.helpers.overlay_shapes_intensity(topleft, bottomright, num_shapes, **kwargs)
Return type

float

augly.video.helpers.overlay_text_intensity(topleft, bottomright, **kwargs)
Return type

float

augly.video.helpers.pad_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.perspective_transform_and_shake_intensity(sigma, shake_radius, **kwargs)
Return type

float

augly.video.helpers.pixelization_intensity(ratio, **kwargs)
Return type

float

augly.video.helpers.remove_audio_intensity(**kwargs)
Return type

float

augly.video.helpers.replace_with_background_intensity(metadata, **kwargs)

The intensity of replace_with_background is the fraction of the source video duration that was replaced with background. Because the overall duration of the video is preserved, the background segments together must be shorter than the source duration so the intensity is never greater than 100.

Return type

float

augly.video.helpers.replace_with_color_frames_intensity(duration_factor, offset_factor, **kwargs)
Return type

float

augly.video.helpers.rotate_intensity(degrees, **kwargs)
Return type

float

augly.video.helpers.scale_intensity(factor, **kwargs)
Return type

float

augly.video.helpers.shift_intensity(x_factor, y_factor, **kwargs)
Return type

float

augly.video.helpers.time_crop_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.time_decimate_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.trim_intensity(metadata, **kwargs)
Return type

float

augly.video.helpers.validate_input_and_output_paths(video_path, output_path)
Return type

Tuple[str, str]

augly.video.helpers.vflip_intensity(**kwargs)
Return type

float

augly.video.helpers.vstack_intensity(metadata, **kwargs)
Return type

float