This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[Feature] Multiple passes for glsl shaders
#1
I have noticed that we can select custom glsl shaders when using vapoursynth, I would like to request that we can add on to it and have multiple passes with different shaders, this allows for more adaptive filtering for different sources and can be useful when using filters like Anime4K where multiple filters are required to make the output desirable

Thanks in advance
Reply
#2
I don't really get it. Smile
You can simply add glsl filter as often as you need it, so why multiple passes?
How do you envision this to work?

Cu Selur
Reply
#3
(25.12.2021, 18:32)Selur Wrote: I don't really get it. Smile
You can simply add glsl filter as often as you need it, so why multiple passes?
How do you envision this to work?

Cu Selur

Wait can we?
Whenever I add another glsl filter the first one gets overwritten
Reply
#4
Just, tested it:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: ACNet.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
clip = core.placebo.Shader(clip=clip, shader="I:/Hybrid/64bit/vsfilters/GLSL/ACNet.glsl", width=640, height=352)
# GLSL filter: adaptive-sharpen.glsl
clip = core.placebo.Shader(clip=clip, shader="I:/Hybrid/64bit/vsfilters/GLSL/adaptive-sharpen.glsl", width=640, height=352)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
-> had no problem here using multiple GLSL filters,....
You need to use "Filter Queue" instead of the default "Filter Order" to add multiple instances,...
read: [INFO] About Vapoursynth Filter Order/Queue
Hybrid allows to add:
  • (most) filters multiple times
  • (most) filters only on frame sections
I'm also working on allowing to apply (most) filters only on parts of the image, but so far I only had time to add this for 'Levels'. (I mainly have to adjust the GUI to support this, the background code is already implemented, but I haven't found the time to add this). Also this is more of a 'gimmicky' feature for me as nobody required it and I sometimes use something likt that to see how different denoisers act on a source by dividing the source in X sections and filter each section with a different denoiser.

Cu Selur
Reply
#5
(25.12.2021, 19:26)Selur Wrote: Just, tested it:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: ACNet.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
clip = core.placebo.Shader(clip=clip, shader="I:/Hybrid/64bit/vsfilters/GLSL/ACNet.glsl", width=640, height=352)
# GLSL filter: adaptive-sharpen.glsl
clip = core.placebo.Shader(clip=clip, shader="I:/Hybrid/64bit/vsfilters/GLSL/adaptive-sharpen.glsl", width=640, height=352)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
-> had no problem here using multiple GLSL filters,....
You need to use "Filter Queue" instead of the default "Filter Order" to add multiple instances,...
read: [INFO] About Vapoursynth Filter Order/Queue
Hybrid allows to add:
  • (most) filters multiple times
  • (most) filters only on frame sections
I'm also working on allowing to apply (most) filters only on parts of the image, but so far I only had time to add this for 'Levels'. (I mainly have to adjust the GUI to support this, the background code is already implemented, but I haven't found the time to add this). Also this is more of a 'gimmicky' feature for me as nobody required it and I sometimes use something likt that to see how different denoisers act on a source by dividing the source in X sections and filter each section with a different denoiser.

Cu Selur
Niceee thanks
However it seems that Anime4K shaders cannot be applied this way?
I'm not sure if it is a VS issue or the structure of Anime4K glsl shaders but they don't seem to work well with video exporting outside of mpv, maybe you can take a look?

Thanks in advance
Reply
#6
I can confirm that if I use the glsl filters from https://github.com/bloc97/Anime4K/releases and use for example:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: Anime4K_Darken_VeryFast.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
clip = core.placebo.Shader(clip=clip, shader="C:/Users/Selur/Desktop/Anime4k/Anime4K_Darken_VeryFast.glsl", width=640, height=352)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
that the preview works fine, vspipe info works fine, but encoding using:
vspipe "E:\Temp\encodingTempSynthSkript_2021-12-26@07_38_12_9010.vpy" - -c y4m | x264 --preset veryfast --crf 18.00 --profile high --level 4.1 --ref 3 --direct auto --b-adapt 0 --sync-lookahead 48 --qcomp 0.50 --rc-lookahead 40 --qpmax 51 --partitions i4x4,p8x8,b8x8 --no-fast-pskip --subme 5 --aq-mode 0 --vbv-maxrate 62500 --vbv-bufsize 78125 --sar 1:1 --non-deterministic --range tv --colormatrix bt470bg --demuxer y4m  --input-range tv --fps 25/1 --output-depth 8 --output "E:\Temp\2021-12-26@07_38_12_9010_03.264" -
fails with:
y4m [error]: bad frame header magic

Wild guess is that those shaders only work if there is an acctual display.

Since I don't think this is a bug in Hybrid, I opened an issue entry over at https://github.com/Lypheo/vs-placebo/issues/17 to see whether the author of vs-placeco can say anything about it.

Cu Selur
Reply
#7
(26.12.2021, 08:53)Selur Wrote: I can confirm that if I use the glsl filters from https://github.com/bloc97/Anime4K/releases and use for example:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: Anime4K_Darken_VeryFast.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
clip = core.placebo.Shader(clip=clip, shader="C:/Users/Selur/Desktop/Anime4k/Anime4K_Darken_VeryFast.glsl", width=640, height=352)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
that the preview works fine, vspipe info works fine, but encoding using:
vspipe "E:\Temp\encodingTempSynthSkript_2021-12-26@07_38_12_9010.vpy" - -c y4m | x264 --preset veryfast --crf 18.00 --profile high --level 4.1 --ref 3 --direct auto --b-adapt 0 --sync-lookahead 48 --qcomp 0.50 --rc-lookahead 40 --qpmax 51 --partitions i4x4,p8x8,b8x8 --no-fast-pskip --subme 5 --aq-mode 0 --vbv-maxrate 62500 --vbv-bufsize 78125 --sar 1:1 --non-deterministic --range tv --colormatrix bt470bg --demuxer y4m  --input-range tv --fps 25/1 --output-depth 8 --output "E:\Temp\2021-12-26@07_38_12_9010_03.264" -
fails with:
y4m [error]: bad frame header magic

Wild guess is that those shaders only work if there is an acctual display.

Since I don't think this is a bug in Hybrid, I opened an issue entry over at https://github.com/Lypheo/vs-placebo/issues/17 to see whether the author of vs-placeco can say anything about it.

Cu Selur

Great to know that it isn't something due to my goofy setup
Thanks for all your help
Happy holidays!
Reply
#8
Just did a small test with:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# GLSL filter: Anime4K_Darken_VeryFast.glsl
# adjusting color space from YUV420P8 to YUV444P16 for VsGLSLFilter
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
clip = core.placebo.Shader(clip=clip, shader="I:/Hybrid/64bit/vsfilters/GLSL/Anime4k/Anime4K_Darken_VeryFast.glsl", width=640, height=352)
# adjusting output color from:  to YUV420P8 for x264Model
= core.resize.Bicubic(clip=, format=vs.YUV420P8, range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
and here it worked now (witht he updated vs-placebo filter from 17 Dec 2021)

Cu Selur
Reply
#9
as a small update regarding using Anime4k filters
https://github.com/Lypheo/vs-placebo/issues/17 -> issue still exists, but it's not happening for all Anime4k filters, the darken filters for example work during preview and encoding.

Cu Selur
Reply
#10
It's fixed. Smile
-> Uploaded a new dev and send you a link via pm.

Cu Selur
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)