bicubic ¶
Classes:
-
AdobeBicubic–Adobe's "Bicubic" interpolation preset resizer (b=0, c=0.75).
-
AdobeBicubicSharper–Adobe's "Bicubic Sharper" interpolation preset resizer (b=0, c=1, blur=1.05).
-
AdobeBicubicSmoother–Adobe's "Bicubic Smoother" interpolation preset resizer (b=0, c=0.625, blur=1.15).
-
BSpline–BSpline resizer (b=1, c=0).
-
Bicubic–Bicubic resizer.
-
BicubicAuto–Bicubic resizer that follows the rule of
b + 2c = ... -
BicubicSharp–BicubicSharp resizer (b=0, c=1).
-
Catrom–Catrom resizer (b=0, c=0.5).
-
FFmpegBicubic–FFmpeg's swscale default resizer (b=0, c=0.6).
-
Hermite–Hermite resizer (b=0, c=0).
-
Mitchell–Mitchell resizer (b=1/3, c=1/3).
-
Robidoux–Robidoux resizer (b=0.37822, c=0.31089).
-
RobidouxSharp–RobidouxSharp resizer (b=0.26201, c=0.36899).
-
RobidouxSoft–RobidouxSoft resizer (b=0.67962, c=0.16019).
AdobeBicubic ¶
Bases: Bicubic
Adobe's "Bicubic" interpolation preset resizer (b=0, c=0.75).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
162 163 164 165 166 167 168 169 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
AdobeBicubicSharper ¶
Bases: Bicubic
Adobe's "Bicubic Sharper" interpolation preset resizer (b=0, c=1, blur=1.05).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
177 178 179 180 181 182 183 184 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
AdobeBicubicSmoother ¶
Bases: Bicubic
Adobe's "Bicubic Smoother" interpolation preset resizer (b=0, c=0.625, blur=1.15).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
192 193 194 195 196 197 198 199 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
BSpline ¶
Bases: Bicubic
BSpline resizer (b=1, c=0).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
87 88 89 90 91 92 93 94 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
Bicubic ¶
Bases: ZimgComplexKernel
Bicubic resizer.
Initialize the scaler with specific 'b' and 'c' parameters and optional arguments.
Parameters:
-
(b¶float, default:0) –The 'b' parameter for bicubic interpolation.
-
(c¶float, default:0.5) –The 'c' parameter for bicubic interpolation.
-
(**kwargs¶Any, default:{}) –Keyword arguments that configure the internal scaling behavior.
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
41 42 43 44 45 46 47 48 49 50 51 52 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
BicubicAuto ¶
Bases: Bicubic
Bicubic resizer that follows the rule of b + 2c = ...
Initialize the scaler with optional arguments.
Parameters:
-
(b¶float | None, default:None) –The 'b' parameter for bicubic interpolation.
-
(c¶float | None, default:None) –The 'c' parameter for bicubic interpolation.
-
(**kwargs¶Any, default:{}) –Keyword arguments that configure the internal scaling behavior.
Raises:
-
CustomValueError–If both 'b' and 'c' are specified
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
BicubicSharp ¶
Bases: Bicubic
BicubicSharp resizer (b=0, c=1).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
207 208 209 210 211 212 213 214 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
Catrom ¶
Bases: Bicubic
Catrom resizer (b=0, c=0.5).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
132 133 134 135 136 137 138 139 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
FFmpegBicubic ¶
Bases: Bicubic
FFmpeg's swscale default resizer (b=0, c=0.6).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
147 148 149 150 151 152 153 154 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
Hermite ¶
Bases: Bicubic
Hermite resizer (b=0, c=0).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
102 103 104 105 106 107 108 109 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
Mitchell ¶
Bases: Bicubic
Mitchell resizer (b=1/3, c=1/3).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
117 118 119 120 121 122 123 124 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
Robidoux ¶
Bases: Bicubic
Robidoux resizer (b=0.37822, c=0.31089).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
239 240 241 242 243 244 245 246 247 248 249 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
RobidouxSharp ¶
Bases: Bicubic
RobidouxSharp resizer (b=0.26201, c=0.36899).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
257 258 259 260 261 262 263 264 265 266 267 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |
RobidouxSoft ¶
Bases: Bicubic
RobidouxSoft resizer (b=0.67962, c=0.16019).
Initialize the scaler with optional arguments.
Parameters:
Methods:
-
bob–Apply bob deinterlacing to a given clip using the selected resizer.
-
deinterlace–Apply deinterlacing to a given clip using the selected resizer.
-
descale–Descale a clip to the given resolution, with image borders handling and sampling grid alignment,
-
ensure_obj–Ensure that the input is a scaler instance, resolving it if necessary.
-
from_param–Resolve and return a scaler type from a given input (string, type, or instance).
-
get_bob_args–Generate the keyword arguments used for bobbing.
-
get_descale_args–Generate and normalize argument dictionary for a descale operation.
-
get_params_args–Generate a base set of parameters to pass for scaling, descaling, or resampling.
-
get_resample_args–Generate and normalize argument dictionary for a resample operation.
-
get_rescale_args–Generate and normalize argument dictionary for a rescale operation.
-
get_scale_args–Generate and normalize argument dictionary for a scale operation.
-
implemented_funcs–Returns a set of function names that are implemented in the current class and the parent classes.
-
kernel_radius–Return the effective kernel radius for the scaler.
-
resample–Resample a video clip to the given format.
-
rescale–Rescale a clip to the given resolution from a previously descaled clip,
-
scale–Scale a clip to the given resolution, with aspect ratio and linear light support.
-
shift–Apply a subpixel shift to the clip using the kernel's scaling logic.
-
supersample–Supersample a clip by a given scaling factor.
Attributes:
-
b– -
bob_function–Bob function called internally when performing bobbing operations.
-
c– -
descale_function(Callable[..., VideoNode]) –Descale function called internally when performing descaling operations.
-
kwargs(dict[str, Any]) –Arguments passed to the implemented funcs or internal scale function.
-
pretty_string(str) –Cached property returning a user-friendly string representation.
-
resample_function(Callable[..., VideoNode]) –Resample function called internally when performing resampling operations.
-
rescale_function(Callable[..., VideoNode]) –Rescale function called internally when performing upscaling operations.
-
scale_function(Callable[..., VideoNode]) –Scale function called internally when performing scaling operations.
Source code in vskernels/kernels/zimg/bicubic.py
222 223 224 225 226 227 228 229 230 231 | |
bob_function class-attribute instance-attribute ¶
bob_function = Bob
Bob function called internally when performing bobbing operations.
descale_function class-attribute instance-attribute ¶
descale_function: Callable[..., VideoNode] = Debicubic
Descale function called internally when performing descaling operations.
kwargs instance-attribute ¶
Arguments passed to the implemented funcs or internal scale function.
pretty_string property ¶
pretty_string: str
Cached property returning a user-friendly string representation.
Returns:
-
str–Pretty-printed string with arguments.
resample_function class-attribute instance-attribute ¶
resample_function: Callable[..., VideoNode] = Bicubic
Resample function called internally when performing resampling operations.
rescale_function class-attribute instance-attribute ¶
rescale_function: Callable[..., VideoNode] = Bicubic
Rescale function called internally when performing upscaling operations.
scale_function class-attribute instance-attribute ¶
scale_function: Callable[..., VideoNode] = Bicubic
Scale function called internally when performing scaling operations.
bob ¶
Apply bob deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
deinterlace ¶
deinterlace(
clip: VideoNode,
*,
tff: FieldBasedLike | bool | None = None,
double_rate: bool = True,
**kwargs: Any
) -> VideoNode
Apply deinterlacing to a given clip using the selected resizer.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(double_rate¶bool, default:True) –Whether to double the frame rate (True) or retain the original rate (False).
Returns:
-
VideoNode–The bobbed clip.
Source code in vskernels/abstract/base.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
descale ¶
descale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Descale a clip to the given resolution, with image borders handling and sampling grid alignment, optionally using linear light processing.
Supports both progressive and interlaced sources. When interlaced, it will separate fields, perform per-field descaling, and weave them back.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target descaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target descaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during descaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
descale_function.
Returns:
-
VideoNode–The descaled video node, optionally processed in linear light.
Source code in vskernels/abstract/complex.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
ensure_obj classmethod ¶
ensure_obj(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> Self
Ensure that the input is a scaler instance, resolving it if necessary.
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
-
Self–Scaler instance.
Source code in vskernels/abstract/base.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
from_param classmethod ¶
from_param(
scaler: str | type[Self] | Self | None = None,
/,
func_except: FuncExcept | None = None,
) -> type[Self]
Resolve and return a scaler type from a given input (string, type, or instance).
Parameters:
-
(scaler¶str | type[Self] | Self | None, default:None) –Scaler identifier (string, class, or instance).
-
(func_except¶FuncExcept | None, default:None) –Function returned for custom error handling.
Returns:
Source code in vskernels/abstract/base.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
get_bob_args ¶
get_bob_args(
clip: VideoNode, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any
) -> dict[str, Any]
Generate the keyword arguments used for bobbing.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left).
-
(**kwargs¶Any, default:{}) –Extra parameters to merge.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
62 63 64 65 66 67 68 69 70 | |
get_descale_args ¶
get_descale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a descale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the descale function.
Returns:
Source code in vskernels/abstract/base.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
get_params_args ¶
get_params_args(
is_descale: bool,
clip: VideoNode,
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate a base set of parameters to pass for scaling, descaling, or resampling.
Parameters:
-
(is_descale¶bool) –Whether this is for a descale operation.
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments to include.
Returns:
Source code in vskernels/kernels/zimg/bicubic.py
54 55 56 57 58 59 60 | |
get_resample_args ¶
get_resample_args(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None,
matrix_in: MatrixLike | None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a resample operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None) –Target color matrix.
-
(matrix_in¶MatrixLike | None) –Source color matrix.
-
(transfer¶TransferLike | None, default:None) –Target color transfer.
-
(transfer_in¶TransferLike | None, default:None) –Source color transfer.
-
(primaries¶PrimariesLike | None, default:None) –Target color primaries.
-
(primaries_in¶PrimariesLike | None, default:None) –Source color primaries.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the resample function.
Returns:
Source code in vskernels/abstract/base.py
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 | |
get_rescale_args ¶
get_rescale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a rescale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the rescale function.
Returns:
Source code in vskernels/abstract/base.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
get_scale_args ¶
get_scale_args(
clip: VideoNode,
shift: tuple[TopShift, LeftShift] = (0, 0),
width: int | None = None,
height: int | None = None,
**kwargs: Any
) -> dict[str, Any]
Generate and normalize argument dictionary for a scale operation.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Vertical and horizontal shift to apply.
-
(width¶int | None, default:None) –Target width.
-
(height¶int | None, default:None) –Target height.
-
(**kwargs¶Any, default:{}) –Additional arguments to pass to the scale function.
Returns:
Source code in vskernels/abstract/base.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | |
implemented_funcs classmethod ¶
Returns a set of function names that are implemented in the current class and the parent classes.
These functions determine which keyword arguments will be extracted from the __init__ method.
Returns:
Source code in vskernels/abstract/base.py
454 455 456 457 458 459 460 461 462 463 464 465 | |
kernel_radius ¶
kernel_radius() -> int
Return the effective kernel radius for the scaler.
Raises:
-
CustomNotImplementedError–If no kernel radius is defined.
Returns:
-
int–Kernel radius.
Source code in vskernels/kernels/zimg/bicubic.py
72 73 74 75 76 | |
resample ¶
resample(
clip: VideoNode,
format: int | VideoFormatLike | HoldsVideoFormat,
matrix: MatrixLike | None = None,
matrix_in: MatrixLike | None = None,
transfer: TransferLike | None = None,
transfer_in: TransferLike | None = None,
primaries: PrimariesLike | None = None,
primaries_in: PrimariesLike | None = None,
**kwargs: Any
) -> VideoNode
Resample a video clip to the given format.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(format¶int | VideoFormatLike | HoldsVideoFormat) –The target video format, which can either be:
- an integer format ID,
- a
vs.PresetVideoFormatorvs.VideoFormat, - or a source from which a valid
VideoFormatcan be extracted.
-
(matrix¶MatrixLike | None, default:None) –An optional color transformation matrix to apply.
-
(matrix_in¶MatrixLike | None, default:None) –An optional input matrix for color transformations.
-
(transfer¶TransferLike | None, default:None) –An optional color transformation transfer to apply.
-
(transfer_in¶TransferLike | None, default:None) –An optional input transfer for color transformations.
-
(primaries¶PrimariesLike | None, default:None) –Optional color transformation primaries to apply.
-
(primaries_in¶PrimariesLike | None, default:None) –Optional input primaries for color transformations.
-
(**kwargs¶Any, default:{}) –Additional keyword arguments passed to the
resample_function.
Returns:
-
VideoNode–The resampled clip.
Source code in vskernels/abstract/base.py
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 | |
rescale ¶
rescale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift, LeftShift] | FieldShift = (0, 0),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: int | BorderHandling = MIRROR,
sample_grid_model: int | SampleGridModel = MATCH_EDGES,
field_based: FieldBasedLike | None = None,
ignore_mask: VideoNode | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Rescale a clip to the given resolution from a previously descaled clip, with image borders handling and sampling grid alignment, optionally using linear light processing.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target scaled width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target scaled height (defaults to clip height if None).
-
(shift¶tuple[TopShift, LeftShift] | FieldShift, default:(0, 0)) –Subpixel shift (top, left) or per-field shifts.
-
(linear¶bool | None, default:None) –Whether to linearize the input before rescaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶int | BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶int | SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(field_based¶FieldBasedLike | None, default:None) –Field-based processing mode (interlaced or progressive).
-
(ignore_mask¶VideoNode | None, default:None) –Optional mask specifying areas to ignore during rescaling.
-
(blur¶float | None, default:None) –Amount of blur to apply during rescaling.
-
(**kwargs¶Any, default:{}) –Additional arguments passed to
rescale_function.
Returns:
-
VideoNode–The scaled clip.
Source code in vskernels/abstract/complex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
scale ¶
scale(
clip: VideoNode,
width: int | None = None,
height: int | None = None,
shift: tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]] = (
0,
0,
),
*,
linear: bool | None = None,
sigmoid: bool | tuple[Slope, Center] = False,
border_handling: BorderHandling = MIRROR,
sample_grid_model: SampleGridModel = MATCH_EDGES,
sar: Sar | float | bool | None = None,
dar: Dar | float | bool | None = None,
dar_in: Dar | bool | float | None = None,
keep_ar: bool | None = None,
blur: float | None = None,
**kwargs: Any
) -> VideoNode
Scale a clip to the given resolution, with aspect ratio and linear light support.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(width¶int | None, default:None) –Target width (defaults to clip width if None).
-
(height¶int | None, default:None) –Target height (defaults to clip height if None).
-
(shift¶tuple[TopShift | list[TopShift], LeftShift | list[LeftShift]], default:(0, 0)) –Subpixel shift (top, left) applied during scaling. If a tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
-
(linear¶bool | None, default:None) –Whether to linearize the input before descaling. If None, inferred from sigmoid.
-
(sigmoid¶bool | tuple[Slope, Center], default:False) –Whether to use sigmoid transfer curve. Can be True, False, or a tuple of (slope, center).
Trueapplies the defaults values (6.5, 0.75). Keep in mind sigmoid slope has to be in range 1.0-20.0 (inclusive) and sigmoid center has to be in range 0.0-1.0 (inclusive). -
(border_handling¶BorderHandling, default:MIRROR) –Method for handling image borders during sampling.
-
(sample_grid_model¶SampleGridModel, default:MATCH_EDGES) –Model used to align sampling grid.
-
(sar¶Sar | float | bool | None, default:None) –Sample aspect ratio to assume or convert to.
-
(dar¶Dar | float | bool | None, default:None) –Desired display aspect ratio.
-
(dar_in¶Dar | bool | float | None, default:None) –Input display aspect ratio, if different from clip's.
-
(keep_ar¶bool | None, default:None) –Whether to adjust dimensions to preserve aspect ratio.
-
(blur¶float | None, default:None) –Amount of blur to apply during scaling.
Returns:
-
VideoNode–Scaled clip, optionally aspect-corrected and linearized.
Source code in vskernels/abstract/complex.py
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 621 622 623 624 625 626 627 628 629 630 631 632 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 | |
shift ¶
shift(
clip: VideoNode,
shifts_or_top: float | tuple[float, float] | list[float],
shift_left: float | list[float] | None = None,
/,
**kwargs: Any,
) -> VideoNode
Apply a subpixel shift to the clip using the kernel's scaling logic.
If a single float or tuple is provided, it is used uniformly. If a list is given, the shift is applied per plane.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(shifts_or_top¶float | tuple[float, float] | list[float]) –Either a single vertical shift, a (top, left) tuple, or a list of vertical shifts.
-
(shift_left¶float | list[float] | None, default:None) –Horizontal shift or list of horizontal shifts. Ignored if
shifts_or_topis a tuple. -
(**kwargs¶Any, default:{}) –Additional arguments passed to the internal
scalecall.
Returns:
-
VideoNode–A new clip with the applied shift.
Raises:
-
VariableFormatError–If the input clip has variable format.
-
CustomValueError–If the input clip is GRAY but lists of shift has been passed.
Source code in vskernels/abstract/base.py
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 | |
supersample ¶
supersample(
clip: VideoNode,
rfactor: float = 2.0,
shift: tuple[TopShift, LeftShift] = (0, 0),
**kwargs: Any
) -> VideoNode
Supersample a clip by a given scaling factor.
Keyword arguments passed during initialization are automatically injected here, unless explicitly overridden by the arguments provided at call time. Only arguments that match named parameters in this method are injected.
Parameters:
-
(clip¶VideoNode) –The source clip.
-
(rfactor¶float, default:2.0) –Scaling factor for supersampling.
-
(shift¶tuple[TopShift, LeftShift], default:(0, 0)) –Subpixel shift (top, left) applied during scaling.
-
(**kwargs¶Any, default:{}) –Additional arguments forwarded to the scale function.
Raises:
-
CustomValueError–If resulting resolution is non-positive.
Returns:
-
VideoNode–The supersampled clip.
Source code in vskernels/abstract/base.py
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 | |