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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th October 2019, 19:25   #1  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 319
Is this correct?

Hi, can someone please confirm if this is correct?:

Code:
Clip = FFmpegSource2("YV12.mkv")

Y = ExtractY(clip)
U = ExtractU(clip).LanczosResize(clip.Width, clip.Height)
V = ExtractV(clip).LanczosResize(clip.Width, clip.Height)
CombinePlanes(Y, U, V, planes = "YUV", source_planes = "YYY", pixel_type = "YV24")
And the same for YV16, YUY2, YV411, YUV420...

I ask mostly because of the ChromaInPlacement parameter in Convert. Maybe this way is correct for all formats (MPEG1, MPEG2, DV)?
Alexkral is offline   Reply With Quote
Old 16th October 2019, 02:38   #2  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 319
I'll put it in a different way. For progressive YV12 to YV24 how wrong is it to use the default ChromaInPlacement with MPEG1 or DV?

I am writing a function for an AVSI and I don't want to add unnecessary arguments.
Alexkral is offline   Reply With Quote
Old 24th October 2019, 04:56   #3  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
You always need to deal with chroma placement. Sorry, no way to avoid it if you want undamaged video when you are done.
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 25th October 2019, 20:06   #4  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 319
That's right, but there's still something I don't understand here. The result of these two scripts is the same:

Code:
FFmpegSource2("YV24.mkv")
ConvertToYV12(ChromaOutPlacement = "MPEG2")
ConvertToYV24(ChromaInPlacement = "MPEG2", chromaresample = "Lanczos")

------------------------

FFmpegSource2("YV24.mkv")
ConvertToYV12(ChromaOutPlacement = "MPEG2")
Y = ExtractY(last)
U = ExtractU(last).LanczosResize(last.Width, last.Height, 0.25, 0, last.Width / 2, last.Height / 2)
V = ExtractV(last).LanczosResize(last.Width, last.Height, 0.25, 0, last.Width / 2, last.Height / 2)
CombinePlanes(Y, U, V, planes = "YUV", source_planes = "YYY", pixel_type = "YV24")
And the same goes for these two:

Code:
FFmpegSource2("YV24.mkv")
ConvertToYV12(ChromaOutPlacement = "MPEG1")
ConvertToYV24(ChromaInPlacement = "MPEG1", chromaresample = "Lanczos")

------------------------

FFmpegSource2("YV24.mkv")
ConvertToYV12(ChromaOutPlacement = "MPEG1")
Y = ExtractY(last)
U = ExtractU(last).LanczosResize(last.Width, last.Height, 0, 0, last.Width / 2, last.Height / 2)
V = ExtractV(last).LanczosResize(last.Width, last.Height, 0, 0, last.Width / 2, last.Height / 2)
CombinePlanes(Y, U, V, planes = "YUV", source_planes = "YYY", pixel_type = "YV24")
I think it should be the other way arround, it's MPEG1 which doesn't have the luma and chroma samples aligned, so there's a need to move the chroma, while MPEG2 does have them aligned and should not need it.

Last edited by Alexkral; 26th October 2019 at 05:44.
Alexkral is offline   Reply With Quote
Old 26th October 2019, 16:30   #5  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Avisynth resizers resize around the image centre, not the top-left (or any other) corner.

So MPEG2 chroma, although originally aligned, gets shifted away on expansion while MPEG1 moves to the desired alignment.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 27th October 2019, 05:52   #6  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 319
Ahh ok thanks, that would also explain the vertical alignment, but I'd still have a couple of questions:

1 - I understand that the different behavior of chromaresample is because of the ChromaInPlacement argument, and what you said about the resizers doesn't apply here, right?

2 - Shouldn't be then the MPEG2 chroma shift in the second script to the right instead of to the left?

3 - Is this the same happening here?
Alexkral 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 19:23.


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