Effects
Effects modify video frames without changing their count or dimensions.
Usage
from videopython.base import Video, Blur, Zoom, ColorGrading, Vignette, KenBurns, BoundingBox
from videopython.base import Fade, VolumeAdjust, TextOverlay
video = Video.from_path("input.mp4")
# Apply blur effect
blur = Blur(mode="constant", iterations=50)
video = blur.apply(video, start=0, stop=2.0)
# Apply zoom effect
zoom = Zoom(zoom_factor=1.5, mode="in")
video = zoom.apply(video)
# Color grading
grading = ColorGrading(brightness=1.1, contrast=1.2, saturation=1.1, temperature=0.1)
video = grading.apply(video)
# Vignette effect
vignette = Vignette(strength=0.5, radius=0.8)
video = vignette.apply(video)
# Ken Burns pan-and-zoom (fluent API)
start_region = BoundingBox(x=0.0, y=0.0, width=0.5, height=0.5) # Top-left quarter
end_region = BoundingBox(x=0.5, y=0.5, width=0.5, height=0.5) # Bottom-right quarter
video = video.ken_burns(start_region, end_region, easing="ease_in_out")
# Fade in from black over 1 second
video = Fade(mode="in", duration=1.0).apply(video)
# Fade out to black at the end
video = Fade(mode="out", duration=0.5).apply(video)
# Adjust volume (mute first 2 seconds)
video = VolumeAdjust(volume=0.0).apply(video, start=0, stop=2.0)
# Add text overlay
video = TextOverlay(text="Hello World", position=(0.5, 0.9), font_size=48).apply(video)
Effect (Base Class)
Effect
Bases: ABC
Abstract class for effect on frames of video.
The effect must not change the number of frames and the shape of the frames.
Source code in src/videopython/base/effects.py
streaming_init
Called once before streaming begins to precompute per-frame parameters.
Override in subclasses that need precomputation (e.g., per-frame alpha arrays, sigma schedules, crop regions).
Source code in src/videopython/base/effects.py
process_frame
Process a single frame in streaming mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
ndarray
|
Single RGB frame (H, W, 3) uint8. |
required |
frame_index
|
int
|
0-based index within this effect's active range. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Processed frame, same shape and dtype. |
Source code in src/videopython/base/effects.py
apply
Apply the effect to a video, optionally within a time range.
Omit start to apply from the beginning, omit stop to apply until
the end. Prefer omitting over passing explicit values when the intent is
full-range application -- this avoids floating-point mismatches with the
actual video duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Video
|
Input video. |
required |
start
|
float | None
|
Start time in seconds. Omit to apply from the beginning. Only set when the effect should begin partway through. |
None
|
stop
|
float | None
|
Stop time in seconds. Omit to apply until the end. Only set when the effect should end before the video does. |
None
|
Source code in src/videopython/base/effects.py
AudioEffect (Base Class)
Audio-only effects that inherit from Effect for execution engine compatibility but skip frame processing entirely.
AudioEffect
Bases: Effect
Abstract base class for audio-only effects.
Inherits from Effect so isinstance checks in the execution engine pass without modification. Overrides apply() to skip frame processing.
Source code in src/videopython/base/effects.py
apply
Apply the audio effect to a video, optionally within a time range.
Omit start to apply from the beginning, omit stop to apply until
the end. Prefer omitting over passing explicit values when the intent is
full-range application -- this avoids floating-point mismatches with the
actual video duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Video
|
Input video. |
required |
start
|
float | None
|
Start time in seconds. Omit to apply from the beginning. Only set when the effect should begin partway through. |
None
|
stop
|
float | None
|
Stop time in seconds. Omit to apply until the end. Only set when the effect should end before the video does. |
None
|
Source code in src/videopython/base/effects.py
Blur
Blur
Bases: Effect
Applies Gaussian blur that can stay constant or ramp up/down over the clip.
Source code in src/videopython/base/effects.py
__init__
__init__(
mode: Literal["constant", "ascending", "descending"],
iterations: int,
kernel_size: tuple[int, int] = (5, 5),
)
Initialize blur effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['constant', 'ascending', 'descending']
|
"constant" applies uniform blur, "ascending" ramps from sharp to blurry, "descending" ramps from blurry to sharp. |
required |
iterations
|
int
|
Blur strength. Higher values produce a stronger blur (e.g. 5 for subtle, 50+ for heavy). |
required |
kernel_size
|
tuple[int, int]
|
Gaussian kernel [width, height] in pixels. Must be odd numbers. Larger kernels spread the blur wider. |
(5, 5)
|
Source code in src/videopython/base/effects.py
Zoom
Zoom
Bases: Effect
Progressively zooms into or out of the frame center over the clip duration.
Source code in src/videopython/base/effects.py
__init__
Initialize zoom effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zoom_factor
|
float
|
How far to zoom. 1.5 is a subtle push, 2.0 is moderate, 3.0+ is dramatic. Must be greater than 1. |
required |
mode
|
Literal['in', 'out']
|
"in" starts wide and pushes into the center, "out" starts tight and pulls back. |
required |
Source code in src/videopython/base/effects.py
FullImageOverlay
FullImageOverlay
Bases: Effect
Composites a full-frame image on top of every video frame.
Useful for watermarks, logos, or static graphic overlays. Supports transparency via RGBA images and an overall opacity control.
Source code in src/videopython/base/effects.py
__init__
Initialize image overlay effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlay_image
|
ndarray
|
RGB or RGBA image array. Must match the video's width and height. |
required |
alpha
|
float | None
|
Overall opacity. 0 = fully transparent, 1 = fully opaque. Defaults to 1.0. |
None
|
fade_time
|
float
|
Seconds to fade the overlay in at the start and out at the end of its time range. |
0.0
|
Source code in src/videopython/base/effects.py
ColorGrading
ColorGrading
Bases: Effect
Adjusts color properties: brightness, contrast, saturation, and temperature.
Source code in src/videopython/base/effects.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
__init__
__init__(
brightness: float = 0.0,
contrast: float = 1.0,
saturation: float = 1.0,
temperature: float = 0.0,
)
Initialize color grading effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
brightness
|
float
|
Shift brightness. -1.0 = much darker, 0 = unchanged, 1.0 = much brighter. |
0.0
|
contrast
|
float
|
Scale contrast. 0.5 = flat/washed out, 1.0 = unchanged, 2.0 = high contrast. |
1.0
|
saturation
|
float
|
Scale color intensity. 0.0 = grayscale, 1.0 = unchanged, 2.0 = vivid/oversaturated. |
1.0
|
temperature
|
float
|
Shift color temperature. -1.0 = cool/blue tint, 0 = neutral, 1.0 = warm/orange tint. |
0.0
|
Source code in src/videopython/base/effects.py
Vignette
Vignette
Bases: Effect
Darkens the edges of the frame, drawing attention to the center.
Source code in src/videopython/base/effects.py
__init__
Initialize vignette effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strength
|
float
|
Edge darkness amount. 0.0 = no darkening, 0.5 = moderate, 1.0 = fully black edges. |
0.5
|
radius
|
float
|
Size of the bright center area. Smaller values (0.5) create a tight spotlight, larger values (2.0) keep more of the frame lit. |
1.0
|
Source code in src/videopython/base/effects.py
KenBurns
KenBurns
Bases: Effect
Cinematic pan-and-zoom that smoothly animates between two crop regions.
Creates movement by transitioning from a start region to an end region over the clip. Use it to add motion to still images or to guide the viewer's eye across a scene.
Source code in src/videopython/base/effects.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
__init__
__init__(
start_region: "BoundingBox",
end_region: "BoundingBox",
easing: Literal[
"linear", "ease_in", "ease_out", "ease_in_out"
] = "linear",
)
Initialize Ken Burns effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_region
|
'BoundingBox'
|
Starting crop region as a BoundingBox with normalized 0-1 coordinates. |
required |
end_region
|
'BoundingBox'
|
Ending crop region as a BoundingBox with normalized 0-1 coordinates. |
required |
easing
|
Literal['linear', 'ease_in', 'ease_out', 'ease_in_out']
|
Animation curve. "linear" moves at constant speed, "ease_in" starts slow, "ease_out" ends slow, "ease_in_out" starts and ends slow. |
'linear'
|
Source code in src/videopython/base/effects.py
Fade
Fade
Bases: Effect
Fades video and audio to or from black.
Source code in src/videopython/base/effects.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | |
__init__
__init__(
mode: Literal["in", "out", "in_out"],
duration: float = 1.0,
curve: Literal[
"sqrt", "linear", "exponential"
] = "sqrt",
)
Initialize fade effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['in', 'out', 'in_out']
|
"in" fades from black at the start, "out" fades to black at the end, "in_out" does both. |
required |
duration
|
float
|
Length of each fade in seconds. |
1.0
|
curve
|
Literal['sqrt', 'linear', 'exponential']
|
Brightness ramp shape. "sqrt" feels perceptually even (recommended), "linear" is mathematically even, "exponential" starts slow and finishes fast. |
'sqrt'
|
Source code in src/videopython/base/effects.py
apply
Apply fade effect to video and audio.
Omit start to apply from the beginning, omit stop to apply
until the end. Prefer omitting over passing explicit values when
the intent is full-range application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video
|
Video
|
Input video. |
required |
start
|
float | None
|
Start time in seconds. Omit to apply from the beginning. Only set when the effect should begin partway through. |
None
|
stop
|
float | None
|
Stop time in seconds. Omit to apply until the end. Only set when the effect should end before the video does. |
None
|
Source code in src/videopython/base/effects.py
apply_audio
Apply fade to audio data in-place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio
|
Audio
|
Audio object to modify. |
required |
start_s
|
float
|
Start time in seconds. |
required |
stop_s
|
float
|
Stop time in seconds. |
required |
Source code in src/videopython/base/effects.py
VolumeAdjust
VolumeAdjust
Bases: AudioEffect
Changes audio volume within a time range without affecting video frames.
Source code in src/videopython/base/effects.py
__init__
Initialize volume adjustment effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
float
|
Volume multiplier. 0.0 = silence, 1.0 = original level, 2.0 = twice as loud (may clip). |
1.0
|
ramp_duration
|
float
|
Seconds to smoothly ramp volume at the start and end of the window, preventing audible clicks. |
0.0
|
Source code in src/videopython/base/effects.py
TextOverlay
TextOverlay
Bases: Effect
Draws text on video frames, with auto word-wrap and optional background box.
Source code in src/videopython/base/effects.py
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | |
__init__
__init__(
text: str,
position: tuple[float, float] = (0.5, 0.9),
font_size: int = 48,
text_color: tuple[int, int, int] = (255, 255, 255),
background_color: tuple[int, int, int, int] | None = (
0,
0,
0,
160,
),
background_padding: int = 12,
max_width: float = 0.8,
anchor: Literal[
"center",
"top_left",
"top_center",
"bottom_center",
"bottom_left",
"bottom_right",
] = "center",
font_filename: str | None = None,
)
Initialize text overlay effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The string to display. Use \n for line breaks. |
required |
position
|
tuple[float, float]
|
Where to place the text as normalized (x, y) coordinates. (0, 0) = top-left corner, (1, 1) = bottom-right corner. |
(0.5, 0.9)
|
font_size
|
int
|
Font size in pixels. |
48
|
text_color
|
tuple[int, int, int]
|
Text color as [R, G, B], each 0-255. |
(255, 255, 255)
|
background_color
|
tuple[int, int, int, int] | None
|
Background box color as [R, G, B, A] (0-255), or null to disable the background. |
(0, 0, 0, 160)
|
background_padding
|
int
|
Padding in pixels between text and background edge. |
12
|
max_width
|
float
|
Maximum text width as a fraction of frame width (0-1). Text longer than this wraps to the next line. |
0.8
|
anchor
|
Literal['center', 'top_left', 'top_center', 'bottom_center', 'bottom_left', 'bottom_right']
|
Which point of the text box sits at the position coordinate. |
'center'
|
font_filename
|
str | None
|
Path to a .ttf font file, or None for the default font. |
None
|