ffmpeg_wrapper

Overview

Function

concatenate_videos(input_file, target_file_name, ratioToMultiplyAnimations, bias, fps, max_fps)

Concatenate all the videos in the list using a concatenation file

convert_as_mp3_file(fileName, target_file_name)

Save the incoming audio file to a regular mp3 file with a standardized filename

extract_audio_slice(audiofile_path, start, end, target_file_name)

Extract a slice of the audio file using ffmpeg

get_first_frame_as_image_ffmpeg(media_url, target_path)

Get the first frame of the video

get_last_frame_as_image_ffmpeg(media_url, target_path)

Get the last frame of the video

get_media_duration(input_video_path)

Get the duration of a media file.

get_media_fps(input_video_path)

Get the frames per second of a media file.

has_audio_track(video_path)

Check if the video has an audio track

merge_audio(media_url, audio_file_path, audio_file_relative_volume, target_file_name)

Merge audio with the video

reencode_video(video_url, target_video_name)

Reencode the video, doing this for imported video that might not concatenate well

Functions

async ffmpeg_wrapper.concatenate_videos(input_file: str, target_file_name=None, ratioToMultiplyAnimations=1, bias=0.33, fps=16, max_fps=16)

Concatenate all the videos in the list using a concatenation file

Parameters:
  • input_file (str) -- The path to the input file

  • target_file_name (str) -- The target file name

  • ratioToMultiplyAnimations (int) -- The ratio to multiply animations

  • bias (int) -- The bias to add to the ratio for the sound to be in sync with video frames

Returns:

The path to the concatenated video file

Return type:

str

async ffmpeg_wrapper.convert_as_mp3_file(fileName, target_file_name: str)

Save the incoming audio file to a regular mp3 file with a standardized filename

Parameters:

fileName (str) -- The path to the audio file to convert

Returns:

The path to the converted audio file

Return type:

str

async ffmpeg_wrapper.extract_audio_slice(audiofile_path: str, start: float = 0, end: float = 1, target_file_name: str = None)

Extract a slice of the audio file using ffmpeg

Parameters:
  • start (int) -- The start of the slice

  • end (int) -- The end of the slice

  • audiofile_path (str) -- The path to the audio file

  • target_file_name -- the target file name

Returns:

The path to the extracted audio slice

Return type:

str

async ffmpeg_wrapper.get_first_frame_as_image_ffmpeg(media_url, target_path=None)

Get the first frame of the video

async ffmpeg_wrapper.get_last_frame_as_image_ffmpeg(media_url, target_path=None)

Get the last frame of the video

ffmpeg_wrapper.get_media_duration(input_video_path)

Get the duration of a media file.

Parameters:

input_video_path (str) -- The path to the input video file.

Returns:

The duration of the media file in seconds.

Return type:

float

ffmpeg_wrapper.get_media_fps(input_video_path)

Get the frames per second of a media file.

Parameters:

input_video_path (str) -- The path to the input video file.

Returns:

The FPS of the media file in frames per seconds.

Return type:

float

ffmpeg_wrapper.has_audio_track(video_path)

Check if the video has an audio track

Parameters:

video_path (str) -- The path to the video file

Returns:

True if the video has an audio track, False otherwise

Return type:

bool

async ffmpeg_wrapper.merge_audio(media_url: str, audio_file_path: str, audio_file_relative_volume: float = None, target_file_name=None)

Merge audio with the video

Parameters:
  • media_url (str) -- The media url to merge

  • audio_file_path (str) -- The audio file path to merge

  • audio_file_relative_volume (float) -- The relative volume of the audio file

  • target_file_name (str) -- The target file name

Returns:

The merged audio file path

Return type:

str

async ffmpeg_wrapper.reencode_video(video_url, target_video_name=None)

Reencode the video, doing this for imported video that might not concatenate well with generated ones or among themselves

Parameters:
  • video_url (str) -- The video url to reencode

  • target_video_name (str) -- The target video name

Returns:

The reencoded video

Return type:

Video