Overview
AlphaVideoClip extends VideoClip to support videos with transparency (alpha channel). Frames are loaded in BGRA format using FFmpeg.
Defined in: src/movielite/video/alpha_video_clip.py:12
Constructor
Path to the video file with alpha channel. Commonly
.mov or .webm with transparencyStart time in the composition timeline (seconds)
Duration to use from the video. If
None, uses the full video durationStart offset within the video file (seconds)
Raises
ValueError: If the file format is not supportedFileNotFoundError: If the video file doesn’t existRuntimeError: If unable to read video metadata or invalid video properties
Example
Key Differences from VideoClip
Frame Format: AlphaVideoClip loads frames in BGRA format (4 channels) instead of BGR (3 channels).Metadata Loading: Uses FFprobe instead of OpenCV for more accurate metadata extraction.Frame Reading: Uses FFmpeg pipe for frame extraction to preserve alpha channel.
Properties
AlphaVideoClip inherits all properties fromVideoClip:
fps- Frames per secondaudio- Audio track (AudioClip)size- Video dimensions (width, height)start,duration,end,speed- Timing properties
Methods
subclip
Start time within this clip (seconds)
End time within this clip (seconds)
New AlphaVideoClip instance representing the extracted portion
src/movielite/video/alpha_video_clip.py:171
close
src/movielite/video/alpha_video_clip.py:166
Inherited Methods
All methods inherited from VideoClip
All methods inherited from VideoClip
AlphaVideoClip inherits all methods from VideoClip:
set_start(start)- Set start timeset_duration(duration)- Set durationset_offset(offset)- Set source offsetset_end(end)- Set end timeset_speed(speed)- Set playback speedloop(enabled)- Enable/disable loopingset_position(value)- Set position on canvasset_opacity(value)- Set opacityset_scale(value)- Set scaleset_rotation(angle, ...)- Set rotationset_size(width, height)- Resize videoset_mask(mask)- Apply maskadd_effect(effect)- Add visual effectadd_transition(next_clip, transition)- Add transitionadd_transform(callback)- Add custom transform
VideoClip for detailed documentation of these methods.Implementation Details
Technical implementation notes
Technical implementation notes
Metadata Loading
AlphaVideoClip uses FFprobe to extract metadata (defined inalpha_video_clip.py:34):Frame Extraction
Frames are read using FFmpeg pipe (defined inalpha_video_clip.py:117):Frame Seeking
The class uses intelligent seeking:- Reopens FFmpeg pipe when seeking backwards or jumping more than 10 frames
- Sequential reading for small gaps (< 10 frames) for efficiency
- Caches the last frame to avoid redundant reads
Complete Example
Use Cases
Logo Overlays
Add transparent logos or watermarks to videos
Particle Effects
Composite transparent particle effects and animations
Green Screen
Use pre-keyed transparent video footage
UI Elements
Add transparent UI elements and graphics
Performance Considerations
Optimization Tips
- Resize before compositing: Resize alpha videos to their final size before adding effects
- Limit layer count: Too many alpha layers can slow rendering significantly
- Pre-process when possible: If the alpha video doesn’t change, consider rendering it once
See Also
VideoClip- For standard videos without transparencyImageClip- For static images (also supports alpha)VideoWriter- For rendering with transparency