Log in

View Full Version : Colorspace


raziel666
7th September 2006, 11:44
Hi
Is there some tool to determine the colorspace of a video so as to put the right argument to the AVISource() pixel_type option? Thx a lot.

drcl
7th September 2006, 14:08
not sure what you mean.

The pixel_type parameter allows you to choose the output format of the decompressor. ie to force an alternative

huffyuv codec will normally decompress to YUY2, but if you were to use

AVISource("huffy_example.avi",pixel_type="RGB32")

then avisynth will request the huffyuv codec to deliver data in RGB32 format.

raziel666
7th September 2006, 14:44
I mean that some videos are encoded in RGB24, RGB32 or YV12 (among others). I have noticed that whenever I use the avisource in an avs script, via the info() function it says decompressor : YV12. Something like the default. So I would like to know, if I can determine what colorspace the video is (for example, x264 colorspace is always YV12), so as to tell avisynth to decompress it that way.

actionman133
7th September 2006, 17:48
Well, you're probably seeing YV12 all the time, because it's a common colorspace for today's codecs. MPEG-1 (VCD), MPEG-2 (DVD and HDTV) and MPEG-4 (DivX, Xvid, H.264, etc) are all encoded in YV12.

HuffYUV is one of the few that I'm aware of in common use that isn't YV12. If a HuffYUV video *also* returns as YV12, then you've got a problem. If it returns YUY2, then it's fine. You're just getting YV12 all the time because all of your clips are YV12-based.

Generally, AVISource () will output the closest matching colorspace. If it needs to convert, it will, but it won't convert RGB32 to YV12 or anything like that (unless you specifically tell it to).

drcl
7th September 2006, 17:51
almost all end user formats are in yv12.

so they will be decoded as such as its most accurate and efficient.

You or whoever produces the file may give rgb24 or whatever data to an encoder but it will be converted to yv12 on those codecs.

yv12 is not the default. yv12 wasnt even a feature of avisynth until version 2.5.

If you feed a HUFFYUV file then you will get yuy2 from info().

One other explaination is that you are using ffvfw/ffdshow to decode VFW.

IanB
8th September 2006, 02:04
The Pixel_type argument on AviSource() enforces the pixel format request passed to the codec.

Without the argument Avisynth 1st requests YV12 then if that fails it requests YUY2 then RGB32 and finally RGB24. So if a given codec is capable of returning YV12 then that is the default format that will be returned.

Note this has nothing to do with the pixel format used by the codec to actually store the data internally. In the VFW API set there is no way to interogate for this information. A human has to make the choice of decoded pixel format based on some external information (i.e experience or standards documentation).

Most modern video compression codec writers seem to favour a YV12 like data encoding. There are exceptions like NTSC DV which uses a 4:1:1 scheme, so it might make sense to request YUY2 here to minimise lose of vertical chromance resolution.

:Hint: Search the forums for "avisource YV12 YUY2 RGB32 RGB24" for many previous posts on this subject.