Module fastedit.Medias

Classes

class Audio (path: str)

Initializing audio.

Parameters

path : str
Path to the audio file.

Ancestors

Methods

def clip(self, start, end, inplace: bool = False)

Extract a part of the audio.

Parameters

start : int or float
Time where the clip starts.
end : int or float
Time where the clip ends.
inplace : bool, default=False
If True, applying changes to the current object. If False, create a new Audio to apply changes.

Returns

Audio or None
If "inplace" is False, it returns an Audio containing the audio clipped. If "inplace" is True, it returns nothing.
def loop(self, duration, inplace: bool = False)

Create a loop of the audio.

Parameters

duration : int or float
Duration of the loop.
inplace : bool, default=False
If True, applying changes to the current object. If False, create a new Audio to apply changes.

Returns

Audio or None
If "inplace" is False, it returns an Audio containing the audio looped. If "inplace" is True, it returns nothing.

Inherited members

class Image (path: str)

Initializing Image.

Parameters

path : str
Path to the Image file.

Methods

def toVideo(self, duration, fps: int = 30, height: int = 720, width: int = 1280, pix_fmt: str = 'yuv420p', format: str = 'mp4')

Convert Image to Video.

Parameters

duration : int or float
Duration of the video in seconds.
fps : int, default=30
Framerate of the video.
height : int, default=720
Height of the video.
width : int, default=1280
Width of the video.
pix_fmt : str, default="yuv420p"
Pixel format of the video.

Returns

Video
Video containing the image.
class Media (path: str)

Initializing media.

Parameters

path : str
Path to the media file.

Subclasses

Methods

def changeVolume(self, volume)

Change the volume of the audio.

Parameters

volume : int or float
Factor by which the volume will be changed.
def getDuration(self)

Get current media duration.

Returns

float
Duration of the media.
def getMetadata(self)

Get current media metadata.

Returns

dict
Metadata of the media.
def save(self, path: str)

Saving the media to the file system.

Parameters

path : str
Path to the file to save the media.
class Video (path: str)

Initializing video.

Parameters

path : str
Path to the video file.

Ancestors

Methods

def addAudio(self, audio, strategy: str = None, inplace: bool = True)

Add or replace audio on the video.

Parameters

audio : Audio or None
Audio instance you want to add.
strategy : str
Method to add audio. Available options : "replace", "add", "combine" or "silent".
inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the new audio. If "inplace" is True, it returns nothing.
def addSubtitles(self, subtitles: Subtitles, strategy: str, channel: int = 0, lang: str = 'eng', fontName: str = 'Arial', fontSize: int = 16, fontPrimaryColor: str = '#ffffff', fontSecondaryColor: str = '#ffffff', outlineColor: str = '#00ffffff', backColor: str = '#00ffffff', bold: bool = False, italic: bool = False, underline: bool = False, borderStyle: int = 1, outline: int = 1, shadow: int = 0, alignment: str = 'bc', inplace: bool = True)

Add subtitles to the video.

Parameters

subtitles : Subtitles
Subtitles instance containing the subtitles.
strategy : str
Type of subtitles. Available options : ["hard", "soft"]. "hard" means subtitles are hard coded to the video. "soft" means subtitles are not burned into a video, they can be enabled and disabled during the video playback.
channel : int, default=0
If type is "soft", you have to specify the stream subtitle number of these subtitles.
lang : str, default="eng"
If type is "soft", you have to specify the subtitle language using the ISO 639 language code with 3 letters.
fontName : str, default="Arial"
The subtitle font as identified by operating systems (only available for hard subtitles).
fontSize : int, default=16
The point size of the font (only available for hard subtitles).
fontPrimaryColor : str, default="#ffffff"
The font color (only available for hard subtitles).
fontSecondaryColor : str, default="#ffffff"
A secondary font color (only available for hard subtitles).
outlineColor : str, default="#00ffffff"
The color used to outline the font (only available for hard subtitles).
backColor : str, default="#00ffffff"
The color of the subtitle shadow (only available for hard subtitles).
bold : bool, default=False
Bold creates the appearance of darker text by applying a thicker stroke weight to the letters (only available for hard subtitles).
italic : bool, default=False
Letters are slanted slightly to the right (only available for hard subtitles).
underline : bool, default=False
One horizontal line immediately below a portion of writing (only available for hard subtitles).
borderStyle : int, default=1
1 -> Outline with shadow, 3 -> Rendered with an opaque box (only available for hard subtitles).
outline : int, default=1
The width of the text outline, in pixels (only available for hard subtitles).
shadow : int, default=0
The depth of the text shadow, in pixels (only available for hard subtitles).
alignment : str, default="bc"
Alignment of subtitles (only available for hard subtitles). Available options: ["tl" (Top Left), "tc" (Top Center), "tr" (Top Right), "ml" (Middle Left), "mc" (Middle Center), "mr" (Middle Right), "bl" (Bottom Left), "bc" (Bottom Center), "br" (Bottom Right)]
inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video with the subtitles. If "inplace" is True, it returns nothing.
def addText(self, texts: list, inplace: bool = True)

Add text(s) in the video.

Parameters

text : list[Texts]
List of text(s) to display on the video.
inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video with texts. If "inplace" is True, it returns nothing.
def changeFrameRate(self, fps: int = 30, inplace: bool = True)

Change video's frames per seconds.

Parameters

fps : int, default=30
Desired frames per seconds.
inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video with the new frame rate. If "inplace" is True, it returns nothing.
def clip(self, start, end, inplace: bool = False)

Extract a part of the video.

Parameters

start : int or float
Time where the clip starts in seconds.
end : int or float
Time where the clip ends in seconds.
inplace : bool, default=False
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video clipped. If "inplace" is True, it returns nothing.
def convert(self, container: str = 'mp4', vcodec: str = 'copy', acodec: str = 'copy', inplace: bool = True)

Convert video to different container and/or codec.

Parameters

container : str, default="mp4"
File format where the data streams will be embedded.
vcodec : str, default="copy"
The way to encode/decode video data stream. Refers to FFmpeg video codecs supported.
acodec : str, default="copy"
The way to encode/decode audio data stream. Refers to FFmpeg audio codecs supported.
inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video converted. If "inplace" is True, it returns nothing.
def loop(self, duration, inplace: bool = False)

Create a loop from a video.

Parameters

duration : int or float
Duration of the loop.
inplace : bool, default=False
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video looped. If "inplace" is True, it returns nothing.
def removeAudio(self, inplace: bool = True)

Remove audio on the video.

Parameters

inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video without audio. If "inplace" is True, it returns nothing.
def resize(self, width: int, height: int, strategy: str = 'simple', inplace: bool = True)

Resize video.

Parameters

width : int
Desired width of the video.
height : int
Desired height of the video.
strategy : int, default="simple"
Type of resizing. Available options: ["simple", "aspect_ratio"].
inplace : bool, default=True
If True, applying changes to the current object. If False, create a new Video to apply changes.

Returns

Video or None
If "inplace" is False, it returns a Video containing the video resized. If "inplace" is True, it returns nothing.

Inherited members