View Full Version : new version of AutoCrop plugin
len0x
3rd January 2005, 15:31
Here we go - version 1.2. Change log:
- 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)
Download: http://len0x.leffe.dnsalias.com/autocrop12.zip
AmiRage
5th January 2005, 11:12
Thanks, but ...
Forbidden
You don't have permission to access /autocrop12.zip on this server.
Apache/1.3.27 Server at len0x.leffe.dnsalias.com Port 80
len0x
5th January 2005, 11:42
It is protected via referrers feature, so downloads are only possible via clicking through this forum.
stealth82
24th April 2006, 11:29
A lot of time has passed since the last post...
I would like to use this promising filter to crop, on the fly, my DVDs (or whatever video file) through ffshow + Avisynth.
BTW, it seems doesn't work very well. Strange things happen.
When I use this call, the simpleAutoCrop(), I get this situation:
http://www.webalice.it/volpato.s/htpc/avisynth/autocrop/first_tn.jpg (http://www.webalice.it/volpato.s/htpc/avisynth/autocrop/first.jpg)
It seems do not crop (as preview) the frame.
If I click on the ffdshow properties, and I modifiy and resave (with the apply button) the Avisynth call, the preview changes as following screenshot:
http://www.webalice.it/volpato.s/htpc/avisynth/autocrop/second_tn.jpg (http://www.webalice.it/volpato.s/htpc/avisynth/autocrop/second.jpg)
So, I try to crop for real the source. I change the AutoCrop call with: AutoCrop(mode=0,aspect=-1) (the aspect parameter should be maintain the original aspect ratio). But the result is very odd; the frame is very little (indicated by the arrow):
http://www.webalice.it/volpato.s/htpc/avisynth/autocrop/third_tn.jpg (http://www.webalice.it/volpato.s/htpc/avisynth/autocrop/third.jpg)
Some ideas?
neutrogenik
24th April 2006, 23:31
use this
AutoCrop(mode=0, threshold=30, samplestartframe=200, sampleendframe=205)
and screenshot me what you got :)
stealth82
26th April 2006, 10:07
and screenshot me what you got :)
Always strange problems... now I get a frame of a color (it seems a zoom of a particular frame area). In combination with LSF and Lanczos resize an error appears: "line 3; the image is too small" etc...
BTW, I'm start to think that's impossible achieve my goal. In a DVD the frame dimensions change several times and the AutoCrop function don't recognize this (it would be useful a sort of reexecution). So, I get a cutted frame even when not necessary (based on the first "sample").
Thanks anyway.
Barleyman
31st December 2006, 18:03
Dumb question about this plugin.. If you define samples = 50 and give some broad range for start and end frame (say, 7500 and 30000), does autocrop pick randomly 50 frames in that range or just 50 sequential frames in 7500 onwards?
foxyshadis
31st December 2006, 18:24
It picks 50 frames at equidistant intervals.
zambelli
19th May 2007, 02:19
I think there's a bug in the plugin. Even when wMultOf and hMultOf are specified, the plugin will pick top and bottom points which aren't multiples of those numbers. This can be really bad when dealing with YV12 video. For example, regardles of the MultOf values, the filter might still do Crop(6,2,64,128). This will effectively mess up the chroma in a YV12 video.
len0x
19th May 2007, 11:51
I think that would have been noticed ealier if it was a common problem... what's you avisynth script and how do you know it doesn't respect the parameters?
zambelli
19th May 2007, 21:16
I think that would have been noticed ealier if it was a common problem... what's you avisynth script and how do you know it doesn't respect the parameters?
AutoCrop(mode=3, wMultOf=16, hMultOf=16, samples=7)
I used the log function to verify that it was cropping on mod2 dimensions. Also, there was chroma ghosting in the cropped video. Converting the video to YUY2 made the chroma problem go away - which would strongly suggest AutoCrop was not respecting mod4 cropping for YV12.
len0x
19th May 2007, 22:02
You should probably re-read what those parameters actually do: "Ensures that the width/height 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." It does NOT ensure the crop itself will be done as mod16 in your case, but just height/width...
zambelli
21st May 2007, 10:39
You should probably re-read what those parameters actually do: "Ensures that the width/height 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." It does NOT ensure the crop itself will be done as mod16 in your case, but just height/width...
That doesn't make much sense, IMHO, but more importantly: the plugin should not be cropping YV12 at less than mod4 vertically when the video is interlaced. Since it does not have any way of knowing whether the video is interlaced, it should either have an "interlaced=true" parameter or it should never crop at less than mod4 vertically. From the Avisynth docs for Crop():
In order to preserve the data structure of the different colorspaces, the following mods should be used. You will not get an error message if they are not obeyed, but it may create strange artifacts.
In RGB:
width no restriction
height no restriction if video is progressive
height mod-2 if video is interlaced
In YUY2:
width mod-2
height no restriction if video is progressive
height mod-2 if video is interlaced
In YV12:
width mod-2
height mod-2 if video is progressive
height mod-4 if video is interlaced
len0x
21st May 2007, 18:28
That is probably true, but I'm just pointing out that there is no bugs in existing parameter implementation. I didn't write the original plugin, so I can't comment on what was the intended use, but since no one raised this for many years before I'm guessing no one is using it on interlaced material (I always deinterlace before crop)...
(I always deinterlace before crop)...
Hmm... and this was the reason why you didn't implement "keep interlaced" in AutoGK? I asked you that some time ago in the AutoGK thread, and you responded something like: "... usefull feature..."
enjoy,
Mtz
len0x
22nd May 2007, 19:32
Frankly I don't understand the question and not only the question itself, but logic behind it...
zambelli
29th May 2007, 11:13
That is probably true, but I'm just pointing out that there is no bugs in existing parameter implementation. I didn't write the original plugin, so I can't comment on what was the intended use, but since no one raised this for many years before I'm guessing no one is using it on interlaced material (I always deinterlace before crop)...
Fine, it's not in the parameters perhaps, but it is in the implementation. YV12 interlaced is not being handled correctly. I'm not saying YOU should fix it. But I am saying it's there if somebody cares enough to fix it.
smok3
19th October 2007, 10:50
if my original is LB 4:3 and my target is PAR 1:1..., is there a way to automate the resizing after the autocrop? (like max y=somey, max x= somex, do something nice with that..)
morphinapg
13th April 2008, 21:10
I'm having a problem, some videos can't be auto cropped because they aren't YUY2 or YV12, so I add ConverttoYV12() to the script before autocrop and it hangs whenever I open the AVS in any program.
buzzqw
14th April 2008, 07:20
a simple workaround for not yv12 file could be this
movie = directshowsource("myfile.mkv",fps=25.000000,convertfps=true,audio=false)
movie = isRGB(movie) ? ConvertToYV12(movie,interlaced=true) : movie
movie = isYUY2(movie) ? ConvertToYV12(movie,interlaced=true) : movie
in that way your movie will be sure yv12
BHH
morphinapg
14th April 2008, 09:04
I did make sure my video was yv12 by using converttoyv12(), which by itself loaded just fine, but after I added autocrop, the script won't load in any program, and doesn't give an error, it simply hangs.
unskinnyboy
14th April 2008, 10:32
I did make sure my video was yv12 by using converttoyv12(), which by itself loaded just fine, but after I added autocrop, the script won't load in any program, and doesn't give an error, it simply hangs.Can you post a sample of this clip you are having problems with, and also your full script? We'll see if we can replicate your issue.
foxyshadis
14th April 2008, 18:59
It might not be hanging, it does take a while to generate the crop parameters depending on your settings and how well the movie seeks (and if it doesn't seek at all, like some formats, it's going to be very, very slow, as it has to decode the entire movie).
morphinapg
18th April 2008, 08:53
It might not be hanging, it does take a while to generate the crop parameters depending on your settings and how well the movie seeks (and if it doesn't seek at all, like some formats, it's going to be very, very slow, as it has to decode the entire movie).
Hmm, it appears that may be the problem. I'll have to do some tests and see if that's what's happening.
EDIT:
Yes, that's what was happening.
Varies
30th December 2009, 17:09
Hello, len0x
Is it posible to add several new parameters?
like integer Force[Left,Top,Right,Bottom]Crop (-1=ForceNoCrop, 0=OFF, >0=AwaysCrop).
so, i try to write real-time cropping plug-in (http://forum.doom9.org/showthread.php?t=151755) ^ ^)
Two years later, I have now run up against AutoCrop's mishandling of interlaced YV12. Is there someone, anyone, out there who would be willing to modify the plugin to use mod 4 height for YV12? From what I can tell, it wouldn't be a difficult modification. I've attempted to do it myself, but I simply do not have the resources and knowledge necessary to do so. I would greatly appreciate if someone would take the time to do it.
Guest
6th July 2010, 12:43
Does this do what you are looking for:
http://neuron2.net/misc/autocrop_patched.zip
I just made it default to height mod 4 for YV12.
Ah, no, not quite, but thank you. I think the part that needs changed is this:
// Ensure Valid Cropping points for YV12
if (left%2) {
left+=1;
right+=1;
}
if (top%2) {
top+=1;
bottom+=1;
}(the second part, line 547)
So that the starting point for the top of the crop is mod 4. That way it preserves the correct alignment of interlaced YV12 chroma.
I'm sorry I wasn't more clear in my earlier post, it was 2 in the morning and I was a bit tired.
Guest
6th July 2010, 14:57
You're still unclear. Do you ALSO want the change I made, since that is what you originally asked for?
Gavino
6th July 2010, 17:00
Two years later, I have now run up against AutoCrop's mishandling of interlaced YV12. Is there someone, anyone, out there who would be willing to modify the plugin to use mod 4 height for YV12?
Wouldn't it be better to make this controlled by a (new) parameter, eg 'interlaced' (default false), rather than unconditionally enforcing mod4?
neuron2: The change you made doesn't make a difference either way. It doesn't really affect what I'm doing. Thanks, though.
Gavino: Probably, but that would be additional work. I don't really care how it is implemented.
Guest
7th July 2010, 14:13
I made your suggested change. Re-download the previous link.
Ah, that did it, but it also seems to have introduced a bug.
With these settings:
AutoCrop(1, hmultof=4, leftadd=96, samplestartframe=framecount(foot)*3/12, sampleendframe=framecount(foot)*5/12, aspect=45.0/44.0)
I get this result:
http://www.stupidideasstudios.com/AutoCropError.png
And when I change mode to 0, I get this error:
avisynth.AvisynthError: ConvertToYUY2: Cannot convert from YV12 if height is not even. Use Crop!
Guest
8th July 2010, 02:38
Give me your source video and script so I can duplicate it.
Guest
19th July 2010, 12:50
@um3k
I really like to finish jobs that I start. Have you decided to abandon this?
um3k
19th July 2010, 16:07
I'm sorry. I found a workaround, as simple as separating fields before using this filter. The results aren't 100% identical, but they're close enough. I don't think I can give you the source stream because a) it would require the full file (~1 gig) to get the same results and b) it is an 8mm home movie that I have been paid to transfer and I don't feel it would be right to share it.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.