View Single Post
Old 8th February 2016, 15:15   #12  |  Link
jackoneill
unsigned int
 
jackoneill's Avatar
 
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
Quote:
Brilliant. Thanks for that.
Maybe brilliant, but needlessly complicated.

Don't let ffmpeg (swscale) do any format conversions. VapourSynth's resizers (zimg) or fmtconv will do it better.

As for converting to RGB and back like in your initial post:
Code:
rgb24 = core.resize.Point(yv12, format=vs.RGB24, matrix_in_s="709", chromaloc_in_s="top_left")

# rgb processing

yv12 = core.resize.Point(rgb24, format=vs.YUV420P8, matrix_s="709", chromaloc_s="top_left")
There is no need to shift the chroma like in Gavino's code because resize.Point to yv24 followed by resize.Point back to yv12 is a no-op, provided you use the same chroma location in both calls.

If your yv12 input is full range, add range_in_s="full". You don't have to convert it to limited range yv12 first. But if you must convert to limited range yv12:
Code:
yv12_limited = core.resize.Point(yv12_full, range_in_s="full", range_s="limited")
__________________
Buy me a "coffee" and/or hire me to write code!
jackoneill is offline   Reply With Quote