View Full Version : mpeg 2 colorspace
j2k
4th January 2006, 19:09
if video is originally DV (YUY2 i'm assuming), then edited in premiere which I believe only does RGB, less the huffyuv codec. So should I export my edited DV using huffyuv in YUY2? The reason I ask is the newly created avi (with huffyuv codec) will then be fed via avisnyth into CCE to create an mpeg2 for use in authoring a DVD. So my mpeg2 will have to be in YUY2 as well, but shouldn't an mpeg2 for dvd be in YV12?
The reason i'm using huffyuv instead of actually just exporting in DV is that a lot of my video has been composited in AfterEffects and recompressing often in DV is frowned upon, but huffyuv should allow me to export clips to other programs, do my compositing, then export again using huffyuv back to premeire for further editing.
If i'm using CCE, is there no way to use YV12 or am I ok using the YUY2?
communist
4th January 2006, 21:48
DV is stored as YV12 regardless of what some decoder spit out.
Editing in Premiere is like using DirectStreamCopy in VirtualDub = no conversion / loss.
Any kind of filtering that takes place in Premiere / After Effects is done in RGB colorspace (-> YV12 -> RGB -> YV12).
MPEG on DVD is YV12 aswell.
CCE just doesnt accept YV12 AFAIK. This is a limitation of this encoder.
Since you're doing lots of compositing etc. you're best of to use a lossless codec in which you render / composite before outputting the final stream.This will not degrade quality each time you render something (as it would happen with a lossy - DV for ex. - codec).
In other words you're on the right way :)
zambelli
4th January 2006, 23:55
The only downside to using HuffYUV in Premiere is the color space conversion. Because Premiere does all the processing in RGB space, you're looking at a YUY2 to RGB conversion and then an additional RGB to YUY2 conversion on export back to HuffYUV.
So your color conversion pipeline might end up looking something like this:
YV12 (DV) --> YUY2 (HFYU) --> RGB (Premiere) --> YUY2 (HFYU) --> YV12 (MPEG or DV)
However, HuffYUV is also capable of compressing and storing RGB video. You could take out one of these steps by converting YV12 to RGB yourself in Avisynth and saving as HuffYUV RGB (make sure "Convert to YUY2" isn't enabled for RGB mode in HuffYUV settings). Then your pipeline would look like this:
YV12 (DV) --> RGB (Avisynth, HFYU) --> RGB (Premiere) --> RGB (HFYU) --> YV12 (DV or MPEG)
j2k
6th January 2006, 19:25
Thanks a lot, both posts are great. So if my final state is dvd, would it be best to convert it to RGB in avisynth, then do all of my work (editing/compositing in RGB lossless codec) then should i convert to YUY2 in avisynth while encoding to mpeg2 in CCE, or just leave it in RGB.
In other words, if my choices are RGB or YUY2 for going on a DVD, is one prefered?
communist
6th January 2006, 20:27
IMHO "best" would be to use lossless RGB codec and do all the work there, then ConvertToYUY2 (via AviSynth) and encode with CCE.
stickboy
9th January 2006, 12:17
DV is stored as YV12 regardless of what some decoder spit out.NTSC DV is not YV12. PAL DV uses 4:2:0 subsampling, but NTSC DV uses 4:1:1.
raquete
9th January 2006, 13:02
IMHO "best" would be to use lossless RGB codec and do all the work there, then ConvertToYUY2 (via AviSynth) and encode with CCE. :goodpost:
can you help me please?
have something wrong in my system and i can't explain this differences: :o
script in vdubmod:
colorbars(720,480) #uncompressed RGB32
http://img460.imageshack.us/img460/388/14zm.th.png (http://img460.imageshack.us/my.php?image=14zm.png)
and with this script:
colorbars(720,480) #uncompressed RGB32
converttoYUY2() #YUV 4:2:2 (YUY2)
http://img460.imageshack.us/img460/3848/29go.th.png (http://img460.imageshack.us/my.php?image=29go.png)
the green and all dependents colors(yellow,cyan,white,etc)lose the intensity.see the line between green/magenta...the hue/luminance decrease too,this differences between color appear in the cce encodes too, all colors are changing comparing with sources(dvds).
i'm using avisynth256 but happen the same with 254 and 255!
what can be wrong in my system? :(
thanks and excuse if my post is OT here.
edit- corrections in url of screenshot
communist
9th January 2006, 13:09
Both links go to one same screenshot?!
NTSC DV is not YV12. PAL DV uses 4:2:0 subsampling, but NTSC DV uses 4:1:1.
Right. But
4:2:0 = YV12
4:1:1 = ?
raquete
9th January 2006, 13:13
Both links go to one same screenshot?!
shame on me.corrected the links to screenshots!
thanks!
communist
9th January 2006, 13:36
Looks alright and is totally normal. RGB is a different colorspace than YUV and in this example YUV with downsampled chroma. The chroma in YUY2 (4:2:2) has 1/2 the resolution than the Luma.
You might wanna read up on this http://www.avisynth.org/Section+3%3A+Filters%2C+plugins+and+colorspaces#q3.1
Wilbert
9th January 2006, 16:45
@raquete,
Also note that colorbars(720,480) #uncompressed RGB32 [16,235] (see docs).
This implies that
colorbars(720,480) # RGB [16,235]
ConvertToYUY2(matrix="PC.601") # RGB [16,235] -> YUV [16,235]
and
colorbars(720,480,pixel_type="yuy2") # YUV [16,235]
give identical results (except for the sampling as communist points out).
raquete
10th January 2006, 15:03
@ communist
thank you for explanations and the link! :goodpost: again!
@ Wilbert
colorbars(720,480,pixel_type="yuy2") # YUV [16,235]encrease the brightness/luma,saturation in all colors and the white with strong solarization...
(i can't open imageshack to post the screenshot now,later i post).
help me more if possible because all encodes with cce and hc give me wrong results in the colors. :o i really trust that have something wrong in my system.
thank you! :)
raquete
10th January 2006, 17:17
@ Wilbert
the last 2 pictures:
colorbars(720,480) #uncompressed RGB32
http://img460.imageshack.us/img460/388/14zm.th.png (http://img460.imageshack.us/my.php?image=14zm.png)
colorbars(720,480) #uncompressed RGB32
converttoYUY2() #YUV 4:2:2 (YUY2)
http://img460.imageshack.us/img460/3848/29go.th.png (http://img460.imageshack.us/my.php?image=29go.png)
and the new colorbars(720,480,pixel_type="yuy2") # YUV [16,235]
http://img393.imageshack.us/img393/7141/38hx.th.png (http://img393.imageshack.us/my.php?image=38hx.png)
thanks!
Wilbert
10th January 2006, 21:58
Please describe exactly how you made the screenshots, which mpeg-2 encoder you used, which avs version you used, etc ...
raquete
10th January 2006, 22:19
#colorbars(720,480) #uncompressed RGB32
#converttoYUY2() #YUV 4:2:2 (YUY2)
colorbars(720,480,pixel_type="yuy2") # YUV [16,235]
loading this "script" in vdubmod-copy source to clipboard-paint-save as .bmp-hosting!
but...all encodes with cce and hc give me wrong results in the colors.
thanks!
[edit]avisynth 256(last new and have the same results with 254 and 255.was posted.and using last xvid too)
Wilbert
10th January 2006, 23:07
Please reread post http://forum.doom9.org/showthread.php?p=765028#post765028
colorbars(720,480) # RGB [16,235]
ConvertToYUY2(matrix="PC.601") # RGB [16,235] -> YUV [16,235]
is different from
colorbars(720,480) # RGB [16,235]
ConvertToYUY2() # RGB [0,255] -> YUV [16,235]
Make a screenshot of the first script and tell me whether it is different from the second screenshot you posted above.
raquete
10th January 2006, 23:27
Make a screenshot of the first script and tell me whether it is different from the second screenshot you posted above.now i have 4 differents screenshots,no one is equal! :p
open the last 3 :
http://img460.imageshack.us/img460/388/14zm.png
http://img460.imageshack.us/img460/3848/29go.png
http://img393.imageshack.us/img393/7141/38hx.png
and the last(with too much bright/luma and the same "issue" between magenta/green like scrennshot 2 ):
colorbars(720,480) # RGB [16,235]
ConvertToYUY2(matrix="PC.601") # RGB [16,235] -> YUV [16,235]
http://img10.imageshack.us/img10/4065/40be.th.png (http://img10.imageshack.us/my.php?image=40be.png)
or here http://img10.imageshack.us/img10/4065/40be.png
thanks!
Wilbert
11th January 2006, 00:02
The magenta/green issue is due to the sampling (sharing horizontal chroma) of YUY2.
Your third and fourth picture is the same (apart from the issue above which shouldn't be visible here, i will look at this), as they should. Your first and second picture is the same (as they should), but different as the first two.
The reason is the luma range:
first pic: RGB [16,235]
second pic: RGB [16,235] (conversion to RGB done by VDub)
third pic: RGB [0,255]
fourth pic: RGB [0,255]
I hope it's clear now :)
raquete
11th January 2006, 02:16
Your third and fourth picture is the same (apart from the issue above which shouldn't be visible here, i will look at this), as they should. right!
now something is wrong Wilbert(or i misunderstood) : Your first and second picture is the same (as they should), but different as the first two. the first and the second pictures are the same in all posts....first is the first(xxx....14zm.png) and the second is the second(yyy...29go.png),don't exist 2 differents first and second pictures.
I hope it's clear now .no.more confused now! :confused:
picture 1 colorbars(720,480),vdub info: uncompressed RGB32
picture 2 colorbars(720,480).converttoYUY2(),vdub info: YUV 4:2:2 (YUY2)
picture 3 colorbars(720,480,pixel_type="yuy2"),vdub info: YUV 4:2:2 (YUY2)
picture 4 colorbars(720,480).ConvertToYUY2(matrix="PC.601"),vdub info YUV 4:2:2 (YUY2)
and all are showing differences in luma/chroma!
i told you,something is crazy in my system! (maybe the user!!???)
now the real doubt:
if the script used to encode in cce don't have any resize and filters,only the colorspace(ConvertToYUY2())
script used:
LoadPlugin("C:\?????\DGDecode.dll")
mpeg2source("D:\??\V01.D2V")
ConvertToYUY2()
loading the .vob or this script in vdub,the colors don't change but why the colors change so much after encode with cce?
mp3dom
11th January 2006, 17:12
Sorry for the little "OT" but...
I have an NTSC MPEG2 file with SMPTE 170M colorspace (which I think is the same as ITU 601) and I need to convert to RGB... do I need to specify (in AviSynth) the ConvertToRGB32(matrix="PC.601") or I can simply ignore the matrix parameter? Then If I want to re-convert to YUY2... i need to re-specify again the PC.601 or is by default PC.601? Thanks!
Wilbert
11th January 2006, 21:06
@raquete,
I looked at your pics again, and i see indeed a difference (in luma/chroma) between picture 1 and 2. The problem is that i can't duplicate it. If i load the scripts in vdubmod, copy source to clipboard-paint, save as jpg, then they both look as your picture 1. Could you select "Snapshot source frame" instead of "copy to clipboard" and upload the first two pictures again?
@mp3dom
I have an NTSC MPEG2 file with SMPTE 170M colorspace (which I think is the same as ITU 601)
Yes, it's the same as Rec.601 [16,235].
and I need to convert to RGB... do I need to specify (in AviSynth) the ConvertToRGB32(matrix="PC.601")
PC.601 is something else as Rec.601. See http://www.avisynth.org/Convert. The former keeps the full luma range, the latter doesn't.
Since the default is Rec601 you should use ConvertToRGB32().
raquete
11th January 2006, 21:38
@raquete,
I looked at your pics again, and i see indeed a difference (in luma/chroma) between picture 1 and 2. The problem is that i can't duplicate it. If i load the scripts in vdubmod, copy source to clipboard-paint, save as jpg, then they both look as your picture 1. Could you select "Snapshot source frame" instead of "copy to clipboard" and upload the first two pictures again?
done.....but
using "Snapshot source frame",saving as (targa) "*.tga" and imageshack don't host this type of image,then the new pictures (1A and 2A) was saved as .bmp!(imageshack change to .png hosting) if you want i can send to your mail the .tga pictures and all bmps.
1A.bmp colorbars(720,480)
http://img263.imageshack.us/img263/3177/1a2ul.th.png (http://img263.imageshack.us/my.php?image=1a2ul.png)
old picture 1 colorbars(720,480)
http://img460.imageshack.us/img460/388/14zm.th.png (http://img460.imageshack.us/my.php?image=14zm.png)
2A.bmp colorbars(720,480).converttoYUY2()
http://img263.imageshack.us/img263/4541/2a5ue.th.png (http://img263.imageshack.us/my.php?image=2a5ue.png)
old picture 2 colorbars(720,480).converttoYUY2()
http://img460.imageshack.us/img460/3848/29go.th.png (http://img460.imageshack.us/my.php?image=29go.png)
just the same...or better,old 1 is equal 1A and old 2 is equal 2A!
[edit]is better a .rar file with all bmps and host in rapidshare?
thanks Wilbert!
raquete
11th January 2006, 21:47
Wilbert,
all bmps posted(and links to imageshack in .txt files) : http://rapidshare.de/files/10867334/Pictures.rar.html
Wilbert
11th January 2006, 23:14
My findings:
If i open 1.bmp and 2.bmp in firefox 1.5 they are different. If i open them in ACDSee or Irfanview they are the same. The same for 3.bmp and 4.bmp.
Could you check whether this is also for you the case?
raquete
11th January 2006, 23:38
i don't have advanced picture view/editor,i have only the paint(paintbrush). it show me that differences.
Wilbert
11th January 2006, 23:48
I don't have paint. But if i try 'Imaging for Windows' instead i also see that difference.
No idea, why the pics are shown differently in different viewers.
guada 2
12th January 2006, 02:21
@wilbert
It is very interesting.
But, which would be the difference between ( Huffyuv and vfapi-convert ) with a script including the function: ConvertToRGB(clip, matrix = "rec709") in mode DVD or HDTV?
raquete
12th January 2006, 23:22
I don't have paint. But if i try 'Imaging for Windows' instead i also see that difference.
No idea, why the pics are shown differently in different viewers.
yes,it's really strange.
encrease the differences: load picture 1 and save as .bmp 16 colors.do the same with picture 2. compare now the new pictures!
comparing my encodes with source: in the vob encoded with cce i have more differences than loading scripts in vdubmod.
do you want that i cut little vobs from source and from cce encode(~10Mb each) and host to you download and compare?
thanks for your interest Wilbert! :)
Wilbert
12th January 2006, 23:27
For your vob you might need ColorMatrix (CCE adds no coefficients, which means Rec709 coefficients since that's the default). If you vob uses different coefficients you should use ColorMatrix. If that's not the problem, then it's a playback problem and i can't help you.
raquete
13th January 2006, 12:40
For your vob you might need ColorMatrix ..ok.i download the last colormatrix version and i'll post the results later....good result i will.
If that's not the problem, then it's a playback problem and i can't help you.all right,i understand.thank you very much! :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.