Log in

View Full Version : Applying HLSL Shaders To Video With Avisynth?


pixel
14th January 2017, 20:05
I have read that avisynth can do the following:

1. Load a video.
2. Apply an HLSL shader to the video frames.
3. Save the video.

This plugin down below is supposed to make this possible:

https://github.com/mysteryx93/AviSynthShader

I have never used avisynth before, so I'm a bit lost.

Can anyone tell me how to do this?

I need an example script that tells Avisynth to:

1. Load video
2. Apply HLSL shader(s)
3. Save result

Also, is there any another software that can apply HLSL shaders to video frames and save the result to a video file?

Thank you all very much! :thanks:

TheFluff
15th January 2017, 06:29
http://avisynth.nl/index.php/Getting_started

FranceBB
15th January 2017, 06:38
FFMpegSource2("yourvideo.mkv" fpsnum=24000, fpsden=1001, atrack=-1)

Converttoyv12()

SuperRes(Input, Passes=1, Str=1, Soft=0, Upscale="""nnedi3_rpow2(2, cshift="Spline16Resize")""", lsb_upscale=false, PlanarOut=true, MatrixIn="Rec709", MatrixOut="Rec709", fWidth=1920, fHeight=1080)

_________________

That is the avs. Basically you use an indexer like ffms2 to open both audio and video and then you filter it using the plugin you posted about. Please note that you need the plugin to be in your plugins folder and/or to load it and its dependencies when you call it. Then, just download virtual dub and drop the avs in that program; you will see the result of the avs and you will be able to encode it.

pixel
15th January 2017, 08:42
I am going to try what you posted.

Where do the HLSL shaders go in this example?

Surely you have to specify something like this somewhere:

Apply bloom.hlsl
Apply sharpen.hlsl
Apply anglecorrect.hlsl

:thanks:

Selur
15th January 2017, 10:09
Looking at AvisynthShader page:
Assuming you installed Avisynth and placed the AvisynthShader and the FFmpegSource plugin inside the plugins folder:
ConvertToShader(1)
FFMpegSource2("yourvideo.mkv")
Shader("bloom.hlsl", Output=2)
Shader("sharpen.hlsl", Output=3)
Shader("anglecorrect.hlsl", Clip1=2, Clip2=3, Output=1)
ShaderExecute(last, Input, Clip1Precision=1, Precision=3, OutputPrecision=1)
ConvertFromShader(1)
should apply the shaders,.. (you still need to use the avisynth script with a tool that supports Avisynth like ffmpeg/mencoder/mplayer/VirtualDub/... to process the script and create the video output,..)
-> you might want to get accustomed with Avisynth in general and start with the link TheFluff posted to understand the whole thing,..

pixel
15th January 2017, 15:19
Thank you very much - I am new to Avisynth/frameserving.

I am going to try the suggested steps.

I'll report back if I get results.

:thanks::thanks::thanks:

johnmeyer
15th January 2017, 21:21
You not only posted this same exact thing at VideoHelp, which is OK, but now you've cross posted this exact same thing elsewhere in this forum (in the General section). That is against the rules of this forum. You should delete that other post.

FranceBB
16th January 2017, 00:53
@pixel... I used SuperRes because it was the first function of the Shader.avsi you linked (I was in a hurry as I had to go to work; morning shift, sadly). Anyway, using HLSL it's pretty much the same as Selur wrote. ;)

pixel
16th January 2017, 17:54
@JohnMeyer

An inventor has brought us a video-processing prototype which is basically 4 custom-developed HLSL shaders that run in realtime inside Media Player Classic.

The results are great in MPC, but we need to find a way to process 20 - 30 test videos a day with this, and SAVE the result to a pixel-accurate video file each time.

This Avisynth plugin seems to be the only technology that can do this.

I'm trying very hard to get Avisynth/Shader Plugin/Virtualdub to work together, but I'm completely new to Avisynth.

So please have some patience with me. =)

johnmeyer
16th January 2017, 18:04
You completely misunderstood my post: I was simply trying to help you to avoid violating the rules of this forum so that one or both of your threads don't get closed. I was not being "inpatient" with you.

pixel
16th January 2017, 18:14
I have deleted the other post - I didn't see the delete option when I first clicked "edit". I thought a moderator might have to delete it.

Thanks!