qtgmc ¶
Classes:
-
QTempGaussMC–Quick Temporal Gaussian Motion Compensated (QTGMC)
QTGMCArgs ¶
Namespace containing helper TypedDict definitions for various argument groups.
Classes:
-
Blur–Arguments available when passing to MVTools.flow_blur.
-
Compensate–Arguments available when passing to MVTools.compensate.
-
Degrain–Arguments available when passing to the internal
binomial_degrainmethod, -
Mask–Arguments available when passing to MVTools.mask.
-
MaskShimmer–Arguments available when passing to the internal
_mask_shimmermethod through -
PrefilterToFullRange–Arguments available when passing to prefilter_to_full_range.
Blur ¶
Compensate ¶
Degrain ¶
Bases: TypedDict
Arguments available when passing to the internal binomial_degrain method, calling MVTools.degrain through QTempGaussMC.basic and QTempGaussMC.source_match or directly calling MVTools.degrain through QTempGaussMC.final
Attributes:
Mask ¶
MaskShimmer ¶
Bases: TypedDict
Arguments available when passing to the internal _mask_shimmer method through QTempGaussMC.prefilter, QTempGaussMC.basic and QTempGaussMC.final.
Attributes:
-
erosion_distance(int) –How much to deflate then reflate to remove thin areas.
-
over_dilation(int) –Extra inflation to ensure areas to restore back are fully caught.
QTempGaussMC ¶
QTempGaussMC(
clip: VideoNode,
input_type: InputType = INTERLACE,
tff: FieldBasedLike | bool | None = None,
**kwargs: Any
)
Bases: VSObject
Quick Temporal Gaussian Motion Compensated (QTGMC)
A very high quality deinterlacer with a range of features for both quality and convenience. These include extensive noise processing capabilities, support for repair of progressive material, precision source matching, shutter speed simulation, etc.
Originally based on TempGaussMC by Didée.
Basic usage
deinterlace = QTempGaussMC(clip).deinterlace()
Refer to the AviSynth QTGMC documentation and the havsfunc implementation for detailed explanations of the underlying algorithm.
These resources remain relevant, as the core algorithm used here is largely similar.
Note that parameter names differ in this implementation due to a complete rewrite. A mapping between vsjetpack and havsfunc parameters is available here.
Examples:
- ...
- Passing a progressive input to reduce shimmering (equivalent to
InputType=2, ProgSADMask=12):Or:clip = ( QTempGaussMC(clip, QTempGaussMC.InputType.REPAIR) .basic(mask_args={"ml": 12}) .deinterlace() )clip = QTempGaussMC(clip, QTempGaussMC.InputType.REPAIR, basic_mask_args={"ml": 12}).deinterlace()
Parameters:
-
(clip¶VideoNode) –Clip to process.
-
(input_type¶InputType, default:INTERLACE) –Indicates processing routine.
-
(tff¶FieldBasedLike | bool | None, default:None) –Field order of the clip.
-
(**kwargs¶Any, default:{}) –Additional arguments to be passed to the parameter stage methods. Use the method's name as prefix to pass an argument to the respective method.
Example for passing tr=1 to the prefilter stage:
prefilter_tr=1.
Classes:
-
BackBlendMode–When to back blend (blurred) difference between pre & post sharpened clip.
-
InputType–Processing routine to use for the input.
-
LosslessMode–When to put exact source fields into result & clean any artifacts.
-
NoiseDeintMode–When noise is taken from interlaced source, how to 'deinterlace' it before restoring.
-
NoiseProcessMode–How to handle processing noise in the source.
-
SearchPostProcess–Prefiltering to apply in order to assist with motion search.
-
SharpenLimitMode–How to limit and when to apply re-sharpening of the clip.
-
SharpenMode–How to re-sharpen the clip after temporal smoothing.
-
SourceMatchMode–Creates higher fidelity output with extra processing.
Methods:
-
analyze–Configure parameters for the motion analysis stage.
-
back_blend–Configure parameters for the back_blend stage.
-
basic–Configure parameters for the basic stage.
-
deinterlace–Start the deinterlacing process.
-
denoise–Configure parameters for the denoise stage.
-
final–Configure parameters for the final stage.
-
lossless–Configure parameter for the lossless stage.
-
motion_blur–Configure parameters for the motion blur stage.
-
prefilter–Configure parameters for the prefilter stage.
-
sharpen–Configure parameters for the sharpen stage.
-
sharpen_limit–Configure parameters for the sharpen_limit stage.
-
source_match–Configure parameters for the source_match stage.
Attributes:
-
basic_output(VideoNode) –Output of the basic stage.
-
bobbed(VideoNode) –High quality bobbed clip, initial spatial interpolation.
-
clip(VideoNode) –Clip to process.
-
denoise_output(VideoNode) –Output of the denoise stage.
-
draft(VideoNode) –Draft processed clip, used as a base for prefiltering & denoising.
-
final_output(VideoNode) –Output of the final stage.
-
input(VideoNode) –Prepared input clip for high quality interpolation.
-
input_type– -
motion_blur_output(VideoNode) –Output of the motion blur stage.
-
noise(VideoNode) –Extracted noise when noise processing is enabled.
-
prefilter_output(VideoNode) –Output of the prefilter stage.
-
sharpen_limit_radius(int) – -
sharpen_mode(SharpenMode) – -
sharpen_strength(float) – -
source_match_bobber(Bobber) – -
tff–
Source code in vsdeinterlace/qtgmc.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
bobbed instance-attribute ¶
bobbed: VideoNode
High quality bobbed clip, initial spatial interpolation.
draft instance-attribute ¶
draft: VideoNode
Draft processed clip, used as a base for prefiltering & denoising.
motion_blur_output instance-attribute ¶
motion_blur_output: VideoNode
Output of the motion blur stage.
BackBlendMode ¶
Bases: CustomIntEnum
When to back blend (blurred) difference between pre & post sharpened clip.
Attributes:
-
BOTH–Perform back-blending both before and after sharpness limiting.
-
POSTLIMIT–Perform back-blending after sharpness limiting.
-
PRELIMIT–Perform back-blending prior to sharpness limiting.
BOTH class-attribute instance-attribute ¶
BOTH = 2
Perform back-blending both before and after sharpness limiting.
POSTLIMIT class-attribute instance-attribute ¶
POSTLIMIT = 1
Perform back-blending after sharpness limiting.
PRELIMIT class-attribute instance-attribute ¶
PRELIMIT = 0
Perform back-blending prior to sharpness limiting.
InputType ¶
Bases: CustomIntEnum
Processing routine to use for the input.
Attributes:
-
INTERLACE–Deinterlace interlaced input.
-
PROGRESSIVE–Deshimmer general progressive material that contains less severe problems.
-
REPAIR–Repair badly deinterlaced material with considerable horizontal artifacts.
LosslessMode ¶
Bases: CustomIntEnum
When to put exact source fields into result & clean any artifacts.
Attributes:
-
NONE–Do not restore source fields.
-
POSTSMOOTH–Restore source fields after final temporal smooth. True lossless but less stable.
-
PRESHARPEN–Restore source fields prior to re-sharpening. Not exactly lossless.
NoiseDeintMode ¶
Bases: CustomIntEnum
When noise is taken from interlaced source, how to 'deinterlace' it before restoring.
Attributes:
NoiseProcessMode ¶
Bases: CustomIntEnum
How to handle processing noise in the source.
Attributes:
SearchPostProcess ¶
Bases: CustomIntEnum
Prefiltering to apply in order to assist with motion search.
Attributes:
-
GAUSSBLUR–Gaussian blur.
-
GAUSSBLUR_EDGESOFTEN–Gaussian blur & edge softening.
SharpenLimitMode ¶
Bases: CustomIntEnum
How to limit and when to apply re-sharpening of the clip.
Attributes:
-
SPATIAL_POSTSMOOTH–Spatial sharpness limiting after the final stage.
-
SPATIAL_PRESMOOTH–Spatial sharpness limiting prior to final stage.
-
TEMPORAL_POSTSMOOTH–Temporal sharpness limiting after the final stage.
-
TEMPORAL_PRESMOOTH–Temporal sharpness limiting prior to final stage.
SPATIAL_POSTSMOOTH class-attribute instance-attribute ¶
SPATIAL_POSTSMOOTH = 2
Spatial sharpness limiting after the final stage.
SPATIAL_PRESMOOTH class-attribute instance-attribute ¶
SPATIAL_PRESMOOTH = 0
Spatial sharpness limiting prior to final stage.
TEMPORAL_POSTSMOOTH class-attribute instance-attribute ¶
TEMPORAL_POSTSMOOTH = 3
Temporal sharpness limiting after the final stage.
TEMPORAL_PRESMOOTH class-attribute instance-attribute ¶
TEMPORAL_PRESMOOTH = 1
Temporal sharpness limiting prior to final stage.
SharpenMode ¶
Bases: CustomIntEnum
How to re-sharpen the clip after temporal smoothing.
Attributes:
-
UNSHARP–Re-sharpening using unsharpening.
-
UNSHARP_MINMAX–Re-sharpening using unsharpening clamped to the local 3x3 min/max average.
SourceMatchMode ¶
Bases: CustomIntEnum
Creates higher fidelity output with extra processing. Will capture more source detail and reduce oversharpening / haloing.
Attributes:
-
BASIC–Conservative halfway stage that rarely introduces artifacts.
-
NONE–No source match processing.
-
REFINED–Restores almost exact source detail but is sensitive to noise & can introduce occasional aliasing.
-
TWICE_REFINED–Restores almost exact source detail.
BASIC class-attribute instance-attribute ¶
BASIC = 1
Conservative halfway stage that rarely introduces artifacts.
REFINED class-attribute instance-attribute ¶
REFINED = 2
Restores almost exact source detail but is sensitive to noise & can introduce occasional aliasing.
TWICE_REFINED class-attribute instance-attribute ¶
TWICE_REFINED = 3
Restores almost exact source detail.
analyze ¶
analyze(
*,
force_tr: int = 0,
preset: Mapping[str, Any] = HQ_SAD,
blksize: int | tuple[int, int] = 16,
overlap: int | tuple[int, int] = 2,
refine: int = 1,
thsad_recalc: int | None = None,
thscd: int | tuple[int | None, float | None] | None = (180, 38.5)
) -> Self
Configure parameters for the motion analysis stage.
Parameters:
-
(force_tr¶int, default:0) –Always analyze motion to at least this, even if otherwise unnecessary.
-
(preset¶Mapping[str, Any], default:HQ_SAD) –MVTools preset defining base values for the MVTools object.
-
(blksize¶int | tuple[int, int], default:16) –Size of a block. Larger blocks are less sensitive to noise, are faster, but also less accurate.
-
(overlap¶int | tuple[int, int], default:2) –The blksize divisor for block overlap. Larger overlapping reduces blocking artifacts.
-
(refine¶int, default:1) –Number of times to recalculate motion vectors with halved block size.
-
(thsad_recalc¶int | None, default:None) –Only bad quality new vectors with a SAD above this will be re-estimated by search. thsad value is scaled to 8x8 block size.
-
(thscd¶int | tuple[int | None, float | None] | None, default:(180, 38.5)) –Scene change detection thresholds:
- First value: SAD threshold for considering a block changed between frames.
- Second value: Percentage of changed blocks needed to trigger a scene change.
Source code in vsdeinterlace/qtgmc.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
back_blend ¶
Configure parameters for the back_blend stage.
Parameters:
-
(mode¶BackBlendMode, default:PRELIMIT) –Specifies at which stage to perform back-blending.
-
(sigma¶float, default:1.4) –Gaussian blur sigma.
Source code in vsdeinterlace/qtgmc.py
686 687 688 689 690 691 692 693 694 695 696 697 698 | |
basic ¶
basic(
*,
tr: int = 2,
thsad: int | tuple[int, int] = 640,
bobber: BobberLike = NNEDI3(nsize=1),
noise_restore: float = 0,
degrain_args: Degrain | None = None,
mask_args: Mask | None = {"ml": 10},
mask_shimmer_args: MaskShimmer | None = {"erosion_distance": 0}
) -> Self
Configure parameters for the basic stage.
Parameters:
-
(tr¶int, default:2) –Temporal radius of the motion compensated binomial smooth.
-
(thsad¶int | tuple[int, int], default:640) –Thsad of the motion compensated binomial smooth.
-
(bobber¶BobberLike, default:NNEDI3(nsize=1)) –Bobber to use for initial spatial interpolation.
-
(noise_restore¶float, default:0) –How much noise to restore after this stage.
-
(degrain_args¶Degrain | None, default:None) –Arguments passed to the binomial_degrain call.
-
(mask_args¶Mask | None, default:{'ml': 10}) –Arguments passed to MVTools.mask for InputType.REPAIR.
-
(mask_shimmer_args¶MaskShimmer | None, default:{'erosion_distance': 0}) –Arguments passed to the mask_shimmer call:
- erosion_distance: How much to deflate then reflate to remove thin areas. Default is 0 for this stage.
- over_dilation: Extra inflation to ensure areas to restore back are fully caught. Default is 0.
Source code in vsdeinterlace/qtgmc.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
deinterlace ¶
deinterlace() -> VideoNode
Start the deinterlacing process.
Returns:
-
VideoNode–Deinterlaced clip.
Source code in vsdeinterlace/qtgmc.py
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | |
denoise ¶
denoise(
*,
tr: int = 1,
func: DFTTest | _DenoiseFuncTr = DFTTest(sigma=8),
mode: NoiseProcessMode = IDENTIFY,
deint: NoiseDeintMode = GENERATE,
mc_denoise: bool = True,
stabilize: tuple[float, float] | Literal[False] = (0.6, 0.2),
func_comp_args: Compensate | None = None,
stabilize_comp_args: Compensate | None = None
) -> Self
Configure parameters for the denoise stage.
Parameters:
-
(tr¶int, default:1) –Temporal radius of the denoising function & it's motion compensation.
-
(func¶DFTTest | _DenoiseFuncTr, default:DFTTest(sigma=8)) –Denoising function to use.
-
(mode¶NoiseProcessMode, default:IDENTIFY) –Noise handling method to use.
-
(deint¶NoiseDeintMode, default:GENERATE) –Noise deinterlacing method to use.
-
(mc_denoise¶bool, default:True) –Whether to perform motion-compensated denoising.
-
(stabilize¶tuple[float, float] | Literal[False], default:(0.6, 0.2)) –Weights to use when blending source noise with compensated noise.
-
(func_comp_args¶Compensate | None, default:None) –Arguments passed to MVTools.compensate for denoising.
-
(stabilize_comp_args¶Compensate | None, default:None) –Arguments passed to MVTools.compensate for stabilization.
Source code in vsdeinterlace/qtgmc.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
final ¶
final(
*,
tr: int = 1,
thsad: int | tuple[int, int] = 256,
noise_restore: float = 0,
degrain_args: Degrain | None = None,
mask_shimmer_args: MaskShimmer | None = {"erosion_distance": 4}
) -> Self
Configure parameters for the final stage.
Parameters:
-
(tr¶int, default:1) –Temporal radius of the motion compensated smooth.
-
(thsad¶int | tuple[int, int], default:256) –Thsad of the motion compensated smooth.
-
(noise_restore¶float, default:0) –How much noise to restore after this stage.
-
(degrain_args¶Degrain | None, default:None) –Arguments passed to MVTools.degrain.
-
(mask_shimmer_args¶MaskShimmer | None, default:{'erosion_distance': 4}) –Arguments passed to the mask_shimmer call:
- erosion_distance: How much to deflate then reflate to remove thin areas. Default is 4 for this stage.
- over_dilation: Extra inflation to ensure areas to restore back are fully caught. Default is 0.
Source code in vsdeinterlace/qtgmc.py
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 | |
lossless ¶
Configure parameter for the lossless stage.
Parameters:
-
(mode¶LosslessMode, default:NONE) –Specifies at which stage to re-weave the original fields.
-
(anti_comb¶bool, default:True) –Whether to apply combing reduction post-processing.
Source code in vsdeinterlace/qtgmc.py
620 621 622 623 624 625 626 627 628 629 630 631 632 | |
motion_blur ¶
motion_blur(
*,
shutter_angle: tuple[float, float] = (180, 180),
fps_divisor: int = 1,
blur_args: Blur | None = None,
mask_args: Mask | None = {"ml": 4}
) -> Self
Configure parameters for the motion blur stage.
Parameters:
-
(shutter_angle¶tuple[float, float], default:(180, 180)) –Tuple containing the source and output shutter angle. Will apply motion blur if they do not match.
-
(fps_divisor¶int, default:1) –Factor by which to reduce framerate.
-
(blur_args¶Blur | None, default:None) –Arguments passed to MVTools.flow_blur.
-
(mask_args¶Mask | None, default:{'ml': 4}) –Arguments passed to MVTools.mask.
Source code in vsdeinterlace/qtgmc.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | |
prefilter ¶
prefilter(
*,
tr: int = 2,
sc_threshold: float = 0.1,
postprocess: SearchPostProcess = GAUSSBLUR_EDGESOFTEN,
strength: tuple[float, float] | Literal[False] = (1.9, 0.1),
limit: tuple[float, float, float] = (3, 7, 2),
bias: float = 0.51,
range_expansion_args: PrefilterToFullRange | None = None,
mask_shimmer_args: MaskShimmer | None = {"erosion_distance": 4}
) -> Self
Configure parameters for the prefilter stage.
Parameters:
-
(tr¶int, default:2) –Radius of the initial temporal binomial smooth.
-
(sc_threshold¶float, default:0.1) –Threshold for scene changes, disables sc detection if False.
-
(postprocess¶SearchPostProcess, default:GAUSSBLUR_EDGESOFTEN) –Post-processing routine to use.
-
(strength¶tuple[float, float] | Literal[False], default:(1.9, 0.1)) –Tuple containing gaussian blur sigma & blend weight of the blur.
-
(limit¶tuple[float, float, float], default:(3, 7, 2)) –3-step limiting (8-bit) thresholds for the gaussian blur post-processing. Only for SearchPostProcess.GAUSSBLUR_EDGESOFTEN.
-
(bias¶float, default:0.51) –Bias for blending the gaussian blurred clip with the limited output. Only for SearchPostProcess.GAUSSBLUR_EDGESOFTEN.
-
(range_expansion_args¶PrefilterToFullRange | None, default:None) –Arguments passed to prefilter_to_full_range.
-
(mask_shimmer_args¶MaskShimmer | None, default:{'erosion_distance': 4}) –Arguments passed to the mask_shimmer call:
- erosion_distance: How much to deflate then reflate to remove thin areas. Default is 4 for this stage.
- over_dilation: Extra inflation to ensure areas to restore back are fully caught. Default is 0.
Source code in vsdeinterlace/qtgmc.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
sharpen ¶
sharpen(
*,
mode: SharpenMode | None = None,
strength: float | None = None,
clamp: float | tuple[float, float] = 1,
thin: float = 0
) -> Self
Configure parameters for the sharpen stage.
Parameters:
-
(mode¶SharpenMode | None, default:None) –Specifies the type of sharpening to use. Defaults to SharpenMode.UNSHARP for InputType.PROGRESSIVE or SharpenMode.UNSHARP_MINMAX otherwise.
-
(strength¶float | None, default:None) –Sharpening strength. Defaults to 1 for SourceMatchMode.NONE or 0 otherwise.
-
(clamp¶float | tuple[float, float], default:1) –Clamp the sharpening strength of SharpenMode.UNSHARP_MINMAX to the min/max average plus/minus this.
-
(thin¶float, default:0) –How much to vertically thin edges.
Source code in vsdeinterlace/qtgmc.py
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 | |
sharpen_limit ¶
sharpen_limit(
*,
mode: SharpenLimitMode = TEMPORAL_PRESMOOTH,
radius: int | None = None,
clamp: float | tuple[float, float] = 0,
comp_args: Compensate | None = None
) -> Self
Configure parameters for the sharpen_limit stage.
Parameters:
-
(mode¶SharpenLimitMode, default:TEMPORAL_PRESMOOTH) –Specifies type of limiting & at which stage to perform it.
-
(radius¶int | None, default:None) –Radius of sharpness limiting. Defaults to 1 for SourceMatchMode.NONE or 0 otherwise.
-
(clamp¶float | tuple[float, float], default:0) –How much undershoot/overshoot to allow.
-
(comp_args¶Compensate | None, default:None) –Arguments passed to MVTools.compensate for temporal limiting.
Source code in vsdeinterlace/qtgmc.py
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 | |
source_match ¶
source_match(
*,
tr: int = 1,
bobber: BobberLike | None = None,
mode: SourceMatchMode = NONE,
similarity: float = 0.5,
enhance: float = 0.5,
degrain_args: Degrain | None = None
) -> Self
Configure parameters for the source_match stage.
Parameters:
-
(tr¶int, default:1) –Temporal radius of the refinement motion compensated binomial smooth.
-
(bobber¶BobberLike | None, default:None) –Bobber to use for refined spatial interpolation. Defaults to the basic bobber.
-
(mode¶SourceMatchMode, default:NONE) –Specifies number of refinement steps to perform.
-
(similarity¶float, default:0.5) –Temporal similarity of the error created by smoothing.
-
(enhance¶float, default:0.5) –Sharpening strength prior to source match refinement.
-
(degrain_args¶Degrain | None, default:None) –Arguments passed to the binomial_degrain call.
Source code in vsdeinterlace/qtgmc.py
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 | |