This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] AviSynth 32 bit - ColorMatrix filter not working for video?
#11
Big Grin 
Me too, lol.

There is a workaround for what I want it to do, so maybe leave it alone for now? lol Undecided
Reply
#12
send you another link via PM for testing Smile

Cu Selur
Reply
#13
Smile 
It works! Big Grin
Reply
#14
SORRY BUT...  Blush Undecided

There is still a problem! Hopefully easy to fix...

If I load an image sequence with bt709 selected, like this:

[Image: YiZ24JH.png]

And I do a color matrix to go from 709 -> 601, I get a wrong Avisynth script:

[Image: tjdjc74.png]

I believe that the highlighted line should read: ConvertToYUY2(interlaced=false, matrix="Rec709")


The Rec601 gives wrong colors. Confused

I tried a custom script and it gives correct colors:

LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ColorMatrix.dll")
ConvertToYUY2(interlaced=false, matrix="Rec709")
ColorMatrix(mode="Rec.709->Rec.601",clamp=3,interlaced=false,hints=false)


This is all because I'm using Topaz Video Enhance AI and outputting to 8 bit png. For DVD, it shifts the color palette. Using ColorMatrix Rec.709->Rec.601 fixes it. But not when ConvertToYUY2 has matrix set to Rec601. Undecided
Reply
#15
I see the problem, happens since the ConvertToYUY2 is inserted before the ColorMatrix, but assumes the 'out matrix' of the ColorMatrix to be the correct matrix.
-> will fix
Reply
#16
I feel terrible bumping this, but, it's still not fixed. It's the problem that wants to keep coming back to induce maximum headaches and annoyance! Tongue

I haven't had time to test it until now, so sorry about that.

Using Hybrid Dev version 2020.10.28.1.

So, the problem now, is that enabling Color Matrix and going from Rec.709 to Rec.601 has no effect (ignore the preview error message):

[Image: HToF7KR.gif]


Here's the previewer script:

ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ImageSeq.dll")
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ColorMatrix.dll")
# loading source: E:/USER/Test/Test-AdobeRGB.png
#  color sampling RGB24@8, matrix: bt709, scantyp: progressive, luminance scale: limited
ImageReader(file="E:\USER\Test\Test-AdobeRGB.png", end=100, fps=23.976, use_DeviL=true, pixel_type="RGB24")
# current resolution: 1440x1080
ConvertToYUY2(interlaced=false, matrix="Rec709")
# color modifications
ColorMatrix(mode="Rec.709->Rec.601",clamp=3,interlaced=false,hints=false)
# filtering
# adjust color to RGB32 (color matrix: Rec601)
ConvertToRGB32(matrix="Rec601")
PreFetch(4)
# setting output fps to 23.976fps
AssumeFPS(24000,1001)
#  output: color sampling RGB32@8, matrix: Rec.601, scantyp: progressive, luminance scale: limited
return last


And here's a debug file (toggled ColorMatrix filter off and on several times at the end):

Edit - Check the log files in the below post; the HybridDebugOutput_1028_NoChange.zip is for the above issue.



Also, I checked, and the workaround I posted above doesn't work here... it has no effect. Although that workaround was for mp4 files, not image streams.



I said above that this custom script gives correct colors in Hybrid 2020.10.20.1 for image streams:

LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ColorMatrix.dll")
ConvertToYUY2(interlaced=false, matrix="Rec709")
ColorMatrix(mode="Rec.709->Rec.601",clamp=3,interlaced=false,hints=false)

But I'm trying it again in Hybrid 2020.10.20.1 and now that also has no effect? WTF?
Reply
#17
It appears that I mislead you when I said that ConvertToYUY2(interlaced=false, matrix="Rec601") should be ConvertToYUY2(interlaced=false, matrix="Rec709"). I said I tested it via custom script, but now I'm not getting the same result when I do that, even in the 2020.10.20.1 version... it does nothing! WTH!

Hybrid 2020.10.17.1 and 2020.10.20.1 have the same script pretty much, but they product very different results. Comparing to source material (not for this particular test image), I can tell you that Hybrid 2020.10.17.1 is the "correct" result, in that it matches my source material that was converted to 709 by another program, then output RGB24 png's (Topaz Video Enhance AI). The Hybrid 2020.10.20.1 result is WAY off. And, the Hybrid 2020.10.28.1 result doesn't do anything. (Right now I'm working with RGB24 png's so I haven't tested mp4 input.)

Here's four frame GIF, first frame is no filters, second is ColorMatrix 709->601 in Hybrid 2020.10.17.1, third is ColorMatrix 709->601 in Hybrid 2020.10.20.1, and fourth is ColorMatrix 709->601 in Hybrid 2020.10.28.1 ("Open image in new tab" should give full size):

[Image: UgapREg.gif]


Here are debug files for each version, for each frame of the above gif:

[attachment=1114]

[attachment=1115]

[attachment=1116]


I can't imagine how much of a headache I must be causing you with this. I understand if this is something you want to "put on the back burner" for a while.

Again, this is with images... this whole thread started because I when I tried to get 2020.10.17.1 to work with mp4 files, it didn't work for me. So another part of the challenge here is to get this to work correctly with *both* image streams and video streams.

And I also haven't even checked this in VapourSynth. Tongue
Reply
#18
The scripts do not really help since those are not the preview, but the encoding scripts.
Looking at the debug output for the preview scripts:
Correct:
ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ImageSeq.dll")
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ColorMatrix.dll")
# loading source: E:/USER/Test/Test-AdobeRGB.png
#  color sampling RGB32@8, matrix: bt709, scantyp: progressive, luminance scale: limited
ImageReader(file="E:\USER\Test\Test-AdobeRGB.png", end=100, fps=23.976, use_DeviL=true, pixel_type="RGB24")
# current resolution: 1440x1080
ConvertToYUY2(interlaced=false, matrix="Rec601") # <- this is wrong
# color modifications
ColorMatrix(mode="Rec.709->Rec.601",interlaced=false,hints=false)
# filtering
# adjust color to RGB32
ConvertToRGB32(matrix="Rec601")
PreFetch(4)
return last
1020_InCorrect:
ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ImageSeq.dll")
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ColorMatrix.dll")
# loading source: E:/USER/Test/Test-AdobeRGB.png
#  color sampling RGB32@8, matrix: bt709, scantyp: progressive, luminance scale: limited
ImageReader(file="E:\USER\Test\Test-AdobeRGB.png", end=100, fps=23.976, use_DeviL=true, pixel_type="RGB24")
# current resolution: 1440x1080
ConvertToYUY2(interlaced=false, matrix="Rec601")
# color modifications
ColorMatrix(mode="Rec.709->Rec.601",clamp=3,interlaced=false,hints=false)
# filtering
# adjust color to RGB32
ConvertToRGB32(matrix="Rec709") # <- this should be 601 for normal Preview and 709 only for FilterPreview
PreFetch(4)

1028_Incorrect:
ClearAutoloadDirs()
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ImageSeq.dll")
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ColorMatrix.dll")
# loading source: E:/USER/Test/Test-AdobeRGB.png
#  color sampling RGB24@8, matrix: bt709, scantyp: progressive, luminance scale: limited
ImageReader(file="E:\USER\Test\Test-AdobeRGB.png", end=100, fps=23.976, use_DeviL=true, pixel_type="RGB24")
# current resolution: 1440x1080
ConvertToYUY2(interlaced=false, matrix="Rec709") # <- correct
# color modifications
ColorMatrix(mode="Rec.709->Rec.601",clamp=3,interlaced=false,hints=false)
# filtering
# adjust color to RGB32 (color matrix: Rec601)
ConvertToRGB32(matrix="Rec601") # <- correct for preview
PreFetch(4)
# setting output fps to 23.976fps
AssumeFPS(24000,1001)
#  output: color sampling RGB32@8, matrix: Rec.601, scantyp: progressive, luminance scale: limited
return last

I have no clue why you would say that 1028 is correct in how it handles the source.
Source is specified as " RGB24@8 " with color matrix " bt709 ".
Hybrid converts to " YUY2 " with " Rec709 ".
Then it applies " ColorMatrix(mode="Rec.709->Rec.601",clamp=3,interlaced=false,hints=false) "
and converts to " RGB32 " for the preview using " ConvertToRGB32(matrix="Rec601") "

-> if you can tell me where Hybrid goes wrong I can adjust it, but to me the handling seems correct.
(Assuming the source is really color sampling RGB32@8, matrix: bt709, scantyp: progressive, luminance scale: limited.)

Cu Selur

Ps.: "And I also haven't even checked this in VapourSynth." me neither Wink
Reply
#19
(02.11.2020, 17:46)Selur Wrote: I have no clue why you would say that 1028 is correct in how it handles the source.

10.17 is correct in the previewer, in that original  source is 601, then processed with another program, which generated an image stream with a shifted color palette. This image stream is the source that is input into Hybrid. Running ColorMatrix 709->601 in Hybrid 10.17 shows in the previewer that the color palette of the result matches the color palette of the original  source; in other words, the source before it was processed with the other program, not the source that was input to Hybrid. That's the point of running the filter in Hybrid... to undo the color palette shift of the other program.

But I only looked at the previewer in the above testings, not the actual mp4 output generated by Hybrid.

Although 10.17 looks correct to the original source in the previewer, on generating a mp4, it didn't do anything. The color palette stayed the same as what was input into Hybrid.

I didn't check 10.20.

In Hybrid 10.28, it shows in the previewer no change when ColorMatrix 709->601 is enabled, and the generated mp4 shows no change either, so I guess in 10.28 at least the previewer is correct. Tongue

I guess I'm going to have to generate a lossless encode from the image stream, then run color matrix on that, since ColorMatrix seems to not want to work on image streams. Undecided



I just checked, and Hybrid 10.28 doesn't do anything with mp4 input either, when running 32-bit Avisynth ColorMatrix 709->601.

So maybe let's take a step back and just look at Hybrid 10.28: the ColorMatrix filter is not working at all.


Here's the image input file again, and a lossless mp4 file of the same image file.
[attachment=1118]
[attachment=1119]


And here are logs of running Hybrid on the image stream, and on the mp4 file:
[attachment=1120]
[attachment=1121]


The color palette stays the same, both in the previewer, and in the output mp4 file. The ColorMatrix 709->601 32-bit Avisynth filter didn't do anything.
Reply
#20
I tried to test with VapourSynth, and didn't get very far... it appears image stream input for VapourSynth is completely broken in Hybrid 2020.10.28.1. It throws an error even when trying to display the script (tried with both PC and TV luma ranges and bt709 color matrix):

[Image: sv6gAlp.png]

[attachment=1122]



OK, I checked the mp4 output in Hybrid 2020.10.20.1, for 32-bit AviSynth ColorMatrix 709->601. It works, and is correct.

SO, in Hybrid 2020.10.20.1, when running 32-bit AviSynth ColorMatrix 709->601:

- Wrong color palette in previewer
- Correct color palette in mp4 output

[Image: uj5WBDI.gif]


In Hybrid 2020.10.28.1, there is no change in the color palette at all, in either the previewer, or mp4 output, for 32-bit AviSynth ColorMatrix 709->601.


Here is a log for Hybrid 2020.10.20.1 for mp4 output, with the 32-bit AviSynth ColorMatrix 709->601 filter:
[attachment=1123]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)