Log in

View Full Version : How to convert 3840x2160 4:2:0 to 1920x1080 4:4:4 ???


nautilus7
14th January 2014, 00:36
Hi,

I have a 3840x2160 4:2:0 clip (satellite transmission) that I want to convert to 1920x1080 4:4:4 using avisynth and then encode it with x264.

First of all, does such conversion (chroma "upsampling") makes sense? Is chroma resolution already 1920x1080 in the original clip?

Although using avisynth for basic encoding for several years, I am not familiar with this type of conversions. I did a quick search and I think that I need to separate chroma from luma, resize luma only an then merge them together again. Is that correct? How to do it?

vampiredom
14th January 2014, 02:13
That is interesting ... You could try:

y = orig.Spline36Resize(1920,1080).ConvertToYV24()
u = orig.UtoY().ConvertToYV24()
v = orig.VtoY().ConvertToYV24()

YToUV(u, v, y)


I am not sure if the chroma siting allows for this kind of direct 'extraction', however. It might better to just convert it conventionally.


ConvertToYV24()
Spline36Resize(1920,1080)

Asmodian
14th January 2014, 04:15
Yes the color information is already 1920x1080 which is why you want to avoid resizing it.

I would use vampiredom's first suggestion as it avoids resizing the color information twice (up to 3840x2160 and back down to 1920x1080) though if there is a chroma position error the second one might be better. I do not believe there is a chroma position error though as MPEG2 position is left-justified so everything should stay in the same place? Chroma position has given me logic troubles in the past though so think about it very carefully. ;)

This should be exactly the same as vampiredom's first suggestion too:
y = orig.Spline36Resize(1920,1080).ConvertToYV24(chromaresample="point")
u = orig.UtoY().ConvertToYV24(chromaresample="point")
v = orig.VtoY().ConvertToYV24(chromaresample="point")

YToUV(u, v, y)

edit: The MPEG2 chroma position is used for most everything but MPEG1 & DV, I assume your 4k video uses the MPEG2 chroma position.

vampiredom
14th January 2014, 04:50
YToUV(u, v, y)

Ah, of course. Sorry, I forgot you can plop the Y in there too. Simpler. Good catch.

nautilus7
14th January 2014, 09:18
Hi, guys, thanks for the suggestions. I will try them out. My video capture is in H.264 format. What does it mean regarding chroma position? Is it the same as MPEG-2?

nautilus7
14th January 2014, 11:05
1. Simple 4k->1080p 4:2:0 output using spline36resize().
2. Your suggested method (4:4:4 output).

http://t.imgbox.com/advRxZAn.jpg (http://imgbox.com/advRxZAn) http://t.imgbox.com/ablnzP2d.jpg (http://imgbox.com/ablnzP2d)

I notice some shift/misplacement in the red wine drop when I enlarge the image a lot. Is it normal?

Gavino
14th January 2014, 12:14
I do not believe there is a chroma position error though as MPEG2 position is left-justified so everything should stay in the same place? Chroma position has given me logic troubles in the past though so think about it very carefully. ;)

This should be exactly the same as vampiredom's first suggestion too:
y = orig.Spline36Resize(1920,1080).ConvertToYV24(chromaresample="point")
u = orig.UtoY().ConvertToYV24(chromaresample="point")
v = orig.VtoY().ConvertToYV24(chromaresample="point")

YToUV(u, v, y)
Yes, there is a chroma position error in that code, so you need to use the appropriate offset on the resize (see here).
Also, it's more efficient to use Y8 as the intermediate format.
y = orig.ConvertToY8().Spline36Resize(1920,1080, src_left=-0.5)
u = orig.UtoY8()
v = orig.VtoY8()

YToUV(u, v, y)

nautilus7
14th January 2014, 14:34
Gavino thanks for the advice. Now, with your script I see a blueish "border" at the left side of the white letters at the bottom of the image, which is not there when using just Spline36Resize().
But it IS present in the orginal, non scaled image (haven't notice before).

Does it mean that the source video/image has wrong chroma placement? See below.

http://t.imgbox.com/abo8efGo.jpg (http://imgbox.com/abo8efGo) http://t.imgbox.com/abhbD6Cp.jpg (http://imgbox.com/abhbD6Cp) http://t.imgbox.com/acmSxoFr.jpg (http://imgbox.com/acmSxoFr)

Now that I think of, I created the 4k source by stacking 4x1080p streams (this way it was aired - 4 channels each of them transmitting a part of the image). Have I done something wrong during merging the 4 streams?

This is the way i merged it:

a=DGSource("TOP_LEFT.dgi")
b=DGSource("TOP_RIGHT.dgi")
c=DGSource("BOT_LEFT.dgi")
d=DGSource("BOT_RIGHT.dgi")

t=StackHorizontal(a, b)
b=StackHorizontal(c, d)

StackVertical(t, b)