Log in

View Full Version : Avisynth+ and matching color format


hello_hello
1st September 2019, 16:10
For classic Avisynth it's fairly easy to convert a video to the same format as another, or to convert a video back to it's original format. Something like this (ignoring any possible matrix mismatch if the original/intermediate format is RGB):

Color_Format = SourceVideo.PixelType()

# Video is converted to another format by SomeFunction()
New_Video = SourceVideo.SomeFunction()

# Conversion back to the original format
New_Video.Eval("ConvertTo"+Color_Format+"()")

Does Avisynth+ offer a similar level of simplicity I've missed? I realise there's bitdepth to consider too, but for PixelType() Avisynth+ returns format names such as YUV420P10 for bitdepths greater than 8, which can't be used the same way.

The closest I have to a cunning plan at the moment is to

- get the original bitdepth
- create a temporary video converted to 8 bit
- get PixelType() after the 8 bit conversion, which seems to result in "traditional" format names such as YV24
- convert the video to the original bitdepth, then convert to the original color format using the "traditional" name (maybe doing it in the reverse order might be better?).

Would I be missing much using the above method?

Cheers.

DJATOM
1st September 2019, 17:06
I don't see a point of doing such conversions. Anyway you can check if your video is YUV420/422/444 (http://avisynth.nl/index.php/Clip_properties) and decide howto process it based on that.

hello_hello
1st September 2019, 18:59
It's for a function that may use a plugin requiring a YV24 input and it outputs YV24. If the bitdepth is greater than 8 bit, it converts to 16 bit as required and outputs 16 bit. I want the function to always output video in the same format as it went in, hence the need to automatically convert it back the the original format, no matter what it was.

I've since remembered Raffriff42's Avisynth+ utilities collection (http://avisynth.nl/images/Utils-r41.avsi) has a function called MatchColorFormat() that does the job, but it seems to me like something it should be easy to do with Avisynth itself.