Basic Concepts¶
VidioPY primarily works with two types of clips: VideoClip
and AudioClip
. Both are derived from the Clip
base class and can be manipulated in various ways such as cutting, slowing down, darkening, or mixing with other clips to create new ones. These clips can then be exported to various file formats such as MP4, GIF, MP3, etc.
flowchart TB
Clip[Clip]
Clip -->|inherits| VideoClip[VideoClip]
Clip -->|inherits| AudioClip[AudioClip]
VideoClip -->|inherits| ImageClip[ImageClip]
VideoClip -->|inherits| VideoFileClip[VideoFileClip]
VideoClip -->|inherits| ImageSequenceClip[ImageSequenceClip]
ImageClip -->|inherits| Data2ImageClip[Data2ImageClip]
Data2ImageClip -->|inherits| TextClip[TextClip]
Data2ImageClip -->|inherits| ColorClip[ColorClip]
AudioClip -->|inherits| SilenceClip[SilenceClip]
SilenceClip -->|inherits| AudioFileClip[AudioFileClip]
AudioClip -->|inherits| AudioArrayClip[AudioArrayClip]
VideoClip
instances can be created from a video file, an image, a text, or a custom animation, and can include an audio track, which is an AudioClip
.
VidioPY provides numerous effects that can be applied to a clip (e.g., clip.resize(width="360")
, clip.subclip(t1,t2)
, or clip.fx(vidiopy.brightness, 1.5)
). Additionally, VidioPY implements several functions (like clip.fl_frame_transform
, clip.fl_clip_transform
, clip.fl_time_transform
, clip.fx
, etc.) that make it easy to create custom effects.
VideoClip¶
Creating a VideoClip¶
A VideoClip
can be created in several ways. The most common method is to load a video file using VideoFileClip
:
A VideoClip can also be created from an image:
Modifying a VideoClip¶
A VideoClip
has several attributes such as fps, duration, size, audio, start, end, etc. These can be modified using the corresponding set
methods:
Applying Effects to a VideoClip¶
Various effects can be applied to a VideoClip, including resize, crop, subclip, fx, etc.:
Exporting a VideoClip¶
A VideoClip
can be exported to a file using the write_videofile
method:
ImageClip¶
Creating an ImageClip¶
An ImageClip
can be created by loading an image file using ImageClip
or by creating a new image using Image.new
or a numpy array:
applying Effects to a ImageClip¶
All Effects that can be applied to the VideoClip
can be applied to the ImageClip
but it is bit different. Some effects you can apply directly to the ImageClip
like the Video Clip but Some Cant Directly for that you have to convert the ImageClip
to the VideoClip
and then apply the effect:
AudioClip¶
Creating an AudioClip¶
An AudioClip
can be created by loading an audio file using AudioFileClip
or SilenceClip
:
Modifying an AudioClip¶
An AudioClip
has several attributes such as audio_data, fps, start, end, etc. These can be modified using the corresponding set
methods:
Applying Effects to an AudioClip¶
An AudioClip
has several attributes such as audio_data, fps, start, end, etc. These can be modified using the corresponding set methods:
Exporting an AudioClip¶
An AudioClip
can be exported to a file using the write_audiofile
method:
Final Flowchart¶
graph TD
Start((Start)) --> ChooseClipType[Choose Clip Type]
ChooseClipType --> |VideoClip| CreateVideoClip[Create VideoClip]
ChooseClipType --> |ImageClip| CreateImageClip[Create ImageClip]
ChooseClipType --> |AudioClip| CreateAudioClip[Create AudioClip]
CreateVideoClip --> |Load from file| LoadVideoFile["Load from file"]
CreateVideoClip --> |Create from image| CreateVideoFromImage["Create from image"]
LoadVideoFile --> ModifyVideoClip[Modify VideoClip]
CreateVideoFromImage --> ModifyVideoClip
ModifyVideoClip --> |Set duration| SetDuration["Set duration"]
ModifyVideoClip --> |Set FPS| SetFPS["Set FPS"]
ModifyVideoClip --> |Set start/end| SetStartEnd["Set start/end"]
ModifyVideoClip --> |Set audio| SetAudio["Set audio"]
ModifyVideoClip --> ApplyEffectsToVideo[Apply Effects to VideoClip]
ApplyEffectsToVideo --> |Resize| ResizeClip["Resize"]
ApplyEffectsToVideo --> |Crop| CropClip["Crop"]
ApplyEffectsToVideo --> |Subclip| Subclip["Subclip"]
ApplyEffectsToVideo --> |Apply custom effects| CustomEffects["Apply custom effects"]
ApplyEffectsToVideo --> ExportVideoClip[Export VideoClip]
ExportVideoClip --> |Write to video file| WriteVideoFile["Write to video file"]
ExportVideoClip --> |Write subclip to video file| WriteSubclip["Write subclip to video file"]
ExportVideoClip --> |Write as image sequence| WriteImageSequence["Write as image sequence"]
ExportVideoClip --> |Save frame| SaveFrame["Save frame"]
CreateImageClip --> |Load from file| LoadImageFile["Load from file"]
CreateImageClip --> |Create from PIL image| CreateFromPIL["Create from PIL image"]
CreateImageClip --> |Create from numpy array| CreateFromNumpy["Create from numpy array"]
LoadImageFile --> ModifyImageClip[Modify ImageClip]
CreateFromPIL --> ModifyImageClip
CreateFromNumpy --> ModifyImageClip
ModifyImageClip --> |Resize| ResizeImageClip["Resize"]
ModifyImageClip --> ConvertToVideo[Convert to VideoClip and apply effects]
ResizeImageClip --> ConvertToVideo
ConvertToVideo --> |Apply effects| ApplyEffectsToVideo
ApplyEffectsToVideo --> ExportImageClip[Export ImageClip]
ExportImageClip --> WriteVideoFile
ExportImageClip --> WriteSubclip
ExportImageClip --> WriteImageSequence
ExportImageClip --> SaveFrame
CreateAudioClip --> |Load from file| LoadAudioFile["Load from file"]
CreateAudioClip --> |Create silent clip| CreateSilentClip["Create silent clip"]
LoadAudioFile --> ModifyAudioClip[Modify AudioClip]
CreateSilentClip --> ModifyAudioClip
ModifyAudioClip --> |Set FPS| SetFPS_audio["Set FPS"]
ModifyAudioClip --> |Set start/end| SetStartEnd_audio["Set start/end"]
ModifyAudioClip --> |Set audio data| SetAudioData["Set audio data"]
ModifyAudioClip --> ApplyEffectsToAudio[Apply Effects to AudioClip]
ApplyEffectsToAudio --> |Subclip| Subclip_audio["Subclip"]
ApplyEffectsToAudio --> |Apply normalize effect| NormalizeEffect["Apply normalize effect"]
ApplyEffectsToAudio --> ExportAudioClip[Export AudioClip]
ExportAudioClip --> WriteAudioFile["Write to audio file"]
WriteVideoFile --> End((End))
WriteSubclip --> End
WriteImageSequence --> End
SaveFrame --> End
WriteAudioFile --> End
click Start "#"
click ChooseClipType "#basic-concepts"
click CreateVideoClip "#creating-a-videoclip"
click LoadVideoFile "#creating-a-videoclip"
click ModifyVideoClip "#modifying-a-videoclip"
click CreateVideoFromImage "#creating-a-videoclip"
click SetDuration "#modifying-a-videoclip"
click SetFPS "#modifying-a-videoclip"
click SetStartEnd "#modifying-a-videoclip"
click SetAudio "#modifying-a-videoclip"
click ApplyEffectsToVideo "#applying-effects-to-a-videoclip"
click ResizeClip "#applying-effects-to-a-videoclip"
click CropClip "#applying-effects-to-a-videoclip"
click Subclip "#applying-effects-to-a-videoclip"
click CustomEffects "#applying-effects-to-a-videoclip"
click ExportVideoClip "#exporting-a-videoclip"
click WriteVideoFile "#exporting-a-videoclip"
click WriteSubclip "#exporting-a-videoclip"
click WriteImageSequence "#exporting-a-videoclip"
click SaveFrame "#exporting-a-videoclip"
click CreateImageClip "#creating-an-imageclip"
click LoadImageFile "#creating-an-imageclip"
click ModifyImageClip "#modifying-an-imageclip"
click CreateFromPIL "#creating-an-imageclip"
click CreateFromNumpy "#creating-an-imageclip"
click ResizeImageClip "#modifying-an-imageclip"
click ConvertToVideo "#modifying-an-imageclip"
click ApplyEffectsToVideo "#applying-effects-to-a-imageclip"
click ExportImageClip "#exporting-an-imageclip"
click WriteVideoFile "#exporting-an-imageclip"
click WriteSubclip "#exporting-an-imageclip"
click WriteImageSequence "#exporting-an-imageclip"
click SaveFrame "#exporting-an-imageclip"
click CreateAudioClip "#creating-an-audioclip"
click LoadAudioFile "#creating-an-audioclip"
click ModifyAudioClip "#modifying-an-audioclip"
click CreateSilentClip "#creating-an-audioclip"
click SetFPS_audio "#modifying-an-audioclip"
click SetStartEnd_audio "#modifying-an-audioclip"
click SetAudioData "#modifying-an-audioclip"
click ApplyEffectsToAudio "#applying-effects-to-an-audioclip"
click Subclip_audio "#applying-effects-to-an-audioclip"
click NormalizeEffect "#applying-effects-to-an-audioclip"
click ExportAudioClip "#exporting-an-audioclip"
click WriteAudioFile "#exporting-an-audioclip"
click End "#final-flowchart"