veditor.editor module

class veditor.editor.VEditor(elements: List[veditor.elements.base.BaseElement] = [], width: Optional[int] = None, height: Optional[int] = None, bgRGB: Optional[Tuple[int, int, int]] = (0, 0, 0))[source]

Bases: veditor.elements.base.BaseElement

set_element_attributes(width: Optional[int] = None, height: Optional[int] = None, bgRGB: Optional[Tuple[int, int, int]] = (0, 0, 0))None[source]
set_trbl()[source]
set_pos_frames()None[source]
append(element: veditor.elements.base.BaseElement)None[source]

Append a new element

Parameters

element (BaseElement) – An instance of BaseElement.

edit(frame: numpy.ndarray[Any, numpy.dtype[numpy.uint8]], pos: int)numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]

Edit a pos-th frame in the video vide_path.

Parameters
  • frame (npt.NDArray[np.uint8]) – The current frame (BGR image) in the video.

  • pos (int) – The current position in the video.

Returns

An editied frame.

Return type

npt.NDArray[np.uint8]

check_work(pos: int, frame: Optional[numpy.ndarray[Any, numpy.dtype[numpy.uint8]]] = None, as_pil: bool = True)Union[numpy.ndarray[Any, numpy.dtype[numpy.uint8]], PIL.Image.Image][source]

Check the editing result for pos frame in video at video_path of this editor.

Parameters
  • pos (int) – The position in the video.

  • frame (Optional[npt.NDArray[np.uint8]], optional) – [description]. Defaults to None

  • as_pil (bool, optional) – Whether to return object as Image.Image or npt.NDArray[npt.uint8]. Defaults to True.

Raises

ValueError – When bgRGB is not set, and frame is None.

Returns

An editing result for the pos-th frame.

Return type

Union[npt.NDArray[np.uint8], Image.Image]

check_works(out_path: Optional[str] = None, codec: str = 'H264', fps: Optional[float] = None, open: bool = True, **kwargs)str[source]

Check the editing results of this editor.

Parameters
  • out_path (Optional[str], optional) – Path to the created video. Defaults to None.

  • codec (str, optional) – Video codec for the created video. Defaults to "H264".

  • fps (Optional[float], optional) – Frame rate of the output video. Defaults to None.

  • open (bool, optional) – Whether to open output file or not. Defaults to True.

Returns

The path to the created video.

Return type

str

export(out_path: Optional[str] = None, codec: str = 'H264', fps: Optional[float] = None, open: bool = True, **kwargs)str[source]

Create a video with each element in elements.

Parameters
  • out_path (Optional[str], optional) – Path to the output video. Defaults to None.

  • codec (str, optional) – Video codec for the output video. Defaults to "H264".

  • fps (Optional[float], optional) – Frame rate of the output video. Defaults to None.

  • open (bool, optional) – Whether to open the created video file. Defaults to True.

Returns

The path to the created video file.

Return type

str

synthesize_audio(out_path: str, open: bool = True)str[source]

Create audio with each editor in editors and attach it to the video at out_path.

Parameters
  • out_path (str) – The path to the output video.

  • open (bool, optional) – Whether to open the created video file. Defaults to True.

Returns

The path to the created video file.

Return type

str

overlayed_audio_create(video_path: str, fps: float)str[source]