Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: yami on March 30, 2015, 09:11:25 AM

Title: AviDemux/VapourSynth
Post by: yami on March 30, 2015, 09:11:25 AM
I know, this is a bit... a lot XD. But maybe, it is worth a thought, maybe an even an inspiration for future developments of AviDemux.
Mean and everyone involved - did you ever think about the possibilities of adding an intersection or module that can communicate and interact with a preinstalled VapourSynth in Avidemux?  I could guess that this is a bit difficult as VS is framebased, AviDemux by now timebased. But honestly, if AviDemux could use the filters there (even if only scripting based) and be used as some kind of GUI for display (besides what AviDemux can already do on its own) as advanced option ... it would be the killer ^^
Title: Re: AviDemux/VapourSynth
Post by: YAFU on October 08, 2015, 02:24:48 PM
We are using scripts with combination of plugins in VapourSynth to reduce noise in Blender/Cycles renders:
http://blenderartists.org/forum/showthread.php?378736-Cycles-noise-reduction-with-VapourSynth

It's amazing how good are these filters to reduce noise. It really would be great if we could load these VapourSynth scripts in Avidemux.
Title: Re: AviDemux/VapourSynth
Post by: mean on October 09, 2015, 09:46:29 AM
It should not be too complicated to do
(This is Not a promise)
Title: Re: AviDemux/VapourSynth
Post by: mean on October 12, 2015, 06:22:01 AM
There is a small vsProxy preliminary test program
It is similar to avsProxy :
* Install VapourSynth (linux only at the moment)
* export PYTHONPATH=/usr/lib/python3.4/site-packages/   (3.5 if you use python 3.5) <<<= This is important, else you might get Cannot setup vapoursynth or similar
* ./vsProxy  blahblah.py (the file must have a .py extension for now)
* Avidemux -> connect to avsProxy

This is the test script i'm using, it 's just a black frame

import vapoursynth as vs
# get the core instance
core = vs.get_core()
clip = core.std.BlankClip(format=vs.YUV420P8)
# flip the video a bit
ret = core.std.Transpose(clip)
# set the clip to be output
ret.set_output()


Be sure to have the commit from monday morning , else you'll have a green video
Title: Re: AviDemux/VapourSynth
Post by: AQUAR on October 12, 2015, 11:45:49 AM
Interesting topic.

I use Avisynth/ADM on windows but wouldn't mind trying the more modern Vapoursynth/ADM on windows.

Title: Re: AviDemux/VapourSynth
Post by: mean on October 12, 2015, 12:04:29 PM
VS is multiplatform, so it's easier for me do developp around it
On the other hand, it seems pulling the whole python stuff is creating internal symbol clash, that's why it's not opened directly by avidemux but through a proxy
Title: Re: AviDemux/VapourSynth
Post by: YAFU on October 12, 2015, 04:46:21 PM
Hi mean.
For Ubuntu users you can install VapourSynth and plugins from this PPA:
https://launchpad.net/~djcj/+archive/ubuntu/vapoursynth

I've tried vsProxy and it is working with this script that you have posted.
What is possible to do for now with vsProxy? I never used avsProxy, so I do not know much about it. Is it possible to load videos? Does the video to be loaded must be specified into the script?
Title: Re: AviDemux/VapourSynth
Post by: mean on October 12, 2015, 05:55:36 PM
Basically, you write your vapoursynth script i.e. foo.py
start
vsProxy foo.py
And then it can be processed by avidemux (File->Connect to proxy), as if loaded directly by it
Title: Re: AviDemux/VapourSynth
Post by: YAFU on October 12, 2015, 06:48:59 PM
Ok, but for example I use KNLMeansCL to reduce noise with OpenCL/GPU:
https://github.com/Khanattila/KNLMeansCL/releases
with this script:
import vapoursynth as vs
core = vs.get_core()
##
##ffmpeg with ffms2
clp = core.ffms2.Source(source='/PATH_TO_VIDEO_HERE/input.mp4')
##

clp = core.knlm.KNLMeansCL(clp, d=3, a=2, s=4, h=4.2, device_type="GPU")
clp.set_output ()

If I run:
./vsProxy script.py
I get:
$ ./vsProxy script.py
[run]  Opening script.py as VapourSynth file
  [run]  VapourSynth init ok, opening file..
  [run]  Format    : YUV444P8
  [run]  FrameRate : 24 / 1
  [run]  Width     : 1280
  [run]  Height    : 720
  [run]  Frames    : 200
  [run]  Flags     : 0x3
  [fillInfo]  Format    : YUV444P8
  [fillInfo]  FrameRate : 24 / 1
  [fillInfo]  Width     : 1280
  [fillInfo]  Height    : 720
  [fillInfo]  Frames    : 200
  [fillInfo]  Flags     : 0x3
Only YUV420P8 supported!
Unsupported settings in script files
Failure


I really do not know if the video should be loaded from the script, or from avidemux.
Title: Re: AviDemux/VapourSynth
Post by: mean on October 13, 2015, 04:17:08 AM
you need to  convert to yuv420 (planar , 8 bits)
Title: Re: AviDemux/VapourSynth
Post by: AQUAR on October 13, 2015, 07:26:48 AM
Thanks mean - I see there is already a win64 binary for vsproxy.
Title: Re: AviDemux/VapourSynth
Post by: mean on October 13, 2015, 09:10:36 AM
Not complete yet, will not work
The socket initialization is missing
Title: Re: AviDemux/VapourSynth
Post by: mean on October 13, 2015, 05:49:24 PM
64bits windows attached

* Important *
1- unzip the nightly 7zip file, dont use the installer
2- Copy the vsProxy.exe in the same folder as avidemux.exe
3- If it fails, wait a bit (3 mn) before retrying

This is still work in progress....
Title: Re: AviDemux/VapourSynth
Post by: YAFU on October 13, 2015, 05:55:54 PM
This is really hard when one does not know about programming/scripting and not know about video technical aspects...
However, looking at other scrips I have done this:
import vapoursynth as vs
core = vs.get_core()
##
##ffmpeg with ffms2
src = core.ffms2.Source(source='/PATH_TO_VIDEO_HERE/input.mp4')
##
input = core.fmtc.matrix(clip=src, mat="601", col_fam=vs.RGB)

YUV = core.fmtc.matrix(clip=input, mat="601", col_fam=vs.YUV)
YUV = core.fmtc.resample(clip=YUV, css="420")
YUV = core.fmtc.bitdepth (clip=YUV, bits=8)

clip = core.knlm.KNLMeansCL(YUV, d=3, a=2, s=4, h=4.2, device_type="GPU")

clip.set_output()


Avdiemux open the video correctly, but the colors are exchanged (red by blue, blue by red). I'm pretty sure I've done things wrong. Any hints on what the problem is?
Title: Re: AviDemux/VapourSynth
Post by: mean on October 13, 2015, 06:59:00 PM
Probably a mistake from me
You can try the "Swap U & V " filter, it should make everything alright
Title: Re: AviDemux/VapourSynth
Post by: mean on October 13, 2015, 07:21:16 PM
Confirmed, U & V are inverted
Title: Re: AviDemux/VapourSynth
Post by: YAFU on October 13, 2015, 07:33:02 PM
Ok  ;)
So this would be the script to reduce noise with KNLMeansCL using OpenCL if anyone is interested:
import vapoursynth as vs
core = vs.get_core()
##
##ffmpeg with ffms2
src = core.ffms2.Source(source='/PATH_TO_VIDEO_HERE/input.mp4')
##

YUV = core.fmtc.matrix(clip=src, mat="601", col_fam=vs.YUV)
YUV = core.fmtc.resample(clip=YUV, css="420")
YUV = core.fmtc.bitdepth (clip=YUV, bits=8)

clip = core.knlm.KNLMeansCL(YUV, d=3, a=2, s=4, h=4.2, device_type="GPU")

clip.set_output()


This is the documentation for parameters:
https://github.com/Khanattila/KNLMeansCL/blob/master/DOCUMENTATION.md

I clarify that I do not know if the script is well designed, but it seems to work.