veditor.elements.video module¶
- class veditor.elements.video.VideoElement(video_path: str, start_pos: int = 0, margin: Union[int, List[int]] = 0, width: Optional[int] = None, height: Optional[int] = None, top: Optional[Union[veditor.elements.base.BaseElement, int]] = 0, right: Optional[Union[veditor.elements.base.BaseElement, int]] = None, left: Optional[Union[veditor.elements.base.BaseElement, int]] = 0, bottom: Optional[Union[veditor.elements.base.BaseElement, int]] = None)[source]¶
Bases:
veditor.elements.base.FixedElement
- calc_element_size(video_path: Optional[str] = None, width: Optional[int] = None, height: Optional[int] = None, **kwargs) → Tuple[int, int][source]¶
Basic method for calculating the element size.
- Parameters
width (Optional[int], optional) – Element width. Defaults to
None
.height (Optional[int], optional) – Element height. Defaults to
None
.
- Returns
Tu
- Return type
Tuple[int, int]
- property video_filename: str¶
Final component of a pathname of
video_path
.
- 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 videovide_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, 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 atvideo_path
of this editor.- Parameters
pos (int) – The position in the video.
as_pil (bool, optional) – Whether to return object as
Image.Image
ornpt.NDArray[npt.uint8]
. Defaults toTrue
.
- Returns
An editing result for the
pos
-th frame.- Return type
Union[npt.NDArray[np.uint8], Image.Image]
- check_works(audio_path: Optional[str] = None, out_path: Optional[str] = None, codec: str = 'H264', H: Optional[int] = None, W: Optional[int] = None, fps: Optional[float] = None, open: bool = True, **kwargs) → str[source]¶
Check the editing results of this editor.
- Parameters
audio_path (str, optional) – Path to the audio file. Defaults to
None
. (Same asvideo_path
.)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"
.H (Optional[int], optional) – Height of the output video. Defaults to
None
.W (Optional[int], optional) – Width of the output video. Defaults to
None
.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', H: Optional[int] = None, W: Optional[int] = None, 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"
.H (Optional[int], optional) – Height of the output video. Defaults to
None
.W (Optional[int], optional) – Width of the output video. Defaults to
None
.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 atout_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