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 10th August 2020, 07:41   #1  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Appropriate YV12 to YUY2 conversion and back

What are the Vapoursynth equivalent YV12 to YUY2 conversions and back?
Cary Knoop is offline   Reply With Quote
Old 10th August 2020, 11:27   #2  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Do you mean actual interleaved YUY2 like in Avisynth, or just any old 4:2:2? I don't think VS (or zimg, rather) actually supports converting to the former. It has a format constant but it's one of the COMPAT ones that's only used for Avisynth interoperability. VS doesn't really support working with interleaved color formats in general, everything is planar internally and packing is only done for input or output.
TheFluff is offline   Reply With Quote
Old 10th August 2020, 12:44   #3  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
there's no appropriate way to convert between 4:2:0 and 4:2:2 because you have to resample Cb, Cr and that leads to quality loss, however, if your goal is to simply "get the shit done":

Code:
#to 422
clp = core.fmtc.resample(clp, css="422", kernel="point")

#to 420
clp = core.fmtc.resample(clp, css="420", kernel="point")

#"point" (nearest neighbor) is a true lossless resampling kernel, but it's pretty much useless if you want to apply literally any filtering on the resampled clip.

Last edited by feisty2; 10th August 2020 at 16:25.
feisty2 is offline   Reply With Quote
Old 10th August 2020, 16:08   #4  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Quote:
Originally Posted by TheFluff View Post
Do you mean actual interleaved YUY2 like in Avisynth
That's the one I mean.

What do you do if your source is already packed that way and you want to deinterlace?
Cary Knoop is offline   Reply With Quote
Old 10th August 2020, 16:23   #5  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
if you do:
#clip is some YUV420P8
clip2 = core.resize.Point(clip, format=vs.COMPATYUY2)
clip3 = core.resize.Point(clip2, format=vs.YUV420P8)
then all three clips are the same

COMPATYUY2 stores bytes as two byte packs interleaved as YU,YV,YU,YV, etc., you can check here
What is the reason to use interleaved YUY2?
_Al_ is offline   Reply With Quote
Old 10th August 2020, 16:50   #6  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by Cary Knoop View Post
That's the one I mean.

What do you do if your source is already packed that way and you want to deinterlace?
Unpacking YUY2 to planar YUV422P8 is lossless. If you can't find a deinterlacer that supports YUV422P8 you could always upscale the chroma so you get YUV444P8 - that probably has at least slightly wider support.

I believe you can also re-pack YUV422P8 to YUY2 for output, or if that doesn't work you could as a last resort use v210, which is a wacky 10-bit interleaved YUV 4:2:2 thing mostly used by QuickTime and some other professional software. The VFW output does support that, although you need to do some mysterious incantation to enable it (can't remember off the top of my head).

Last edited by TheFluff; 10th August 2020 at 16:53.
TheFluff 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 13:32.


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