Log in

View Full Version : IsYUV420, IsYUV444


MysteryX
2nd October 2021, 18:35
I have a few questions about VapourSynth.

First, is there an easy way to know whether a clip is YUV420, YUV422 or YUV444 without regards to bitdepth? Let's say I want to convert back to source format but in 16bits. Iterating through all combinations would be long to write.

Second, should I aim to support videos with variable frame properties like Range and Matrix?

Supporting that means using FrameEval whenever I need to use those frame properties. Is there a performance cost to FrameEval? Does it need to recreate the filters for each frame or performance isn't much of an issue?

Julek
2nd October 2021, 19:00
src420 = src.resize.Bicubic(format=vs.YUV420P16)
src422 = src.resize.Bicubic(format=vs.YUV422P16)
src444 = src.resize.Bicubic(format=vs.YUV444P16)

print(src420.format.subsampling_w)
print(src422.format.subsampling_w)
print(src444.format.subsampling_w)

print(src420.format.subsampling_h)
print(src422.format.subsampling_h)
print(src444.format.subsampling_h)
output:
1
1
0

1
0
0

Example: https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/master/havsfunc.py#L5391

ChaosKing
2nd October 2021, 19:11
Supporting that means using FrameEval whenever I need to use those frame properties. Is there a performance cost to FrameEval? Does it need to recreate the filters for each frame or performance isn't much of an issue?

I can't find the post where it was mentioned, but instead of doing everything inside frameeval, let frameeval just call a function that does your stuff. This should give the best performance.

MysteryX
2nd October 2021, 20:29
I can't find the post where it was mentioned, but instead of doing everything inside frameeval, let frameeval just call a function that does your stuff. This should give the best performance.
Isn't that all what FrameEval does, call a function?

Selur
2nd October 2021, 23:32
@MysteryX: you caould simply test for it.

First, is there an easy way to know whether a clip is YUV420, YUV422 or YUV444 without regards to bitdepth? Let's say I want to convert back to source format but in 16bits. Iterating through all combinations would be long to write.
clip = mvf.Depth(clip, depth=16)
see: https://github.com/HomeOfVapourSynthEvolution/mvsfunc/blob/master/mvsfunc.py

Cu Selur

Cu Selur

kedautinh12
3rd October 2021, 00:08
@MysteryX: you caould simply test for it.


clip = mvf.Depth(clip, depth=16)
see: https://github.com/HomeOfVapourSynthEvolution/mvsfunc/blob/master/mvsfunc.py

Cu Selur

Cu Selur

New ver of mvsfunc
https://github.com/AmusementClub/mvsfunc

MysteryX
4th October 2021, 05:56
While being at it -- is there a convert function that allows converting back from RGB to YUV while respecting frame properties (Matrix, Primaries, Range) that were already set before converting to RGB?

Quadratic
4th October 2021, 08:43
While being at it -- is there a convert function that allows converting back from RGB to YUV while respecting frame properties (Matrix, Primaries, Range) that were already set before converting to RGB?

Resize can infer from props, if that doesn't work you may just need to create a quick function that stores and reads props.
https://www.vapoursynth.com/doc/functions/video/resize.html

MysteryX
4th October 2021, 15:13
Resize requires specifying Matrix to go back to YUV; so I assume it also need Transfer, Primaries and Range to also be specified. Then chroma location.

Reading props, that's why I was looking into FrameEval to do it properly on a frame-per-frame basis, but it's a bit tricky to write with all those variables.

Myrsloik
4th October 2021, 16:05
While being at it -- is there a convert function that allows converting back from RGB to YUV while respecting frame properties (Matrix, Primaries, Range) that were already set before converting to RGB?

No, there's no good way to do that.