PDA

View Full Version : Colorspace (and FourCC) detection?


Cyberia
9th June 2004, 21:51
Is there an easy way to have AviSynth report the colorspace of an clip? I know I can use the Info() filter, but displaying it onscreen in the video doesn't help me.

I am querying AviSynth on files using the AVISTREAMINFO API. Is the colorspace listed here somewhere and I'm not seeing it?

Cyberia
9th June 2004, 22:04
After reading my post, I wasn't very clear. Perhaps a better way to ask is this: I want to query AviSynth via an external program and get back the colorspace of the loaded clip. The simpler the better.

scharfis_brain
9th June 2004, 23:49
read the AVISynth - DOcumentation

especially the part: "Clip Properties"

Cyberia
10th June 2004, 14:57
You mean IsYUV(), IsYV12? ...(etc)

I am having a hard time conceptualizing what I need to do with these. Could you give me an example? How/where does the value get returned?

Maybe I should not be scripting this? Instead invoke avisynth.dll calling the IsYUV() function and get a boolean back?

Bidoche
10th June 2004, 15:17
@Cyberia

one of the methods of the vfw IAVIStream interface (ReadFormat ?)
allows to fill a BITMAPINFOHEADER struct.

Then you can use its biCompression and biBitCount members to deduce ColorSpace of outputted clip.
(check msdn for more details)

Cyberia
12th June 2004, 01:19
@Bidoche - THANK YOU! This is EXACTLY what I was looking for! Zip-zop! Works like a charm.

FYI: You only need biBitCount to determine the colorspace. I'm not sure what the biCompression member is for. I suspect this returns the FourCC code if I reverse it and convert to ASCII?

I will post sample code (in VB nonetheless) in the near future.

Cyberia
15th June 2004, 17:58
Ok I can get the biCompression field and perform the magic on it to get the actual FourCC code. However, I am not seeing any 4CC on AVI files opened with AviSynth.

If I query the original AVI file with the API call, I get a valid 4CC back. But I always get a 4CC of zero through AviSynth.

Shouldn't AviSynth pass on the original video 4CC code?

Bidoche
15th June 2004, 18:09
Avisynth fills the BiCompression field correctly:

ie BI_DIB for RGB24 and RGB32, and the 4CC for YUY2 and YV12


Shouldn't AviSynth pass on the original video 4CC code?NO, you get uncompressed data through Avisynth so 4CC is different

stickboy
15th June 2004, 18:20
Originally posted by Cyberia:
Shouldn't AviSynth pass on the original video 4CC code?
After AviSynth opens a file, it outputs uncompressed frames. Why do you need to know what its original fourCC value was?

What should happen if you open multiple videos with a script that each has a different fourCC?

Cyberia
15th June 2004, 18:44
Querying the AVI directly, I get a 4CC => "XVID", "DIV3", etc...
I understand this part, but through AviSynth, I get these FourCC values:

RGB24 => 4CC = 0
RGB32 => 4CC = 0
YUV2 => 4CC = 844715353 => "YUV2"
YV12 => 4CC = 842094169 => "YV12"

Should the RGBs return zero?

Cyberia
15th June 2004, 18:49
Originally posted by stickboy
After AviSynth opens a file, it outputs uncompressed frames. Why do you need to know what its original fourCC value was?

Because I want to know what was used to compress the original file without opening VDub and selecting 'File Information'. I also want to be able to tell how AviSynth choose to decompress the video.

What should happen if you open multiple videos with a script that each has a different fourCC?

Yea, ok, thats a good question. You got me there.

Cyberia
15th June 2004, 22:16
Originally posted by Bidoche
Avisynth fills the BiCompression field correctly:

ie BI_DIB for RGB24 and RGB32, and the 4CC for YUY2 and YV12

I'm directly checking the structs now, and it appears AviSynth is NOT populating the biCompression field of the BITMAPINFOHEADER struct correctly.

However, the fccHandler field of the TAVISTREAMINFO struct is populated just like you say Bidoche.

stickboy
16th June 2004, 05:40
Originally posted by Cyberia
Should the RGBs return zero?Yes. Uncompressed RGB should have a fourCC value that corresponds to BI_RGB, which should be defined as 0.

Cyberia
17th June 2004, 20:46
Gotcha, all is good then. Thanks.

Now if someone could only tell me why AVIREADFORMAT doesn't work for Xvid AVIs? But I made a thread for that in the XviD forum....

Cyberia
18th June 2004, 03:26
I have posted a sample VB6 program that returns AVI (or AVS) resolution, frame count, frate rate, colorspace and fourCC code.

The program is available here. (http://home.insightbb.com/~cyberia-1/ASI/AVI-Info.rar)

esby
23rd June 2004, 11:18
What should happen if you open multiple videos with a script that each has a different fourCC
just to answer this weird question :)

If you are supposed to pass the fourCC, depending which strategy is used, you'll get or:
- the f4cc of the first file 'loaded'
- the f4cc of the last file 'loaded'
- f4cc decision overrides by the filter chain, if this one is transmitted via it...
in all cases, you'll get only one f4cc in the end of the filterchain,
meaning if the assembled clips are not compatibles you'll get borked result in the beginning, ending, some part or the whole video... (actually dsynth may go for the second case, load order being determined by the filterchain constructor call)...


esby

DoC hEx
25th June 2004, 07:35
Hi Cyberia,

Have you ever tried to get a Frame from an AVS file using VB6? As I'm trying to update an old program I had for getting frames from MPEG2Dec2.dll. (I've posted the code in the Development section) But I'm looking to update this code to pull in frames direct from an AVS script as this would be more useful in the long run.

Cheers,
dOc Hx

esby
25th June 2004, 14:28
@DoC hEx:
Read the vfw api & avifile documentation maybe?

Avs files are handled exactly like avi files, in avifile compatibility mode... (which sounds so normal^^;)

avs2.5 can be compiled with vc 6.2...
avs2avi can be compiled with vc 6.2 too, if you convert the project file...
old version of vdub can be compiled with vc 6.2 too ...

so if you need concrete example, you know where to search...

esby

Cyberia
25th June 2004, 22:24
Originally posted by DoC hEx
Hi Cyberia,

Have you ever tried to get a Frame from an AVS file using VB6? As I'm trying to update an old program I had for getting frames from MPEG2Dec2.dll. (I've posted the code in the Development section) But I'm looking to update this code to pull in frames direct from an AVS script as this would be more useful in the long run.

Hi! No I haven't (yet). I am going to try an do this sometime this year, but at the moment I am just passing the AVS script to a Mediaplayer OCX control. It's not the best solution, but it saves me from having to reinvent the wheel. If only someone would fix seeking in audio-less AVS scripts in WMP9..... (when WMP9 CAN seek in the audio-less source AVI)

Being able to pull frames from AviSynth would be great, especially because you can get frames from other sources (AVISource, DSSource) but there are times, especially with MPEG2DEC that you want to see the raw frames (before AviSynth) so don't lose that ability.

I will definately look at your code.