video_encoding.encoding package

Submodules

video_encoding.encoding.local module

video_encoding.encoding.local.create_temp_folder()[source]

Create temporary directory.

Returns

Tempfile object.

Return type

tempfile.TemporaryDirectory

video_encoding.encoding.utils module

video_encoding.encoding.utils.clean_up(path)[source]

Remove the folder

Parameters

path (str) – Path or folder to remove.

video_encoding.encoding.utils.get_file_name_extension(path)[source]

Get the file name and extension from the path.

Parameters

path (str) – Path of the file.

Returns

Tuple of file name and file extension.

Return type

Tuple(str, str)

video_encoding.encoding.video_encoding module

class video_encoding.encoding.video_encoding.Process(in_path, resolution, out_path)[source]

Bases: object

convert(video, writer, width, height)[source]

Convert the video frame by frame into the provided resolution frame by frame.

# TODO: Make this function parallel.

Parameters
  • video (cv2.VideoCapture) – Video that is to be encoded into a given resolution.

  • writer (cv2.VideoWriter) – Video writer which writes the encoded video frame by frame.

  • width (int) – Width according to the resolution to be set for the video.

  • height (int) – Height according to the resolution to be set for the video.

Return type

None

encode_audio(temp_video_path)[source]

Encode the audio into resized video.

Parameters

temp_video_path (str) – Temporary file path where the resized video is stored.

Returns

Final resized video to choosen resolution.

Return type

VideoFileClip

property encode_video

Encode the video and perform the process of conversion of and saving the video.

extract_audio()[source]

Extract audio from video.

Returns

Audio extracted from the video.

Return type

AudioFileClip

get_height_width_res()[source]

Get the height and width for a given resolution.

Returns

Height and width for a given resolution.

Return type

namedtuple

writer_setup(temp_path, fps, codec, width, height)[source]

Video writer setup according to the original frame per second, codec, width and height.

Here it is ensured that we preseve the original codec and frames per second (fps) of the original video. Hence the fps and the codec are extracted from the video information before the conversion of the video.

Parameters
  • temp_path (str) – Temporary path where encoded video is stored.

  • fps (float) – Frame per second of the original video before encoding. This is to preserve the fps from the original video.

  • codec (str) – Video coded to be used. This is determined by the extension currently.

  • width (int) – Width to set according to the resolution.

  • height (int) – Height to set according to the resolution.

Returns

OpenCV video writer object with the settings from the original video.

Return type

cv2.VideoWriter

video_encoding.encoding.video_information module

Function or utilities to get more information about the video. These includes functions to get video properties like:

  • Frame Rate

  • Video Height

  • Video Width

  • Total number of frames

video_encoding.encoding.video_information.Video_information[source]

alias of video_encoding.encoding.video_information.VideoInfo

video_encoding.encoding.video_information.get_video_information(video)[source]

Collect and present information about the video.

This function get the following information about a video. * Frame Rate * Width of the video. * Height of the video. * Total frames in a video.

Parameters

video (cv2.VideoCapture) – Video for which the information is required.

Returns

Frame rate, width, height and total frames in a video.

Return type

Video_information