Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd October 2021, 18:35   #1  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
IsYUV420, IsYUV444

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?
MysteryX is offline   Reply With Quote
Old 2nd October 2021, 19:00   #2  |  Link
Julek
Registered User
 
Julek's Avatar
 
Join Date: Dec 2020
Posts: 84
Code:
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/HomeOfVapourSynth...sfunc.py#L5391
Julek is offline   Reply With Quote
Old 2nd October 2021, 19:11   #3  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Quote:
Originally Posted by MysteryX View Post
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.
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 2nd October 2021, 20:29   #4  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by ChaosKing View Post
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?
MysteryX is offline   Reply With Quote
Old 2nd October 2021, 23:32   #5  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
@MysteryX: you caould simply test for it.

Quote:
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.
Code:
clip = mvf.Depth(clip, depth=16)
see: https://github.com/HomeOfVapourSynth...ter/mvsfunc.py

Cu Selur

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 3rd October 2021, 00:08   #6  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,153
Quote:
Originally Posted by Selur View Post
@MysteryX: you caould simply test for it.


Code:
clip = mvf.Depth(clip, depth=16)
see: https://github.com/HomeOfVapourSynth...ter/mvsfunc.py

Cu Selur

Cu Selur
New ver of mvsfunc
https://github.com/AmusementClub/mvsfunc
kedautinh12 is offline   Reply With Quote
Old 4th October 2021, 05:56   #7  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
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?
MysteryX is offline   Reply With Quote
Old 4th October 2021, 08:43   #8  |  Link
Quadratic
Registered User
 
Join Date: Jul 2021
Posts: 26
Quote:
Originally Posted by MysteryX View Post
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/func...eo/resize.html

Last edited by Quadratic; 4th October 2021 at 08:49.
Quadratic is offline   Reply With Quote
Old 4th October 2021, 15:13   #9  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
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.
MysteryX is offline   Reply With Quote
Old 4th October 2021, 16:05   #10  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by MysteryX View Post
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.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:51.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.