Log in

View Full Version : AutoGK And Cropping Errors


JediYodaNT
26th September 2004, 21:57
Hey Guys, I Need A Little Advice. I Read Someones Post Earlier About AutoGK Cropping Part Of The Picture Without Being Set To Do It. The Response Was That There Was Going To Be A New Option In The Hidden Options Add On App To Correct This Error. I've D/L'd The Add On And Cannot Find The Setting Needed To Correct The Issue. I've Been Ridding My Angel Season 4 DVDs and So Far Discs 1 And 2 Have Ripped And Converted Wonderfully. However, When I Encode Disc 3 AutoGK Crops The Bottom Of The Picture. Can You Guys Recommend Anything I Can Do To Fix This Error?

len0x
27th September 2004, 11:04
Reduce threshold of autocrop to say 20...
And use AutoGK Assistant for that...

KingArgyle
17th December 2004, 17:17
I'm having similar problems but with some MPEG files that have been recorded from TV. I've tried lowering the threshold of the cropping to 1 and have changed the default number of frames to 20 from 10 to analyze, but the bottom portion of the program is always cropped off. If a program has any text at the bottom of the screen, this is cut off. Perfect example is the opening credits in "Frasier", the bottom portion picture is cut off (by about 1/8). Adjusting the settings of autocrop helped, but didn't eliminate the problem.

Any ideas, or am I going to have to go the full GK route to handle this?

len0x
17th December 2004, 18:12
Do you have to crop at all? you can disable it by setting threshold to 0...

jggimi
17th December 2004, 18:27
...but the bottom portion of the program is always cropped off....

Are these captures from tape rather than from broadcast? If so, you are probably seeing artifacts of head switching noise. I ask, because head switching noise appears at the bottom of images from VHS tape.

KingArgyle
17th December 2004, 18:58
No they are from broadcast. Recorded with the Life View Walker Ultra in MPEG2 format using GBPVR to control the recording.

Lenox, I'll try setting the threshold to 0 and see how that works.

KingArgyle
18th December 2004, 06:55
I found what the problem was. The aspect ratio was getting set to 1:1. As soon as I edited the AVS script to change to 4:3, everything was fine in preview mode.

I know I can abort the DGIndex and modify the d2v file to change the aspect ratio, but I want to batch up a bunch of these to convert over night, and rather not baby sit the process. I looked at Faq 6.10, and that method will work. Not batch friendly.

Is there a tool that I can use to correct this problem in the source files?

len0x
18th December 2004, 16:11
ProjectX might be able to do that, however your recoding program might be able to adjust AR as well.

KingArgyle
20th December 2004, 20:25
Thanks. I was able to use Project X to fix the Aspect Ratio problem. I'll see if I can get the developer of GBPVR to take a look at how the aspect ratio information is being stored in the mpeg stream.

Rafael
4th January 2005, 18:28
>> Are these captures from tape rather than from broadcast? If so, you are probably seeing artifacts of head switching noise. I ask, because head switching noise appears at the bottom of images from VHS tape.<<

I have this problem, and the way the autcrop defaults are set, I still sometimes get noise/artifacts from VHS conversion in my final avi. How do I make sure I get rid of these artifacts using the autocrop feature? Should I change the threshold, the number of frames to examine, or the the starting frame for autocrop operation?

Thanks! :)

len0x
4th January 2005, 18:51
Originally posted by Rafael
How do I make sure I get rid of these artifacts using the autocrop feature?

Wait until next version of AutoGK - I have the solution that allows almost manual cropping ready :)

Rafael
4th January 2005, 19:00
Originally posted by len0x
Wait until next version of AutoGK - I have the solution that allows almost manual cropping ready :)

Thanks for the quick reply len0x. Anything I can do by fine-tuning the autocrop parameters in the current version? When will the next one be available?

Actually, sorry to be a pain but I have one more question (which does not belong in this thread, so my apologies). How do I change the default player for the preview option?

Thanks again!

jggimi
4th January 2005, 19:00
You could experiment with a short capture and increase the threshold to the point where autocrop eliminates the head switching interference. But that would introduce aspect ratio errors. Manually cropping away this interference may also introduce AR error.

You might consider switching from AGK to GK, in order to add the Letterbox() filter to your script manually. Letterbox() is recommended by the Analog Capture Guide (http://www.doom9.org/capture/start.html). I do HuffYUV captures to .avi and use GK, but GK can also accept MPEG-2 captures through DGIndex.

[EDIT: Added manual cropping note after seeing update from len0x.]

len0x
4th January 2005, 19:28
Originally posted by Rafael
When will the next one be available?


now!
see hidden_options.txt for instructions

Originally posted by Rafael
How do I change the default player for the preview option?


you can't...

len0x
4th January 2005, 19:30
Originally posted by jggimi
Manually cropping away this interference may also introduce AR error.

How?

jggimi
4th January 2005, 19:43
If after cropping, AutoGK resizes to an assumed DAR of 4:3.

len0x
4th January 2005, 19:49
Nah, a given AR is feeded into autocrop, so it does more cropping to achieve proper AR. In case you force more cropping on one side - all others will be cropped automatically.

jggimi
4th January 2005, 20:11
That will not harm the AR, whenever a capture has a PAR of 1:1, such as 640x480. But it may remove excessive content from the other three overscan areas. That's an issue of personal taste and content source.

But what if a capture stream does not have a 1:1 PAR? For example, one can have a 720x480 capture or a 704x480 capture of the same content. I suppose it would depend on DAR/PAR information obtained from the MPEG-2 stream? I don't capture MPEG-2, so I haven't looked into it.

The guide recommends Letterbox() for tape captures, to black out the bottom lines without impacting other areas of the image, and retaining all other captured pixels for final resizing, if any. See section 7.2.6 of the Capture Guide for an example that blacks out the bottom 16 lines. I'm able to use 8 with my captures.

Rafael
5th January 2005, 19:04
OK, I'm still having some trouble with understanding how to crop off the VHS tracking noise. I downloaded 1.85 and I'm looking at the hidden_options.text file:
______________________________________________________________
6) Tune auto crop parameters
.autocrop

First line is a threshold 1-255 (AutoGK uses 34 by default). The less number is the more cropping will be done.
Second line is number of frames to examine (AutoGK uses 10 by default)
Third line (optional) is starting frame for autocrop operation (useful if beginning logo or into has different AR)
Forth line (optional) is left,right,top,bottom forced crop values _after_ initial autocropping is performed. So if you want to crop out some non-black material (like bottom 8 pixels in 1088i stream) you can use this parameter.
To use it for manual cropping set threshold to 0 and then crop values in the forth line will be actual crop values.
Note that AutoGK is enforcing mod4 values for both horizontal and vertical cropping.

34
10
1000
4,4,4,4
________________________________________________________________

All I need is to trim off some pixels from the bottom (let's say 12). So what do I need to do exactly? Do I edit this file, and set set the first line at 0 and the fourth line at 0,0,0,12? Or do I do something else?

Thanks!

len0x
5th January 2005, 19:14
Originally posted by Rafael
All I need is to trim off some pixels from the bottom (let's say 12). So what do I need to do exactly? Do I edit this file, and set set the first line at 0 and the fourth line at 0,0,0,12?

You don't have to set threshold to 0, just use 0,0,0,12 if those 12 pixels are not black.

Rafael
5th January 2005, 19:28
Thanks. So I can just leave lines 1-3 at default values and set line 4 at 0,0,0,12? Once I do this editing, do I just save the file, start AutoGK, and send the job? Nothing to change in the AutoGK Assistant menu at all? Thanks again for your patience....

len0x
5th January 2005, 19:31
correct

Rafael
6th January 2005, 18:07
OK, I experimented with this issue for several hours now. For my purpose it seems to make no difference how I manually set the fourth line parameters. I always get about three pixels of noise on the bottom of the autogk-encoded video. I used TMPEGEnc to measure exactly how many pixels I would need to shave off the original video to get rid of the noise, and it comes up to 10. Then I went to the AUTOGK hidden options text document and consecutively set the parameter at 10, then 12, and then 15, and none of those settings allows me to remove the three pixels of noise at the bottom. In fact, I took back the autogk-encoded files to TMPGEnc again, and in the end they all have the same amount of noise (three pixels) at the bottom, so the value of the fourth parameter appears to make no difference at all. Any clues?

len0x
6th January 2005, 18:23
please post your avs file

Rafael
6th January 2005, 18:33
How do I do that? I just tried attaching the avs file and it won't allow it as a valid attachment extension.

jggimi
6th January 2005, 18:37
Open the file in an editor (such as Notepad).

Copy all.

Paste in the thread.

Rafael
6th January 2005, 18:55
OK, here are the avs files. Just from looking at them (and given my limited knowledge of these programs), it seems that autogk may not be recognizing the manual modifications I make to the autocrop file. But then again, what do I know????

This is the _.avs file:

LoadPlugin("C:\PROGRA~1\AutoGK\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\decomb.dll")
file="C:\Tenorio Documents\Movies\Auto\agk_tmp\interlace.log"
global sep="-"
function IsMoving() {
global b = (diff < 1.0) ? false : true}
mpeg2source("C:\Tenorio Documents\Movies\Auto\agk_tmp\vr1.d2v")
c = SelectRangeEvery(180,18)
global clip = c
c = WriteFile(c, file, "a", "sep", "b")
c = FrameEvaluate(c, "global a = IsCombed(clip, 32)")
c = FrameEvaluate(c, "IsMoving")
c = FrameEvaluate(c,"global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")
crop(c,0,0,4,4)

This is the _movie.avs file:

LoadPlugin("C:\PROGRA~1\AutoGK\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\autocrop.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\RemoveGrain.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\kerneldeint.dll")

movie = mpeg2source("C:\Tenorio Documents\Movies\Auto\agk_tmp\vr1.d2v")
cropclip = autocrop(movie,mode=0,wmultof=4,hmultof=4,samples=10,aspect=0,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
fixed_aspect = 0.909090909090909
c_width = width(cropclip)
c_height = round(height(cropclip) / fixed_aspect)
input_par = float(c_width)/float(c_height)
input_par = input_par > 1.4 ? input_par : (4.0/3.0)
out_width = 304
out_height = round(float(out_width) / input_par)
hmod = out_height - (floor(out_height / 16 ) * 16)
out_height = (hmod > 4) ? (out_height + (16 - hmod)) : (out_height - hmod)
new_aspect = (float(out_width) / float(out_height)) / fixed_aspect
KernelDeInt(movie,order=1,sharp=true)
autocrop(mode=0,wmultof=4,hmultof=4,samples=10,aspect=new_aspect,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
BicubicResize(out_width,out_height,0,0.5)
RemoveGrain(mode=2)

And this is the _comptest.avs file:

LoadPlugin("C:\PROGRA~1\AutoGK\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\autocrop.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\RemoveGrain.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\kerneldeint.dll")

movie = mpeg2source("C:\Tenorio Documents\Movies\Auto\agk_tmp\vr1.d2v")
cropclip = autocrop(movie,mode=0,wmultof=4,hmultof=4,samples=10,aspect=0,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
fixed_aspect = 0.909090909090909
c_width = width(cropclip)
c_height = round(height(cropclip) / fixed_aspect)
input_par = float(c_width)/float(c_height)
input_par = input_par > 1.4 ? input_par : (4.0/3.0)
out_width = 640
out_height = round(float(out_width) / input_par)
hmod = out_height - (floor(out_height / 16 ) * 16)
out_height = (hmod > 4) ? (out_height + (16 - hmod)) : (out_height - hmod)
new_aspect = (float(out_width) / float(out_height)) / fixed_aspect
KernelDeInt(movie,order=1,sharp=true)
autocrop(mode=0,wmultof=4,hmultof=4,samples=10,aspect=new_aspect,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
LanczosResize(out_width,out_height)
RemoveGrain(mode=2)
SelectRangeEvery(300,15)

Any insights/suggestions will be greatly appreciated.

len0x
6th January 2005, 19:18
were does ".autocrop" reside and what's in it exactly?

Rafael
6th January 2005, 19:38
Originally posted by len0x
were does ".autocrop" reside and what's in it exactly?

LOL. I was going to ask you the same question. All I am doing is modifying the fourth line on item 6 in the hidden_options.txt file as you recommended. I thought this would take care of resetting the crop parameters. Do I actually need to modify the .autocrop file in addition to editing the above txt file? I don't even know where that file is. Maybe I am misunderstanding the whole procedure. That is why I had asked whether something needed to be changed in the assistant menu.

Rafael
6th January 2005, 19:42
There is an autocrop.txt file in the autogk/filters/docs folder:
__________________________________________________________
Copyright (c) 2003 Glenn Bussell. All rights reserved.
glenn@videofringe.com

This file is subject to the terms of the GNU General Public License as
published by the Free Software Foundation. A copy of this license is
included with this software distribution in the file COPYING. If you
do not have a copy, you may obtain a copy by writing to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details

AutoCrop for AviSynth V 1.1

By Glenn Bussell

INTRODUCTION

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.

The latest version of this filter is available at

http://www.videofringe.com/autocrop

CHANGES

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.

This version of AutoCrop is compiled for AviSynth 2.5. It will not work with any of the
2.0 releases. If you need to use AviSynth 2.0 please download version 0.3 of this filter
from
http://www.videofringe.com/autocrop


USAGE

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 is a lot of parameters!

Parameter order follows.

AutoCrop(mode,wMultOf,hMultOf,leftAdd,rightAdd,topAdd,bottomAdd,threshold,samples,samplest
artframe,sampleendframe,aspect)

SYNTAX

mode - Integer - default 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.

wMultOf - Integer - default 4

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 - Integer - default 2

As above but for height

leftAdd - Integer - default 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.

rightAdd - Integer - default 0

See above but for the right.

topAdd - Integer - default 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.

bottomAdd - Integer - default 0

See above but for the bottom.

threshold - Integer (0-255) - default 30

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
maybe neccessary.

samples - Integer - default 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.

samplestartframe - Integer - default 0 (first frame)

Sets the first frame to be looked at when determining the cropping parameters.

sampleendframe - Integer - default -1 (last frame)

Sets the last frame to be looked at when determining the cropping parameters. 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

aspect - Float - default 0 - Aspect is ignored

-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 4/3 won't work the .0 is need to tell AVISynth the value is
a float.

RECOMMENDED USE

I strongly suggest using the preview mode before committing to a particular crop.

SOURCE

Source is included in the distribution.

PLANNED FUTURE ENHANCEMENTS

Blanking Mode

len0x
6th January 2005, 19:51
Jeez :) Short story - use assistant to create ".autocrop" file (it has nothing to do with autocrop.txt or hidden_options.txt that are just MANUALS). Then add forth line to it (current assistant cannot create forth line yet). All hidden options are files starting with a dot that resides in the input source folder...

Rafael
6th January 2005, 22:55
Thanks!

I tested this procedure with a small file and it seems to have worked fine (the whole video file is kind of noisy so that's why I say "seems"). Will use it with a different file and report the results.

:)

ohhowhappy
8th January 2005, 20:00
Greetings to you all.
I'm also trying to get rid of about 15 pixels of VCR distortion. I've inserted
0,0,0,15 as the last line in the autocrop file. In AGK version 1.85b I get an error message:

EXCEPTION: '0,0,0,15' is not a valid integer value

1.85b, with AutoGK assistant, will run the autocrop parameter OK without that last line. But, like the other fellow, using the autocrop options AutoGK assistant offers doesn't crop properly.

Excellent program in other respects. It's attracted quite a following at the Arstechnica AV forum (http://episteme.arstechnica.com/eve/ubb.x?a=frm&s=50009562&f=67909965).

len0x
9th January 2005, 13:21
Are you sure that "0,0,0,15" is the _fourth_ line in ".autocrop"? (i.e. you created starting frame as third line using assistant).

ohhowhappy
9th January 2005, 16:13
Ah, four lines needed. I had only 3. Thank you!