Letterbox

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
(add link to avs+ documentation)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:FuncDef|Letterbox(clip ''clip'', int ''top'', int ''bottom'' [, int ''x1''] [, int ''x2''] [, int ''color''])}}
+
<div style="max-width:54em" >
 +
<div {{BlueBox2|40|0|3px solid purple}} >
 +
{{AvsPlusFullname}}<br>
 +
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/letterbox.html https://avisynthplus.readthedocs.io]
 +
</div>
  
Letterbox simply blocks out the upper ''top'' and lower ''bottom'' scanlines of each frame, and / or optionally blocking out the left (x1) and right (x2) portions for HDTV letterboxing, and using black by default or specifying an optional color. This has a couple of uses: one, it can eliminate stray video noise from the existing black bands in an image that's already letterboxed; two, it can eliminate the garbage lines that often appear at the bottom of the frame in captures from VHS tape.
 
  
The functionality of Letterbox can be duplicated with a combination of [[Crop]] and [[AddBorders]], but Letterbox is faster and easier.  
+
Fills the top and bottom ''rows'' of each frame, and optionally the left and right ''columns'', with black or color. This has several common uses:
 +
* Black out video noise from the existing black bands in an image that's already letterboxed
 +
* Black out the video noise at the bottom of the frame in [[Wikipedia:VHS|VHS]] tape sources.
 +
* Black out [[Wikipedia:Overscan#Overscan_amounts|overscan]] areas in [[Wikipedia:Video_CD|VCD]] or [[Wikipedia:Super_Video_CD|SVCD]] sources.
 +
* Create a quick rectangular [[Mask|mask]] for other filters &ndash; a so-called "[[Wikipedia:Matte_(filmmaking)#Garbage_matte|garbage matte]]"
 +
See also: [[AddBorders]], which increases frame size. '''Letterbox''' does not change frame size.
  
Generally, it's better to crop this stuff off using Crop or [[CropBottom]] than to hide it with Letterbox. However, in some cases, particularly if you're compressing to MPEG, it's better to use Letterbox because it lets you keep a standard frame size like 352x288 or 320x240. Some MPEG players get confused when the source video has a strange frame size.  
+
The functionality of '''Letterbox''' can be duplicated with a combination of [[Crop]] and [[AddBorders]], but '''Letterbox''' is faster and easier.  
  
The color parameter is optional, default=0 <black>, and is specified as an RGB value regardless of whether the clip format is RGB or YUV based. See [[Colors]] for more information on specifying colors.
+
Generally, it's better to '''Crop''' video noise off than to black it out; many older lossy compression algorithms don't deal well with solid-color borders, unless the border happens to fall on a [[Wikipedia:Macroblock|macroblock]] boundary (16 pixels for MPEG). However, in some cases, particularly for certain hardware players, it's better to use '''Letterbox''' because it lets you keep a standard frame size.
  
Another use could also be to clear out overscan areas in VCD or SVCD encodings.  
+
{{AvsPluscon}} also supports [[RGB64]], [[PlanarRGBA]] and [[YUVA]].
 +
</div>
  
'''Changes:'''
+
 
 +
== Syntax and Parameters ==
 +
{{FuncDef
 +
|Letterbox(clip ''clip'', int ''top'', int ''bottom'' [, int ''x1'' , int ''x2'' , int ''color'' ] [, int ''color_yuv'' {{AvsPluscon}}])
 +
}}
 +
 
 +
:{{Par2|top, bottom|int|(required)}}
 +
::Number of {{FuncArg|top}} and {{FuncArg|bottom}} rows to blank out.
 +
::*For [[YV12]] sources, {{FuncArg|top}} and {{FuncArg|bottom}} must be [[Modulo|mod2]] (divisible by 2).
 +
 
 +
:{{Par2|x1, x2|int|0}}
 +
::Number of ''left'' ({{FuncArg|x1}}) and ''right'' ({{FuncArg|x2}}) columns to blank out.
 +
::*For [[YUY2]], [[YV16]] and [[YV12]] sources, {{FuncArg|left}} and {{FuncArg|right}} must be [[Modulo|mod2]] (divisible by 2).
 +
::*For [[YV411]] sources, {{FuncArg|left}} and {{FuncArg|right}} must be [[Modulo|mod4]] (divisible by 4).
 +
 
 +
:{{Par2|color|int|(black)}}
 +
::Fill color; specified as an RGB value. See [[Colors|this page]] for more information on specifying colors.
 +
::*For YUV clips, colors are converted from full-range (0{{D}}-255{{D}}) to TV-range (16{{D}}-235{{D}}).
 +
 
 +
:{{Par2|color_yuv|int|}} {{AvsPluscon}}
 +
::Specifies the color of the border using YUV values. It requires setting pixel_type to one of the YUV formats; otherwise it doesn't do anything.
 +
::Similar to {{FuncArg|color_yuv}} in BlankClip
 +
 
 +
== Changes ==
 
{| border="1"
 
{| border="1"
 +
|-
 +
| v3.4.1 AVS+
 +
| Added color_yuv option.
 
|-  
 
|-  
 
| v2.07
 
| v2.07
Line 18: Line 53:
 
|-  
 
|-  
 
| v2.06
 
| v2.06
| Added optional left and right parameters (x1 and x2).
+
| Added optional left and right parameters (''x1'' and ''x2'').
 
|}
 
|}
  
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 +
[[Category:Borders_and_Cropping]]

Latest revision as of 06:24, 18 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io


Fills the top and bottom rows of each frame, and optionally the left and right columns, with black or color. This has several common uses:

  • Black out video noise from the existing black bands in an image that's already letterboxed
  • Black out the video noise at the bottom of the frame in VHS tape sources.
  • Black out overscan areas in VCD or SVCD sources.
  • Create a quick rectangular mask for other filters – a so-called "garbage matte"

See also: AddBorders, which increases frame size. Letterbox does not change frame size.

The functionality of Letterbox can be duplicated with a combination of Crop and AddBorders, but Letterbox is faster and easier.

Generally, it's better to Crop video noise off than to black it out; many older lossy compression algorithms don't deal well with solid-color borders, unless the border happens to fall on a macroblock boundary (16 pixels for MPEG). However, in some cases, particularly for certain hardware players, it's better to use Letterbox because it lets you keep a standard frame size.

AVS+ also supports RGB64, PlanarRGBA and YUVA.


[edit] Syntax and Parameters

Letterbox(clip clip, int top, int bottom [, int x1 , int x2 , int color ] [, int color_yuv AVS+])

int  top, bottom = (required)
Number of top and bottom rows to blank out.
  • For YV12 sources, top and bottom must be mod2 (divisible by 2).
int  x1, x2 = 0
Number of left (x1) and right (x2) columns to blank out.
  • For YUY2, YV16 and YV12 sources, left and right must be mod2 (divisible by 2).
  • For YV411 sources, left and right must be mod4 (divisible by 4).
int  color = (black)
Fill color; specified as an RGB value. See this page for more information on specifying colors.
  • For YUV clips, colors are converted from full-range (0d-255d) to TV-range (16d-235d).
int  color_yuv =
AVS+
Specifies the color of the border using YUV values. It requires setting pixel_type to one of the YUV formats; otherwise it doesn't do anything.
Similar to color_yuv in BlankClip

[edit] Changes

v3.4.1 AVS+ Added color_yuv option.
v2.07 Added color option.
v2.06 Added optional left and right parameters (x1 and x2).
Personal tools