![]() |
|
Deoldify Vapoursynth filter - Printable Version +- Selur's Little Message Board (https://forum.selur.net) +-- Forum: Talk, Talk, Talk (https://forum.selur.net/forum-5.html) +--- Forum: Small Talk (https://forum.selur.net/forum-7.html) +--- Thread: Deoldify Vapoursynth filter (/thread-3595.html) Pages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
RE: Deoldify Vapoursynth filter - Selur - 30.04.2024 Quote:I need your support to answer to zspeciman's question.okay, looking at the scripts. 1st script uses ImageSource, thus frames should already be at RGB24 # adding colors using DeOldify
from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip, method=0, deoldify_p=[0, 24, 1, 0])# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# adding colors using DeOldify
from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip, method=0, deoldify_p=[0, 24, 1, 0])# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# adding colors using DeOldify
from vsdeoldify import ddeoldify_main
clip = ddeoldify_main(clip=clip)Quote:I think that is an issue related to the color space conversion, both my first script and Deoldify original are working on "color space: RGB24, bit depth: 8, yuv luminance scale: full, matrix: 709"yes, and the YUV420P8 is converted to RGB24. The main difference I see is that the source in the second script uses 0-255 as range while the second clip uses 16-235. What happens if you use Levels to convert your input from 16-235 to 0-255 and adjust the range signaling to 'full' before applying DeOldify? I also updated the test version with a version where Hybrid will for 'limited' content create code like this: # changing range from limited to full range
clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
# setting color range to PC (full) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=0)
# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="full")
# adding colors using DeOldify
from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip, method=0, deoldify_p=[024, 1, 0])
# changing range from full to limited range
clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")Cu Selur RE: Deoldify Vapoursynth filter - Dan64 - 01.05.2024 Unfortunately this fix is not enough Using your script I obtain the following image: That is better but not equal to "native" RGB24 version Using the following script # Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'D:/Programs/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="D:/Programs/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
import validate
# Source: 'TestClipSingerBW.mp4'
# Current color space: YUV420P8, bit depth: 8, resolution: 480x360, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading TestClipSingerBW.mp4 using LWLibavSource
clip = core.lsmas.LWLibavSource(source="TestClipSingerBW.mp4", format="YUV420P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)
clip = core.std.Loop(clip=clip[185], times=257)
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# setting color transfer (170), if it is not set.
if validate.transferIsInvalid(clip):
clip = core.std.SetFrameProps(clip, _Transfer=6)
# setting color primaries info (to 470), if it is not set.
if validate.primariesIsInvalid(clip):
clip = core.std.SetFrameProps(clip, _Primaries=5)
clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
# setting color range to PC (full) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=0)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="full")
# adding colors using DeOldify
from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip, method=0, deoldify_p=[0, 24, 1, 0])
# adjusting output color from: RGB24 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="full")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# output
clip.set_output()In this case I removed the final conversion to limited, and the picture obtained is a little better But to get the exact picture I need to used the same conditions as in the following script # Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'D:/Programs/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="D:/Programs/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
import validate
# Source: 'TestClipSingerBW.mp4'
# Current color space: YUV420P8, bit depth: 8, resolution: 480x360, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading TestClipSingerBW.mp4 using LWLibavSource
clip = core.lsmas.LWLibavSource(source="TestClipSingerBW.mp4", format="YUV420P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)
clip = core.resize.Bicubic(clip=clip, matrix_in_s="470bg", matrix_s="709", range_in=0, range=0)
# changing range from limited to full range
clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
clip = core.std.Loop(clip=clip[185], times=257)
frame = clip.get_frame(0)
# Setting detected color matrix (709).
clip = core.std.SetFrameProps(clip, _Matrix=1)
# setting color transfer (170), if it is not set.
if validate.transferIsInvalid(clip):
clip = core.std.SetFrameProps(clip, _Transfer=1)
# setting color primaries info (to 709), if it is not set.
if validate.primariesIsInvalid(clip):
clip = core.std.SetFrameProps(clip, _Primaries=1)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
# changing range from limited to full range
#clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
# setting color range to PC (full) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=0)
# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full", dither_type="error_diffusion")
# adding colors using DeOldify
from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip, method=0, deoldify_p=[0, 24, 1, 0])
# changing range from full to limited range
#clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
# adjusting output color from: RGB24 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="709", range_s="full")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# output
clip.set_output()In this case I obtain the following picture To simplify the comparison I created this album: https://imgsli.com/MjYwNDcy Dan RE: Deoldify Vapoursynth filter - Selur - 01.05.2024 Man,.. why post the whole script, each time,.. Looking at you correct way: # Source: 'TestClipSingerBW.mp4'
# Current color space: YUV420P8, bit depth: 8, resolution: 480x360, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading TestClipSingerBW.mp4 using LWLibavSource
clip = core.lsmas.LWLibavSource(source="TestClipSingerBW.mp4", format="YUV420P8", stream_index=0, cache=0, fpsnum=25, prefer_hw=0)clip = core.resize.Bicubic(clip=clip, matrix_in_s="470bg", matrix_s="709", range_in=0, range=0)# changing range from limited to full range
clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")clip = core.std.Loop(clip=clip[185], times=257)# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)# setting color range to PC (full) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=0)# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full", dither_type="error_diffusion")
# adding colors using DeOldify
from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip, method=0, deoldify_p=[0, 24, 1, 0])So all in all up to this point (ignoring the frame duplication thing) you made sure that if YUV content was present it is converted to matrix bt709 and luma range full before converted to RGB and fed to DeOldify. # adjusting output color from: RGB24 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="709", range_s="full")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# output
clip.set_output()Would have been way easier if you had spend the time to write down a few sentences of what you did or indented to do. I write a test version which will make sure DeOldify is fed with 'bt709' and 'full' but will revert to the original values afterwards. If you want 'bt709' and 'full' output, you should use Levels to convert the levels and ColorMatrix to change the matrix before feeding the source to DeOldify. Cu Selur RE: Deoldify Vapoursynth filter - Dan64 - 01.05.2024 Hello Selur, I changed vsdeoldify to use internally the full range, previously vsdeoldify was using the limited range. This change together with your change, fixed the problem related to the color space conversion. You can find the comparison here: https://imgsli.com/MjYwNTM4 Regarding the new version provided by you, a part the conversion of the range from "limited" to "full", I noted that you added the support to ColorTune. Unfortunately the implementation is not working perfectly. Main issues found are: 1) ColorTune is propagated to the custom parameters, but is not passed to the function ddeoldify_main() 2) In some case ColorTune is not propagated correctly in the custom parameters (its destination is depending from selected preset) 3) ColorMap is not propagated correctly to custom parameters (its destination is depending from selected preset) and affects also ColorFix custom parameters I attached the new version with the support of "full range" Dan P.S. In this release, in the clip description of function ddeoldify() I added the following advice: please remove any grain from the clip, because it will create artifacts on colored frames. RE: Deoldify Vapoursynth filter - Selur - 01.05.2024 Quote: I changed vsdeoldify to use internally the full range, previously vsdeoldify was using the limited range.Shouldn't it use the range it is fed with?!? (or throw an error if the luma range is different then required) I will: a. remove the full range requirement for the filter b. look into fixing the problems with RC5 RE: Deoldify Vapoursynth filter - Dan64 - 01.05.2024 (01.05.2024, 12:04)Selur Wrote:Quote: I changed vsdeoldify to use internally the full range, previously vsdeoldify was using the limited range.Shouldn't it use the range it is fed with?!? (or throw an error if the luma range is different then required) No, please the current version in my opinion is working perfectly, I expect to receive in input a source with matrix=709 and full range. In the current version, at the beginning of vsdeoldify I'm using the following code if clip.format.id != vs.RGB24:
# clip not in RGB24 format, it will be converted
if (clip.format.color_family == "YUV"):
clip = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="full", dither_type="error_diffusion")
else:
clip = clip.resize.Bicubic(format=vs.RGB24, range_s="full")Previously I was using if clip.format.id != vs.RGB24:
# clip not in RGB24 format, it will be converted
if (clip.format.color_family == "YUV"):
clip = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="limited", dither_type="error_diffusion")
else:
clip = clip.resize.Bicubic(format=vs.RGB24, range_s="limited")Moreover, previously when It was necessary a change from RGB24 to YUV and then back to RGB24 I was a code like clip = clip.resize.Bicubic(format=vs.YUV444PS, matrix_s="709", range_s="limited")
....
....
clip_rgb = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="limited", dither_type="error_diffusion")now I'm using clip = clip.resize.Bicubic(format=vs.YUV444PS, matrix_s="709", range_s="full")
...
...
clip_rgb = clip.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="full", dither_type="error_diffusion")So this version is expecting in input a RGB24 clip with matrix=709 and range full. Dan RE: Deoldify Vapoursynth filter - Selur - 01.05.2024 updated the test version (against R5), it should make sure it gets full&709 Cu Selur RE: Deoldify Vapoursynth filter - Dan64 - 01.05.2024 I still found the yesterday version RE: Deoldify Vapoursynth filter - Selur - 01.05.2024 Argh, there's still a bug regarding the undoing of the color matrix change. (RGB doesn't have a color matrix entry) RE: Deoldify Vapoursynth filter - Selur - 01.05.2024 Updated test download. |