PDA

View Full Version : Cropping Distorts Colors?...


Typhoon859
23rd February 2009, 03:54
When I have this line of code...
crop(2,2,-2,-2,true)

...for some reason, the colors shift to the upper-left or something.. Then, there's like some kind of line, splitting the colors a third of the picture from the right... What's even stranger is that it's perfectly fine if I do a resize. Anybody know why this might be happening?

Typhoon859
23rd February 2009, 06:24
I can capture a frame and post it if that would help.

manono
23rd February 2009, 09:04
Anybody know why this might be happening?
You're cropping a YV12 interlaced video by Mod2?

http://avisynth.org/mediawiki/Crop

krieger2005
23rd February 2009, 10:10
@manono: He cropped by 4, so if the video is mod 4 (interlaced) or 2 at the beginning, the crop should't affect in any negative way.
@Typhoon859: The problem you described comes often if you have the mod-problematic (that's why manono said it). It would help if you say your input-resolution of the video.

Gavino
23rd February 2009, 11:13
He cropped by 4, so if the video is mod 4 (interlaced) or 2 at the beginning, the crop should't affect in any negative way.
For interlaced YV12, it's not enough for the resultant height to be mod4, the vertical 'cropping points' must also be mod4 or else the chroma will be associated with the wrong field.

Typhoon859
23rd February 2009, 11:47
You're cropping a YV12 interlaced video by Mod2?

http://avisynth.org/mediawiki/Crop

The video is 720x480 and it's progressive. I do convert to YV12 in the beginning though, yes. I took that out just now though but it still happens.

2Bdecided
23rd February 2009, 12:03
So what colour format is it without/before conversion?

Typhoon859
23rd February 2009, 12:05
So what colour format is it without/before conversion?

I don't know. How do I check?

2Bdecided
23rd February 2009, 16:54
Somewhere in your script, just after the source command, add info(), e.g.:

whateversource("something.xxx")
info()
return last

...and look at the resulting video e.g. in VirtualDub.

Cheers,
David.

neuron2
23rd February 2009, 17:42
I don't know. How do I check? You don't know? What is the video and where did you get it?

Typhoon859
23rd February 2009, 18:09
You don't know? What is the video and where did you get it?

It's from a Dragon Ball Z Remastered DVD by FUNimation.

Typhoon859
23rd February 2009, 21:39
Somewhere in your script, just after the source command, add info(), e.g.:

whateversource("something.xxx")
info()
return last

...and look at the resulting video e.g. in VirtualDub.

Cheers,
David.

oh... well the original ColorSpace is actually YV12 so... I don't even need that ConvertToYV12 line.. Ummm, so yeah... Some additional info-
FieldBased (Separated) Video: NO
Parity: Top Field First
Video Pitch: 736 bytes

neuron2
24th February 2009, 02:34
Gavino gave you the answer already.

Typhoon859
24th February 2009, 02:50
Gavino gave you the answer already.

I don't get it. Sorry. He explained.. something - that I didn't understand. I still don't know how to solve the problem :(

neuron2
24th February 2009, 02:59
You have to crop vertically in units of 4, not 2.

Crop(2,4,-2,-4)

Typhoon859
24th February 2009, 03:11
You have to crop vertically in units of 4, not 2.

Crop(2,4,-2,-4)

Hmmm.. I know I've been asking many questions but, honestly, if I'm bothering you, you don't have to answer. Anyway, well, if I did that, it would mess up the ratio a little bit. Would I be able to do the following?
Crop(2,0,-2,-0)

Better than cropping so much.. In any case, I don't really understand why. Think you can explain? I'm interested. (Not interested enough to read 5 links to 5 different articles of explanation though)

neuron2
24th February 2009, 03:24
Hmmm.. I know I've been asking many questions but, honestly, if I'm bothering you, you don't have to answer. I only get bothered when the rules are not followed, so relax.

Anyway, well, if I did that, it would mess up the ratio a little bit. Would I be able to do the following?
Crop(2,0,-2,-0) 0 is a multiple of 4, so yes.

Better than cropping so much.. In any case, I don't really understand why. Think you can explain? I'm interested. (Not interested enough to read 5 links to 5 different articles of explanation though) For YV12, you have N lines of luma but only N/2 lines of chroma. So if you crop 2 lines of luma, that crops 1 line of chroma. Cropping one line from anything has the effect of moving the data from one field to the other. This effect is intentionally used to reverse field dominance. But it's not something you want in your case, because the chroma changes fields but the luma does not.

When you crop by 4, that gives a chroma crop of 2, which is an even number so the chroma stays in the right field.

Typhoon859
24th February 2009, 12:03
Hmmm.. Ok, I see, but, how come it isn't a problem after I do a resize? Why does that even matter? It's the original that I'm cropping and only after which point I resize.

neuron2
24th February 2009, 12:40
Post a short unprocessed original clip and give us the exact scripts that produce any effects that you think are unexpected or unexplained.

Typhoon859
24th February 2009, 14:40
Post a short unprocessed original clip and give us the exact scripts that produce any effects that you think are unexpected or unexplained.

Well, the clip I already posted. You explained why cropping the way I did causes the effect described in my original post to happen. I'm just asking why it doesn't happen after I resize-
crop(2,2,-2,-2,true)
LanczosResize(704,396)

If I do that, there's no problem. I just want to know why.

Didée
24th February 2009, 14:59
If I do that, there's no problem. ... no problem except for the ghosting which you're talking bout in that other thread, nay?

Your source is not progressive, but interlaced (telecined). Such a source you can not crop and/or resize at free will. You need to respect the technical imperatives. Search up on "interlacing" and "IVTC" to inform yourself. It's been explained a thousand times before.

First of all, do an IVTC on the source, like you were shown in [one of] your other thread[s]. After that, you can crop-around and resize-around to your heart's content.

Typhoon859
24th February 2009, 15:13
... no problem except for the ghosting which you're talking bout in that other thread, nay?

Your source is not progressive, but interlaced (telecined). Such a source you can not crop and/or resize at free will. You need to respect the technical imperatives. Search up on "interlacing" and "IVTC" to inform yourself. It's been explained a thousand times before.

First of all, do an IVTC on the source, like you were shown in [one of] your other thread[s]. After that, you can crop-around and resize-around to your heart's content.

Oh, alright. Sorry. The effect was so subtle that I didn't think it was something that common. The things I read up on looked really severe so that's why I didn't relate it. An encoder that I got inspired by has been doing this for a very long time and I think that even he didn't do this in his encodes so it's not necessarily from inexperience that I'm having some of these issues, although it's definitely part of it. But um, I mean. That's why I'm posting here - to learn, honestly.. I did a lot of learning by reading up but these things that I posted I didn't really know how to look up. And thanks again Didee.

Gavino
24th February 2009, 15:25
Well, the clip I already posted.
Did I miss that? I can't see any clip posted above.

Please post your entire script too so we can see the source filter and any others that might have a bearing on the problem.

The interlaced YV12 cropping problem I described (more fully explained by neuron2) might not be the whole story, especially if you are right in saying that the video is progressive.

Does changing crop(2,2,-2,-2,true) to crop(2,2,-2,-2) make any difference?

EDIT: Ah, I hadn't seen the previous two posts when I wrote that. If the problem is now 'solved', forget it.

Didée
24th February 2009, 15:34
@ Typhoon859 - well, it really must be some very faint ghosting. I fail to see any.

However, something funny seems to go on when doing some tight cropping. While e.g. "crop(2,4,-2,-4)" should be technically okay, it displays with distorted colors in Vdub. The distortion disappears when adding "ConvertToRGB()" at the end of the script. Somewhat mysterious.

Typhoon859
24th February 2009, 18:01
Did I miss that? I can't see any clip posted above.

Please post your entire script too so we can see the source filter and any others that might have a bearing on the problem.

The interlaced YV12 cropping problem I described (more fully explained by neuron2) might not be the whole story, especially if you are right in saying that the video is progressive.

Does changing crop(2,2,-2,-2,true) to crop(2,2,-2,-2) make any difference?

EDIT: Ah, I hadn't seen the previous two posts when I wrote that. If the problem is now 'solved', forget it.

Oh, my bad. That was in the other two threads that I posted the video.
-http://www.mybloop.com/Typhoon859/Dragon_Ball_Z_Remastered_DVD-Video_Rips/Ghosting_vob

Adding true at the end just makes it a little bit faster from what I understand. It doesn't really change anything.

I tried it without any code but the resize. The resize was the entire script. That's how I figured out that was causing the problem. And yes, the clip is indeed progressive (or at least that's what DGIndex and VDubMod say. You can see for yourself now.

Typhoon859
24th February 2009, 18:09
@ Typhoon859 - well, it really must be some very faint ghosting. I fail to see any.

However, something funny seems to go on when doing some tight cropping. While e.g. "crop(2,4,-2,-4)" should be technically okay, it displays with distorted colors in Vdub. The distortion disappears when adding "ConvertToRGB()" at the end of the script. Somewhat mysterious.

Strange indeed. Umm, one question though. How do you know that the clip is telecined? I thought that you were able to tell because that's what the ghosting was but you're saying you don't see any. Other than that, I don't see anything wrong with it, besides that the framerate is 29.97 instead of 23.976 which it was originally, before converted to NTSC. That's what causes problems on many DVDs, especially anime - I know that... but...

In any case, I need to get home to take a snapshot of a frame the shows the ghosting I'm speaking about.

neuron2
24th February 2009, 21:23
@Didée

VirtualDub always upsizes chroma progressively, which is wrong when the frames are sampled interlaced.

How do you know that the clip is telecined? By knowing what telecining is and looking at the video by fields. You can also look at the count of field repeats in the Info box of DGIndex.

Didée
25th February 2009, 12:12
Oh dear, silly mistake on my side. DGIndex happened to be set to "honor pulldown flags" (didn't checked the actual setting), bravely applied 3:2 pulldown, and I fell for that output.
embarrassing!:o

I take everything back and argue the converse. The sample is progressive, so no need to IVTC.

Apologizes for the noise.

neuron2
25th February 2009, 12:20
The sample is progressive, so no need to IVTC. There's no need to IVTC with filters, but you still need to IVTC. Force Film mode is an IVTC method.

Typhoon859
25th February 2009, 14:16
There's no need to IVTC with filters, but you still need to IVTC. Force Film mode is an IVTC method.

Well, how does IVTC aid the video? What technical/visual difference would it make?

IanB
25th February 2009, 19:59
IVTC takes a 59.94 fields per second video stream with a 3:2 telecine pattern (encoded as 29.97 interlaced frames per second) and recovers the original 23.976 progressive film frames per second.

With the progressive film frames you can do you manipulations and processing without the difficulties and problems of interlacing.

Typhoon859
25th February 2009, 21:17
IVTC takes a 59.94 fields per second video stream (encoded as 29.97 interlaced frames per second) and recovers the original 23.976 progressive film frames per second.

With the progressive film frames you can do you manipulations and processing without the difficulties and problems of interlacing.

Isn't that exactly what FDecimate() does?

IanB
25th February 2009, 23:43
Sorry, and the 59.94 fields per second video stream has a 3:2 telecine pattern.

So no, FDecimate(), does full frame removal.

The IVTC process reassociates the fields into whole frames then discards the 1 duplicate in 5 frames.

:search: "Telecine IVTC" there is an absolute mountain of information on this subject.

Typhoon859
26th February 2009, 00:24
Sorry, and the 59.94 fields per second video stream has a 3:2 telecine pattern.

So no, FDecimate(), does full frame removal.

The IVTC process reassociates the fields into whole frames then discards the 1 duplicate in 5 frames.

:search: "Telecine IVTC" there is an absolute mountain of information on this subject.

Lol, yeah, I know. I can imagine.. I read up on it before but I thought it was something about every 5th frame being interlaced. I don't see it on these DVD-sources. It looks perfectly progressive to me :/

krieger2005
26th February 2009, 10:43
It looks perfectly progressive to me

The sample is progressive, so no need to IVTC.

There's no need to IVTC with filters, but you still need to IVTC. Force Film mode is an IVTC method.

Any Conclusion, Typhoon?

neuron2
26th February 2009, 14:01
Typhoon859 is on a 30-day vacation so won't be able to respond immediately.

Comatose
27th February 2009, 16:35
You don't know? What is the video and where did you get it?
Wow... you know, people new to Avisynth often don't even know what "color format" means.

neuron2
27th February 2009, 18:18
He has a past record of rule 6 violation and over a hundred posts, so the question is reasonable. Please take further off-topic discussion to PM.

Typhoon859
11th April 2009, 06:35
He has a past record of rule 6 violation and over a hundred posts, so the question is reasonable. Please take further off-topic discussion to PM.

This was pretty much the first week I was on doom9 when all of this happened. I just happened to be really into this which is why I had over 100 posts. I didn't know that the fair post I made in terms of what it was a response to was anything close to enough to violate "Be nice to each other and respect the moderator. Profanity and insults will not be tolerated."

In terms of Rule 6.. I posted an irc link once of the location of an encoder I've been speaking to. It's really just a chatting community... I think you were a bit too strict. You could've just deleted the link and told me not to do that again. Anybody I've showed this to thought it was completely ridiculous. Usually my friends are the first to point out my wrongs. I'm terrified of every little action I do simply because of how strictly you see the forum rules as being.

Anyway, @krieger2005, umm, I just got confused when I saw that. Those are two conflicting statements. In any case, the encodes look just fine without the IVTC so I'm basing my conclusion off that. There's no need to IVTC.

aaar9800
13th April 2009, 00:27
I am about to rip a dvd of a five episode mini series. The video has 11 pixel border on the left and a 9 pixel border on the right, so I figured I would post in this thread instead of starting a new one.

I am considering using the following script:

ConvertToRGB24()
crop(11,0,-9,0)
ConvertToYV12()

Since YV12 has color information in mod4, would this script degrade video due to resampling (3 pixels of old chroma + 1 new)? Or would it be better just to overcrop on one of the sides and have a residual one pixel border, i.e.:

crop(12,0,-8,0)