PDA

View Full Version : Still Confused about RGB and YUV


GParent
5th January 2004, 00:04
Hi all,

First: Yup, I read the FAQ and many posts and am still confused.

I have a modest 1.4 GHz PC using:

Windows XP with SP1
Scenealyzer Live! 2.1
Vegas 4
CCE Version 2.67.00.23
Matrox DV Codec

This is my receipe for capturing video and I'm not getting pure YUV in the video processing chain.

(1) VHS tape connected to analog input of Canopus ADVC-100.

(2) Output of Canopus over Firewire into PC.

(3) Scenealyzer Live reads the ADVC-100 video and creates an AVI file, which should have the appearance of a DV capture. I am assuming that I am getting 100% YUV video on that AVI file. Is that correct???

(4) I ended up only using Vegas to snip off the ends of the captured AVI, which I should have done in CCE or TMPGEnc, directly. I thought Vegas would leave the YUV as YUV, when it rendered out as an AVI. I am wondering if Vegas has converted to RGB on the render out.

(5) Using CCE, it seems to me that a test of a sample clip has created two different looking MPEGs, one for Luma 0-255, and the other for Lum 16-235.

If CCE is reading raw YUV video from the captured AVI file, then RGB conversion would not be needed. Therefore, if a difference in the sample exists, it seems that CCE is converting from RGB. Right?

Enough of my ranting. What the heck do I have to do to keep a nice tight Capture to MPEG chain and never have to use RGB conversion?

Thanks,

Gary

jggimi
5th January 2004, 00:34
Moved to DV forum, since your capture occurs externally, and your input method is DV.

bb
5th January 2004, 09:27
GParent,

in your conversion chain Vegas appears to use RGB internally. But as soon as you render the video to a DV AVI again, you should have the YUV colorspace back. Which codec did you use for Vegas output?

The luma range can be affected in several steps. I suggest you use AviSynth's histogram functionality to test the luma range in the various conversion steps.

bb

SomeJoe
5th January 2004, 17:23
Well, let's make sure we understand what we mean by YUV.

DV is stored internally as a compressed form of YUV. The luminance and downsampled chrominance samples are compressed with the DV codec, which is an intraframe DCT-based compression.

Now, what you are seeking is a processing chain that never has to do color conversions between YUV color space and RGB color space. This would be very nice, as some clarity and detail is lost when doing those color conversions.

But the YUV you're speaking of is not the same as what exists in the DV file. When a program (like Vegas or CCE) requests a frame from your .avi, the codec is responsible for handing that application an uncompressed frame. The DV codec needs to access a compressed, chroma-downsampled (4:1:1 or 4:2:0) frame from the .avi, and hand back to the application an uncompressed frame.

This uncompressed frame can be one of the uncompressed YUV formats (YUY2, YV12) if the codec supports that type of handoff. But most DV codecs don't. They typically will only hand off an RGB frame. One of the reasons for this is that most of the uncompressed YUV formats are still chroma-downsampled. This wreaks havoc if you're trying to do certain transitions or effects in an editor like Premiere or Vegas where full chroma resolution is needed.

Another problem is that many applications will not work internally in YUV colorspace. Such as Vegas. When Vegas wants to edit (do a cross-dissolve, transition, effect, etc.) it wants to process RGB frames. Even if the DV codec supports YUV handoff, Vegas will specifically open the .avi using RGB handoff. So will Premiere. Only Premiere Pro will process internally in YUV, and only if the timeline codec supports it, and probably only for certain simpler types of processing.

CCE will support input from the codec in YUV format, but again, only if the codec supports it.

Bottom line is, there is a very narrow set of circumstances where you can completely avoid RGB color conversion. You need a DV codec that supports YUV handoff, and all applications dealing with the file must be able to process internally in YUV.

GParent
5th January 2004, 21:14
Vegas uses its proprietary DV Codec, refered to as SoFo Codec. Some say its from Main Concept and others say Sonic Foundry (now Sony) did it themselves. Essentially, you have control over what Codec that Vegas uses internally. If you check "IGNORE THIRD PARTY DV CODECS" and uncheck "USE MICROSOFT DV CODEC" it will use its own. However, the SoFo Codec is invisible. Let me repeat, the Vegas Codec is transparent and not exposed to the external world outside of Vegas. What Vegas renders will later be decompressed by the default 'dvsd' Codec. In my case, 'dvsd' is MATROX. Matrox will do both YUV and RGB, from what I understand.

Since my captures are very straight forward, Im aiming to tighten the loop.

STEP 1: Scenalyzer Live to Capture. Under options, I have set TYPE 2 DV AVI file (Premiere, etc.).

My other option is the Canopus Compatible DV file. I am sticking with the Type 2 DV AVI ('dvsd'). Since Canopus ADVC-100 created the DV video I am capturing, I have no explanation why I am avoiding it.


STEP 2: NO VEGAS. I'll go right into CCE to create the MPEG-2. If the Matrox Codec really does handle YUV, can I assume that the RGB Luma sttings will be ignored by CCE.

NOTE: If I were converting to YUV using an AVISYNTH script, then CCE would ignore the RGB Luma settings. Right? If so, why can't CCE do the same for raw YUV directly out of the capture file???

Again, I am in the process of experimenting with some samples but I wanted to get the advice here before proceeding.

Gary

bb
6th January 2004, 12:37
Originally posted by GParent
NOTE: If I were converting to YUV using an AVISYNTH script, then CCE would ignore the RGB Luma settings. Right? If so, why can't CCE do the same for raw YUV directly out of the capture file???
I see no necessity to use the ConvertYUY2() command in AviSynth for DV sources. AviSynth will open the DV file in YUV color space and hand it over to CCE without any colorspace conversion commands (at least this is true for PAL sources; I'm not sure about NTSC). You can even use YUV based filtering in AviSynth without introducing colorspace conversions.

bb

bsr
21st May 2004, 20:50
Originally posted by bb
I see no necessity to use the ConvertYUY2() command in AviSynth for DV sources. bb
I have to use this in my AVS script if I want to use Convolution3D filter. Do you think this is because I installed the Panasonic DV codec and with AVIsource it brings it into AVISYNTH as RGB24?

If I use Directshowsource instead of AVIsource my avs script does output YUY2. But don't know the advantages/disadvantages of each. Think Directshowsource was a lot slower on my computer.

I'll try disableing the Panasonic DV codec this weekend(Vcswap does this I think) and see if AVIsource will output YUY2.

Thanks for the informative thread. I've done a lot of searching and a lot of reading and this RGB and YUY stuff is starting to make a little sense to me now.

bb
21st May 2004, 22:42
The Panasonic DV codec outputs RGB indeed. The conversion to YUY2 is necessary in this case, but takes time. So if you want to keep the VfW way with AviSource, then you may consider to install another DV codec, e.g. MainConcept or Canopus (remember that Canopus uses a different fourCC).

DirectShowSource should not be slower than AviSource. Make sure you use the latest AviSynth version - there were several improvements in the DirectShow area.

bb

bsr
24th May 2004, 17:32
Used VCSwap to disable the Panasonic DV codec.
Now I get an error that AVIsource doesn't have a dvsd decoder to read the AVI file. But I could swear it worked before I installed the Panasonic DV codec?
Will try downloading the Free Canapus and change the FourCC to see if that works. I do have AVISynth 2.54.
Thanks for the help.

bb
24th May 2004, 23:17
So you must have had another DV codec (or at least a decoder), which was set to handle dvsd. E.g. ffdshow is capable of decoding DV (even in VfW mode).

bb

bsr
25th May 2004, 03:28
Tried the canapus decoder, it worked and gave a colorspace Output of YUY2 on my script.
FFDSHOW worked also and gave an output of YV12 on my script unless I disabled the YV12 in the Decoder/Output settings, then it outputed YUY2.
What would be the preference Canapus or FFDshow decoder? Can't say I've used either in the past.

If my capture is from a Sony DV cam DCR-PC101, is the native colorspace YUY2 or YV12?:confused:

Wonder if my Sony Cam installed a DV codec that was disabled and lost when I installed the Panasonic DV codec.:eek:

I've always had great results using VDUB filters with TMPGenc. But did some reading and wanted to try out AVISYNTH and CCE for speed and less colorspace conversions.
Ohh well, time to play around and do some testing.:)

bb
25th May 2004, 12:38
Your Sony DV codec must have been disabled when the Panasonic codec was registered to the same fourCC (there's only one codec per fourCC). It should be possible to re-register it again (don't ask me how :) ).

Colorspace: DV is YUV 4:2:0 for PAL and YUV 4:1:1 for NTSC.

bb