Merge

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
(formatting, links, phrasing)
Line 1: Line 1:
{{Template:Func3Def|Merge(clip ''clip1'', clip ''clip2'' [, float ''weight''])|MergeChroma(clip ''clip1'', clip ''clip2'' [, float ''weight''])|MergeLuma(clip ''clip1'', clip ''clip2'' [, float ''weight''])}}
+
__TOC__
  
These filters make it possible to merge pixels (or, for YUV clips only, just the luma or chroma) from one videoclip into another. There is an optional weighting, so a percentage between the two clips can be specified. Merge is present in v2.56.
+
{{FuncDefH4|Merge}}
 +
{{FuncDef
 +
|Merge(clip ''clip1'', clip ''clip2'' [, float ''weight'' ] )
 +
}}
  
''clip1'' is the clip that has the appropriate data merged INTO (based on which filter you use). In the case of MergeLuma or MergeChroma, that means that the OTHER channel (chroma or luma respectively) is completely untouched.
+
''Merge (blend) one video clip into another.''
  
''clip2'' is the one from which the pixel data must be taken. In MergeChroma, this is where the Chroma will be taken from, and vice-versa for MergeLuma. It must be the same colorspace as clip1; i.e. you cannot merge from a YV12 clip into a YUY2 clip.
+
:{{Par2|clip1|clip|(required)}}
 +
:{{Par2|clip2|clip|(required)}}
 +
::Base clip, overlay clip.  
  
The weight defines how much influence the new clip should have. Range is 0.0 to 1.0, where 0.0 is no influence and 1.0 will completely overwrite the specified channel. The default is 0.5 for Merge and 1.0 for MergeChroma and MergeLuma. The filter will be slightly slower when a weight other than 0.0, 0.5 or 1.0 is specified.
+
:{{Par2|weight|float|0.5}}
 +
::Strength of effect. Range is 0.0–1.0.
 +
::*At 0.0, {{FuncArg|clip2}} has no influence on the output.
 +
::*At 1.0, {{FuncArg|clip2}} replaces {{FuncArg|clip1}} completely.
 +
::*Default is 0.5; output is average of {{FuncArg|clip1}} and {{FuncArg|clip2}}.
  
The audio, framerate and framecount are taken from the first clip.
+
*Clips must be in the same [[Convert|colorspace]].
 +
*Audio, [[Clip_properties|FrameRate]] and [[Clip_properties|FrameCount]] are taken from the first clip.  
  
Nb, prior to v2.60 there was no ''weight'' argument for MergeChroma and MergeLuma: you needed to use ''ChromaWeight'' for MergeChroma() and ''LumaWeight'' for MergeLuma(). Since v2.60 you can also use the ''weight'' argument.
 
  
'''Examples:'''
+
{{FuncDefH4|MergeChroma}}
 +
{{Func2Def
 +
|MergeChroma(clip ''clip1'', clip ''clip2'' [, float ''chromaweight'' ] )
 +
|MergeChroma(clip ''clip1'', clip ''clip2'' [, float ''weight'' ] ) (*v2.60 only)
 +
}}
  
# Will only blur the Luma channel.
+
''Merge ''chroma'' from one video clip into another.''
mpeg2source("c:\apps\avisynth\main.d2v")
+
lumvid = [[Blur]](1.0)
+
MergeLuma(lumvid)
+
  
  # This will do a Spatial Smooth on the Chroma channel
+
:{{Par2|clip1|clip|(required)}}
 +
:{{Par2|clip2|clip|(required)}}
 +
::Base clip, chroma overlay clip.
 +
 
 +
:{{Par2|chromaweight|float|1.0}}
 +
:{{Par2|weight|float|1.0}}
 +
::Strength of effect. Range is 0.0–1.0.
 +
::*At 0.0, {{FuncArg|clip2}} has no influence on the output.
 +
::*At 1.0, {{FuncArg|clip2}} replaces {{FuncArg|clip1}} chroma completely.
 +
::*Default is 1.0; output chroma taken only from {{FuncArg|clip2}}.
 +
::*Alternate name ''weight'' added in AviSynth v2.60
 +
 
 +
*Clips must be in the same [[Convert|colorspace]] and [[YUV]] only.
 +
*Audio, [[Clip_properties|FrameRate]] and [[Clip_properties|FrameCount]] are taken from the first clip.
 +
 
 +
 
 +
{{FuncDefH4|MergeLuma}}
 +
{{Func2Def
 +
|MergeLuma(clip ''clip1'', clip ''clip2'' [, float ''lumaweight'' ] )
 +
|MergeLuma(clip ''clip1'', clip ''clip2'' [, float ''weight'' ] ) (*v2.60 only)
 +
}}
 +
 
 +
''Merge ''luma'' from one video clip into another.''
 +
 
 +
:{{Par2|clip1|clip|(required)}}
 +
:{{Par2|clip2|clip|(required)}}
 +
::Base clip, luma overlay clip.
 +
 
 +
:{{Par2|lumaweight|float|1.0}}
 +
:{{Par2|weight|float|1.0}}
 +
::Strength of effect. Range is 0.0–1.0.
 +
::*At 0.0, {{FuncArg|clip2}} has no influence on the output.
 +
::*At 1.0, {{FuncArg|clip2}} replaces {{FuncArg|clip1}} luma completely.
 +
::*Default is 1.0; output luma taken only from {{FuncArg|clip2}}.
 +
::*Alternate name ''weight'' added in AviSynth v2.60
 +
 
 +
*Clips must be in the same [[Convert|colorspace]] and [[YUV]] only.
 +
*Audio, [[Clip_properties|FrameRate]] and [[Clip_properties|FrameCount]] are taken from the first clip.
 +
 
 +
 
 +
== Examples ==
 +
<div {{BoxWidthIndent|56|2}} >
 +
  # Blur the Luma channel.
 +
[[DGDecode/MPEG2Source|MPEG2Source]]("main.d2v")
 +
clipY = [[Blur]](1.0)
 +
MergeLuma(clipY )
 +
</div>
 +
 
 +
<div {{BoxWidthIndent|56|2}} >
 +
# Do a spatial smooth on the chroma channel
 
  # that will be mixed 50/50 with the original image.
 
  # that will be mixed 50/50 with the original image.
  mpeg2source("c:\apps\avisynth\main.d2v")
+
  MPEG2Source("main.d2v")
  chromavid = SpatialSmoother(2,3)  
+
  clipC = [[SpatialSoften]](2,3)  
  MergeChroma(chromavid,0.5)
+
  MergeChroma(clipC , 0.5)
 +
</div>
  
  # This will run a temporalsmoother and a soft spatial
+
<div {{BoxWidthIndent|56|2}} >
  # smoother on the Luma channel, and a more agressive
+
  # Run a temporal smoother and a soft spatial
  # spatial smoother on the Chroma channel.
+
  # smoother on the luma channel, and a more aggressive
 +
  # spatial smoother on the chroma channel.
 
  # The original luma channel is then added with the
 
  # The original luma channel is then added with the
 
  # smoothed version at 75%. The chroma channel is
 
  # smoothed version at 75%. The chroma channel is
 
  # fully replaced with the blurred version.
 
  # fully replaced with the blurred version.
  mpeg2source("c:\apps\avisynth\main.d2v")
+
  MPEG2Source("main.d2v")
  luma = TemporalSmoother(2,3)
+
  clipY = [[TemporalSoften]](2,3)
  luma = luma.Spatialsmoother(3,10,10)
+
  \      .SpatialSoften(3,10,10)
  chroma = Spatialsmoother(3,40,40)
+
  clipC = SpatialSoften(3,40,40)
  MergeLuma(luma,0.75)
+
  MergeLuma(clipY, 0.75)
  MergeChroma(chroma)
+
  MergeChroma(clipC)
 +
</div>
  
  # This will average two video sources.
+
<div {{BoxWidthIndent|56|2}} >
  [[AviSource]]("c:\apps\avisynth\main.avi")
+
  # Average two video sources.
  vid2 = AviSource("c:\apps\avisynth\main2.avi")
+
  vid1 = [[AviSource]]("main.avi")
  Merge(vid2)
+
  vid2 = AviSource("main2.avi")
 +
  Merge(vid1, vid2)
 +
</div>
  
'''Changelog:'''
+
== Changelog ==
 
{| border="1"
 
{| border="1"
 
|-  
 
|-  
 
| v2.60
 
| v2.60
| Added alias "Weight" for "ChromaWeight" and "LumaWeight".
+
| Added alias ''weight'' for ''chromaweight'' and ''lumaweight''.
 
|-  
 
|-  
 
| v2.56
 
| v2.56
| Added Merge.
+
| Added ''Merge''.
 
|}
 
|}
  
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 +
[[Category:Layering]]
 +
[[Category:Levels_and_Chroma_filters]]

Revision as of 04:49, 24 January 2016

Contents


Merge

Merge(clip clip1, clip clip2 [, float weight ] )

Merge (blend) one video clip into another.

clip  clip1 = (required)
clip  clip2 = (required)
Base clip, overlay clip.
float  weight = 0.5
Strength of effect. Range is 0.0–1.0.
  • At 0.0, clip2 has no influence on the output.
  • At 1.0, clip2 replaces clip1 completely.
  • Default is 0.5; output is average of clip1 and clip2.


MergeChroma

MergeChroma(clip clip1, clip clip2 [, float chromaweight ] )
MergeChroma(clip clip1, clip clip2 [, float weight ] ) (*v2.60 only)

Merge chroma from one video clip into another.

clip  clip1 = (required)
clip  clip2 = (required)
Base clip, chroma overlay clip.
float  chromaweight = 1.0
float  weight = 1.0
Strength of effect. Range is 0.0–1.0.
  • At 0.0, clip2 has no influence on the output.
  • At 1.0, clip2 replaces clip1 chroma completely.
  • Default is 1.0; output chroma taken only from clip2.
  • Alternate name weight added in AviSynth v2.60


MergeLuma

MergeLuma(clip clip1, clip clip2 [, float lumaweight ] )
MergeLuma(clip clip1, clip clip2 [, float weight ] ) (*v2.60 only)

Merge luma from one video clip into another.

clip  clip1 = (required)
clip  clip2 = (required)
Base clip, luma overlay clip.
float  lumaweight = 1.0
float  weight = 1.0
Strength of effect. Range is 0.0–1.0.
  • At 0.0, clip2 has no influence on the output.
  • At 1.0, clip2 replaces clip1 luma completely.
  • Default is 1.0; output luma taken only from clip2.
  • Alternate name weight added in AviSynth v2.60


Examples

# Blur the Luma channel.
MPEG2Source("main.d2v")
clipY = Blur(1.0)
MergeLuma(clipY )
# Do a spatial smooth on the  chroma channel
# that will be mixed 50/50 with the original image.
MPEG2Source("main.d2v")
clipC = SpatialSoften(2,3) 
MergeChroma(clipC , 0.5)
# Run a temporal smoother and a soft spatial
# smoother on the luma channel, and a more aggressive
# spatial smoother on the chroma channel.
# The original luma channel is then added with the
# smoothed version at 75%. The chroma channel is
# fully replaced with the blurred version.
MPEG2Source("main.d2v")
clipY = TemporalSoften(2,3)
\       .SpatialSoften(3,10,10)
clipC = SpatialSoften(3,40,40)
MergeLuma(clipY, 0.75)
MergeChroma(clipC)
# Average two video sources.
vid1 = AviSource("main.avi")
vid2 = AviSource("main2.avi")
Merge(vid1, vid2)

Changelog

v2.60 Added alias weight for chromaweight and lumaweight.
v2.56 Added Merge.
Personal tools