View Full Version : Strange color problem
Music Fan
26th September 2015, 21:37
Hi,
I have a video that has a strange problem with colors, it's especially visible on parts in movement.
But when I play this mpg with MPC-HC, this problem is not really visible.
IIRC, I recorded it a few years ago on TV with my Set-top box. Its HDD was crypted and the only way I had to transfer recordings was to capture by its analog output (Scart with S-video adaptator) with my Hauppauge card.
Thus I wonder if the problem comes from a bad encoding by the TV channel or if it was created when I captured it and was caused by the Set-top box or by my capture card.
I recorded in mpeg-2 @ 12Mbps in PAL system. That's supposed to be anamorphic 16/9 but I exported these jpeg in 720.576 with Virtual Dub.
Here is how it looks like without any filter (I tried FFVideoSource and LWLibavVideoSource, both give the same result, except the field order), click to see the real size ;
http://nsa38.casimages.com/img/2015/09/26/mini_150926102135351873.jpg (http://www.casimages.com/i/150926102135351873.jpg.html)
It's originally progressive but encoded interlaced.
It seems 2 fields of 2 successive frames are blended.
If I use tfm(), that's better, but another problem appears (the main problem actually) ;
http://nsa38.casimages.com/img/2015/09/26/mini_150926102628755839.jpg (http://www.casimages.com/i/150926102628755839.jpg.html)
I get the same result than tfm() if I remove the first field like this ;
separatefields().trim(1,0).weave()
And here is what happens when I separate fields, whatever I use tfm() before or not, these are 3 successive frames (or fields actually) ;
http://nsa38.casimages.com/img/2015/09/26/mini_150926102822826571.jpg (http://www.casimages.com/i/150926102822826571.jpg.html)
http://nsa38.casimages.com/img/2015/09/26/mini_150926102910312734.jpg (http://www.casimages.com/i/150926102910312734.jpg.html)
http://nsa38.casimages.com/img/2015/09/26/mini_150926103238520976.jpg (http://www.casimages.com/i/150926103238520976.jpg.html)
The chroma and luma move separately :confused:
How to fix this ?
vivan
26th September 2015, 21:55
On first image both fields have exactly same chroma, which is blended from 2 frames. Last 3 images seem to have normal chroma, but it's not synced to luma.
It's really hard to say if it's fixable without an actual sample.
Music Fan
26th September 2015, 22:51
Here is a sample ;
https://www.sendspace.com/file/2eermu
poisondeathray
26th September 2015, 23:20
orig=MPEG2Source("Dji ext.d2v")
u=orig.utoy.tfm.vinverse
v=orig.vtoy.tfm.vinverse
YToUV(u,v)
MergeLuma(orig.tfm.trim(1,0))
vivan
26th September 2015, 23:30
LWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
Music Fan
26th September 2015, 23:30
orig=MPEG2Source("Dji ext.d2v")
u=orig.utoy.tfm.vinverse
v=orig.vtoy.tfm.vinverse
YToUV(u,v)
MergeLuma(orig.tfm.trim(1,0))
Thanks, great !
Do you know what could be the origin of this problem ?
And can you explain a little bit your script ?
There are still little problems ; add separatefields() at the end and look at frames 393, 395, 397, 399 and 401 (196 to 200 without separatefields) : the top of the wall becomes green.
Music Fan
26th September 2015, 23:35
LWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
Great ! That seems ok with this script :)
vivan
26th September 2015, 23:37
I can see what the problem is (chroma fields are out of order, maybe they are BFF while luma TFF), but I have no idea how this could have happened.
In my script I change order of chroma fields by using SelectEvery and then remove one field, that matches all fields and makes video progressive.
poisondeathray
26th September 2015, 23:37
vivan's looks correct.
It's a chroma phase delay. I don't know the exact "engineering-speak" mechanism, but I think it's related to PAL hannover bars
https://en.wikipedia.org/wiki/Hanover_bars
Music Fan
27th September 2015, 11:52
Thanks, I had never heard of this.
If I get it with really interlaced videos (Tv shows, documentary ...), will vivan's script work too ?
By the way, with other videos (recorded with my new Set-top box that does not crypt its HDD) transfered as is on my pc, I see sometimes the same problem than on first frame (blending) but without chroma phase delay. In this case, can I simply remove first field (which seems to work) or there is something better to do ?
When these videos are movies (originally progressive), tfm() also works. Same question ; is there anything better to do ?
Music Fan
4th October 2015, 23:43
By the way, how to compare with and without effect with this kind of script ?
LWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
I found this structure, which works with simple scripts (v1 = as is, v2 = black and white);
v1=LWLibavVideoSource("P:\Dji ext.mpg")
v2=v1.greyscale()
stackhorizontal(v1,v2)
But I don't find how to integrate the lines luma = and chroma = in this kind of structure.
vivan
5th October 2015, 01:17
For visual comparisons Interleave function is much better.
In Avisynth each function writes into a variable named "last" unless you explicitly assign it to another variable. For example my code is equal to
last = LWLibavVideoSource("Dji ext.mpg")
luma = last.SeparateFields().Trim(1, 0).Weave()
chroma = last.SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
last = luma.MergeChroma(chroma)
return lastNow you can see that original video was lost, since last was rewritten. What you can do is just to write result to another variable.
LWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
v1 = luma.MergeChroma(chroma)
Interleave (v1, last)
Music Fan
5th October 2015, 08:34
Thanks.
In Avisynth each function writes into a variable named "last" until you explicitly assign it to another variable.
I guess you mean another function.
For visual comparisons Interleave function is much better.
But if I really need to see both together, how tu use stack ?
Music Fan
5th October 2015, 09:32
After some tests I found how to make it ;
LWLibavVideoSource("P:\Dji ext.mpg")
v2=LWLibavVideoSource("P:\Dji ext.mpg")#without effect
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
stackhorizontal(last,v2)
If I understand correctly, each line correspond to last, except when the sign = is present ; in this case, this line is not used before to be enabled in another line, as v2 enabled in stackhorizontal(last,v2).
edit : actually there is a strange problem : if I add SeparateFields() after this script to get ;
LWLibavVideoSource("P:\Dji ext.mpg")
v2=LWLibavVideoSource("P:\Dji ext.mpg")#without effect
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
stackhorizontal(last,v2)
SeparateFields()
v2 has a field inversion, while it's supposed to be untouched :confused:
I believed that v2 would act as this script ;
LWLibavVideoSource("P:\Dji ext.mpg")#tff
SeparateFields()
but it's not the case :confused:
I guess it's because last became BFF [with Trim(1, 0).Weave()] and last prevails over v2 which is thus forced to become bff.
edit 2 : the field inversion on v2 disappears when I simply reverse last and v2 in the stackhorizontal line ; stackhorizontal(v2,last) instead of stackhorizontal(last,v2)
vivan
5th October 2015, 11:18
I guess you mean another function.I meant "unless" not "until", sorry. Yeah, that typo changed my explanation into a complete wrong one.
But no, you assign values to variables... Well, they will be objects in C#/Java, but still not functions. They have "clip" type, so lets simly call them clips.
You don't assign functions to anything, you assign their result. But that result is calculated "lazily", only when it's needed.
Just think about it as if clip was just a number.
Another thing to note is that every function uses "last" as first input if no input is specified. Or uses specified clip, if you write it like this: "clip.function()", which is equal to "function(clip)".
So this codeLWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
actually meanslast = LWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields(last)
luma = Trim(luma, 1, 0)
luma = Weave(luma)
chroma = SeparateFields(last)
chroma = SelectEvery(chroma, 2, 1, 0)
chroma = Trim(chroma, 1, 0)
chroma = Weave(chroma)
last = MergeChroma(luma, chroma)
return last
But if I really need to see both together, how tu use stack ?It has same syntax.
UPD:After some tests I found how to make it ;While this works opening video twice is not a "clean" solution. Probably this way it will be easier to modify:
source = LWLibavVideoSource("P:\Dji ext.mpg")
luma = source.SeparateFields().Trim(1, 0).Weave()
chroma = source.SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
result = luma.MergeChroma(chroma)
StackHorizontal(source, result)
I guess it's because last became BFF [with Trim(1, 0).Weave()] and last prevails over v2 which is thus forced to become bff.Yes, after you do Weave() clip becomes BFF.
edit 2 : the field inversion on v2 disappears when I simply reverse last and v2 in the stackhorizontal line ; stackhorizontal(v2,last) instead of stackhorizontal(last,v2)Wiki says thatWeave uses the frame-parity information in the source clip to decide which field to put on top. If it gets it wrong, use ComplementParity beforehand or SwapFields afterwards.Honestly I have no idea how it works.
Music Fan
5th October 2015, 21:07
I meant "unless" not "until", sorry. Yeah, that typo changed my explanation into a complete wrong one.
But no, you assign values to variables... Well, they will be objects in C#/Java, but still not functions. They have "clip" type, so lets simly call them clips.
You don't assign functions to anything, you assign their result. But that result is calculated "lazily", only when it's needed.
Just think about it as if clip was just a number.
Another thing to note is that every function uses "last" as first input if no input is specified. Or uses specified clip, if you write it like this: "clip.function()", which is equal to "function(clip)".
So this codeLWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
actually meanslast = LWLibavVideoSource("Dji ext.mpg")
luma = SeparateFields(last)
luma = Trim(luma, 1, 0)
luma = Weave(luma)
chroma = SeparateFields(last)
chroma = SelectEvery(chroma, 2, 1, 0)
chroma = Trim(chroma, 1, 0)
chroma = Weave(chroma)
last = MergeChroma(luma, chroma)
return last
Woaw, I will have to read it several times to understand it, I'm a little bit confused with this.
While this works opening video twice is not a "clean" solution. Probably this way it will be easier to modify:
source = LWLibavVideoSource("P:\Dji ext.mpg")
luma = source.SeparateFields().Trim(1, 0).Weave()
chroma = source.SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
result = luma.MergeChroma(chroma)
StackHorizontal(source, result)
Actually my script is simpler. The problem with yours is that I can't add easily functions (I like to see them one above the other).
Is there a way to open only 1 time the video and make a script a simple as mine, without result = and without typing source. each time a new line is added ?
Edit : I believe I have found, tell me if it's ok or if it has disadvantages ;
v1=LWLibavVideoSource("P:\Dji ext.mpg")
v2=v1
last=v1
luma = SeparateFields().Trim(1, 0).Weave()
chroma = SeparateFields().SelectEvery(2, 1, 0).Trim(1, 0).Weave()
luma.MergeChroma(chroma)
greyscale()#just to show that functions can be added this way
stackhorizontal(last,v2)#last is black and white, v2 is untouched (except its field order)
Yes, after you do Weave() clip becomes BFF.
Wiki says thatHonestly I have no idea how it works.
There is no problem with weave, the result is logical, I was talking about the order in stackhorizontal.
Here is the explanation, that's what I guessed ;
http://avisynth.nl/index.php/StackHorizontal
Most other information (sound track, frame rate, etc) is taken from the first clip
Which explains why the 2nd clip became BFF (as the 1st) while it was originally TFF.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.