AutoCrop

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(AutoCrop)
 
m (External Links: add link to patched AutoCrop)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{FilterCat4|External_filters|Plugins|Adjustment_filters|Borders and Cropping}}
 
{{FilterCat4|External_filters|Plugins|Adjustment_filters|Borders and Cropping}}
 
{{Filter3
 
{{Filter3
|[http://web.archive.org/web/20050404182221/http://www.videofringe.com/autocrop/ Glenn Bussell], len0x
+
|[https://web.archive.org/web/20050404182221/http://www.videofringe.com/autocrop/ Glenn Bussell], len0x
 
|v1.2
 
|v1.2
 
|3=[http://len0x.leffe.dnsalias.com/autocrop12.zip autocrop12.zip]
 
|3=[http://len0x.leffe.dnsalias.com/autocrop12.zip autocrop12.zip]
 
|4=Borders and Cropping
 
|4=Borders and Cropping
|5=[http://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
+
|5=[https://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
|6=[http://forum.doom9.org/showthread.php?t=37204 Doom9 Thread] - [http://forum.doom9.org/showthread.php?t=87602 Update]
+
|6=[https://forum.doom9.org/showthread.php?t=37204 Doom9 Thread] - [https://forum.doom9.org/showthread.php?t=87602 Update]
 
}}
 
}}
  
Line 15: Line 15:
 
<br>
 
<br>
 
== Requirements ==
 
== Requirements ==
* AviSynth 2.5.8 or [http://sourceforge.net/projects/avisynth2/ greater]
+
* AviSynth 2.5.8 or [https://sourceforge.net/projects/avisynth2/ greater]
 
* Supported color formats: [[YUY2]], [[YV12]]
 
* Supported color formats: [[YUY2]], [[YV12]]
 
<br>
 
<br>
 
== [[Script variables|Syntax and Parameters]] ==
 
== [[Script variables|Syntax and Parameters]] ==
AutoCrop takes 12 parameters but they are all optional so you can just do <code>AutoCrop()</code> to get a feel for how the filter works. Parameters can either be specified in order or by name. I suggest specifying by name as there is a lot of parameters!
+
AutoCrop takes 12 parameters, but they are all optional so you can just do <code>AutoCrop()</code> to get a feel for how the filter works. Parameters can either be specified in order or by name. I suggest specifying by name, as there are a lot of parameters!
 
<br>
 
<br>
 
<br>
 
<br>
Line 35: Line 35:
 
::{{Par2|wMultOf|int|4}}
 
::{{Par2|wMultOf|int|4}}
 
::{{Par2|hMultOf|int|2}}
 
::{{Par2|hMultOf|int|2}}
:::Ensures that the width of the cropped clip will be a multiple of the number specified. Use this to ensure that clip is a valid for whatever codec you are going to compress with. hMultOf is the same but for the height.
+
:::Ensures that the width of the cropped clip will be a multiple of the number specified. Use this to ensure that clip is a valid for whatever codec you are going to compress with. hMultOf is the same, but for the height.
 
<br>
 
<br>
 
::{{Par2|leftAdd|int|0}}
 
::{{Par2|leftAdd|int|0}}
:::Forces autocrop to crop and additional 'leftAdd' pixels after it completes auto detection. You can use this option in conjunction with wMultOf. Useful for cropping out bad quality lines on the side of VHS captures.
+
:::Forces autocrop to crop an additional 'leftAdd' pixels after it completes auto detection. You can use this option in conjunction with wMultOf. Useful for cropping out bad quality lines on the side of VHS captures.
  
 
::{{Par2|topAdd|int|0}}
 
::{{Par2|topAdd|int|0}}
:::Forces autocrop to crop and additional 'topAdd' pixels after it completes auto detection. You can use this option in conjunction with hMultOf. Useful for cropping out bad quality lines on the top of VHS captures.
+
:::Forces autocrop to crop an additional 'topAdd' pixels after it completes auto detection. You can use this option in conjunction with hMultOf. Useful for cropping out bad quality lines on the top of VHS captures.
  
 
::{{Par2|rightAdd|int|0}}
 
::{{Par2|rightAdd|int|0}}
Line 107: Line 107:
 
!v1.2
 
!v1.2
 
|[http://len0x.leffe.dnsalias.com/autocrop12.zip autocrop12.zip]
 
|[http://len0x.leffe.dnsalias.com/autocrop12.zip autocrop12.zip]
|[http://web.archive.org/web/20130311200834/http://len0x.leffe.dnsalias.com/autocrop12.zip autocrop12.zip]
+
|[https://web.archive.org/web/20130311200834/http://len0x.leffe.dnsalias.com/autocrop12.zip autocrop12.zip]
 
|-
 
|-
 
!v1.1
 
!v1.1
|[http://web.archive.org/web/20041204083940/http://www.avisynth.org/warpenterprises/files/autocrop_25_dll_20030617.zip autocrop_25_dll_20030617.zip]
+
|[https://web.archive.org/web/20041204083940/http://www.avisynth.org/warpenterprises/files/autocrop_25_dll_20030617.zip autocrop_25_dll_20030617.zip]
 
|
 
|
 
|-
 
|-
 
!v1.0
 
!v1.0
|[http://web.archive.org/web/20031214011808/http://www.avisynth.org/warpenterprises/files/autocrop_25_dll_20030309.zip autocrop_25_dll_20030309.zip]
+
|[https://web.archive.org/web/20031214011808/http://www.avisynth.org/warpenterprises/files/autocrop_25_dll_20030309.zip autocrop_25_dll_20030309.zip]
 
|
 
|
 
|-
 
|-
 
!v0.3
 
!v0.3
 
|[http://www.avisynth.nl/users/warpenterprises/files/autocrop_20_dll_20021105.zip autocrop_20_dll_20021105.zip]
 
|[http://www.avisynth.nl/users/warpenterprises/files/autocrop_20_dll_20021105.zip autocrop_20_dll_20021105.zip]
|[http://web.archive.org/web/20031214011808/http://www.avisynth.org/warpenterprises/files/autocrop_20_dll_20021105.zip autocrop_20_dll_20021105.zip]
+
|[https://web.archive.org/web/20031214011808/http://www.avisynth.org/warpenterprises/files/autocrop_20_dll_20021105.zip autocrop_20_dll_20021105.zip]
 
|}
 
|}
 
<br>
 
<br>
 
== External Links ==
 
== External Links ==
*[http://avisynth.org.ru/docs/english/externalfilters/autocrop.htm avisynth.org.ru] - AutoCrop documentation.
+
*[https://avisynth.org.ru/docs/english/externalfilters/autocrop.htm avisynth.org.ru] - AutoCrop documentation.
*[http://github.com/KG7x/xvid4psp/tree/master/AutoCrop GitHub] - AutoCrop mod by XviD4PSP. Original [http://code.google.com/p/xvid4psp/ Google Code repository].  
+
*[https://github.com/KG7x/xvid4psp/tree/master/AutoCrop GitHub] - AutoCrop mod by XviD4PSP. Original [https://code.google.com/archive/p/xvid4psp/ Google Code repository].  
 +
*[https://forum.doom9.org/showthread.php?p=1414983#post1414983 Doom9 Forum] - Patched Autocrop to correctly handle interlaced YV12, may no be complete: [https://web.archive.org/web/20140703022759if_/http://neuron2.net/misc/autocrop_patched.zip autocrop_patched.zip]
 
<br>
 
<br>
 
<br>
 
<br>
 
-----------------------------------------------
 
-----------------------------------------------
 
'''Back to [[External_filters#Borders_and_Cropping|External Filters]] &larr;'''
 
'''Back to [[External_filters#Borders_and_Cropping|External Filters]] &larr;'''

Latest revision as of 02:52, 19 April 2020

Abstract
Author Glenn Bussell, len0x
Version v1.2
Download autocrop12.zip
Category Borders and Cropping
License GPLv2
Discussion Doom9 Thread - Update

Contents

[edit] Description

AutoCrop is an AviSynth filter that automatically crops the black borders from a clip. It operates in either preview mode where it overlays the recommended cropping information on the existing clip, or cropping mode where it really crops the clip. It can also ensure width and height are multiples of specified numbers so the cropped clip can be passed to the video compressor of your choice without problems.

[edit] Requirements


[edit] Syntax and Parameters

AutoCrop takes 12 parameters, but they are all optional so you can just do AutoCrop() to get a feel for how the filter works. Parameters can either be specified in order or by name. I suggest specifying by name, as there are a lot of parameters!

AutoCrop (clip, int "mode", int "wMultOf", int "hMultOf", int "leftAdd", int "topAdd", int "rightAdd", int "bottomAdd", int "threshold", int "samples", int "samplestartframe", int "sampleendframe", float "aspect")


clip   =
Input clip.


int  mode = 1
  • 0 : Crop - Crops the image
  • 1 : Preview - Suggested cropping information is overlayed on the existing clip, including a crop command that you can use to replace AutoCrop with.
  • 2 : Log - Logs the cropping parameters to the file "AutoCrop.log" in the current directory.
  • 3 : Crop & Log - combination of modes 0 and 2


int  wMultOf = 4
int  hMultOf = 2
Ensures that the width of the cropped clip will be a multiple of the number specified. Use this to ensure that clip is a valid for whatever codec you are going to compress with. hMultOf is the same, but for the height.


int  leftAdd = 0
Forces autocrop to crop an additional 'leftAdd' pixels after it completes auto detection. You can use this option in conjunction with wMultOf. Useful for cropping out bad quality lines on the side of VHS captures.
int  topAdd = 0
Forces autocrop to crop an additional 'topAdd' pixels after it completes auto detection. You can use this option in conjunction with hMultOf. Useful for cropping out bad quality lines on the top of VHS captures.
int  rightAdd = 0
Same as leftAdd but for the right side.
int  bottomAdd = 0
Same as topAdd but for the bottom side.


int  threshold = 40
Threshold is the average luminance a line must have before it's considered non blank. For DVD sources values as low as 20 should work reliably. For VHS sources raising the value may be necessary.


int  sample = 5
The number of frames to examine when determining the cropping information. This directly affects the startup time of the filter. This number dramatically effects the amount of time taken for the filter to startup. Increasing the number to 10 will basically double the startup time.


int  samplestartframe = 0
int  sampleendframe = -1
These parameters set the first and last frame to be looked at when determining the cropping parameters. Defaults are the first frame(0) and last frame(-1).
If you want to take the cropping information from a single frame, set samplestartframe and sampleendframe to the same number and samples to be 1


int  aspect = 0
  • -1 : Maintain aspect ratio of the source clip
  • 0 : Aspect is ignored
  • >0 : Aspect ratio will be set to this. For example for a 4:3 aspect ratio you would pass 4.0/3.0 or 1.33333333333. Note that 4/3 won't work since the .0 is needed to tell AviSynth the value is a float.


[edit] Examples

AutoCrop with default values:

AviSource("Blah.avi")
AutoCrop(mode=1, wMultOf=4, hMultOf=2, leftAdd=0, topAdd=0, rightAdd=0, bottomAdd=0, \
         threshold=40, samples=5, samplestartframe=0, sampleendframe=-1, aspect=0)


[edit] Changelog

Version       Date            Changes
v1.2 01/03/2005 - fixed bug when preview and actual crop values were different - fixed bug when AR was not properly enforced (rounding errors) - threshold 0 ensures that no cropping is done unless necessary for AR - fixed bug when leftAdd and rightAdd parameters were not properly working in YUY2 mode - wMulfOf and hMultOf cannot be zero now - wMultOf is relaxed to be mod2 for YV12 (previously mod4) - added mode=3 which is mode 0 plus mode 2 (cropping and logging at the same time)
v1.1 06/17/2003 - Added ability to set a range of frames to sample for cropping information. - Reduced default number of frames to sample to 5. - Reduced default threshold to 30, this change and the one above should perform give equal or better performance for DVD sources much quicker. - Minor documentation updates.
v1.0 03/09/2003 - A new version of AutoCrop which solves the YV12 cropping problems found in version 0.51.
v0.51 27/02/2003 - New version 0.51 with (hopefully) working wMultOf and hMultOf in YV12 mode.
v0.5 26/02/2003 - This version (finally) adds YV12 support.
v0.4 01/30/2003 - This version of AutoCrop is compiled for AviSynth 2.5 it will not work with any of the 2.0 releases. - The preview argument (which was a boolean) has been removed and replaced with the new mode argument (which is an int) this was to allow for the implementation of the logging mode and the future blanking mode. - Aspect Ratio support. Support for maintaining and setting aspect ratios is included. - Logging mode. Image is left untouched, cropping information is written to the file "AutoCrop.log" in the current directory.
v0.3 11/05/2005 - Setting wMultOf=width now behaves correctly. ie. Just letterboxes the clip. - Debugging information no longer written to disk.
v0.1 11/03/2002 - Initial release for AviSynth 2.0


[edit] Archived Downloads

Version Download Mirror
v1.2 autocrop12.zip autocrop12.zip
v1.1 autocrop_25_dll_20030617.zip
v1.0 autocrop_25_dll_20030309.zip
v0.3 autocrop_20_dll_20021105.zip autocrop_20_dll_20021105.zip


[edit] External Links




Back to External Filters

Personal tools