Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#4041 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,625
|
What filter(s) do you need that are not available natively ? If you need to apply an exclusive ffmpeg filter, and there isn't something similar already available - ffmpeg output can be piped to a vs script (vsrawsource input), and that can be piped back into ffmpeg with vspipe or native ffmpeg vpy demuxer |
![]() |
![]() |
![]() |
#4042 | Link | |
Registered User
Join Date: Jul 2019
Location: Russia
Posts: 88
|
Quote:
I am trying to fix videos where good, normal scenes and very dark scenes are constantly alternating. I tried using "-vf pp=al", it just got a little better. Even if try to manually set the brightness and contrast values for a specific frame, then get disgusting grains, noise and others. I would be glad to have advice for this situation. Last edited by Jukus; 12th October 2020 at 16:42. |
|
![]() |
![]() |
![]() |
#4043 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,625
|
Quote:
There are several "auto" leveling plugins in avisynth; if you're on windows you can use those in the vpy script. Avisynth+ is supposed to be crossplatform now, but I'm not sure if you can load avs plugins into vpy scripts on other platforms than Win The ffmpeg/vpy piping back and forth workaround is not ideal; lots of overhead piping back and forth. |
|
![]() |
![]() |
![]() |
#4044 | Link |
Registered User
Join Date: May 2011
Posts: 370
|
Just as a curiosity sort of, you could pipe ffmpeg cmd line in vapoursynth directly in your script.
It is not ideal, it is one way only, no searching etc. vs script is always python script so all python woo-doo is available in vs script as well. Not sure how many folks realize that. Code:
import vapoursynth as vs from vapoursynth import core import subprocess import ctypes ffmpeg = r'C:\tools\ffmpeg.exe' source_path=r'C:\videos\video.mp4' clip = core.lsmas.LibavSMASHSource(source_path) #this clip is not not needed, just to get width and height clip = core.std.BlankClip(clip) w = clip.width h = clip.height Ysize = w * h UVsize = w * h//4 frame_len = w * h * 3 // 2 #YUV420 command = [ ffmpeg, '-i', source_path,'-vcodec', 'rawvideo', '-pix_fmt', 'yuv420p', '-f', 'rawvideo', '-'] pipe = subprocess.Popen(command, stdout = subprocess.PIPE, bufsize=frame_len) def load_frame(n,f): try: vs_frame = f.copy() for i, size in enumerate([Ysize, UVsize, UVsize]): ctypes.memmove(vs_frame.get_write_ptr(i), pipe.stdout.read(size), size) pipe.stdout.flush() except Exception as e: raise ValueError(repr(e)) return vs_frame try: clip = core.std.ModifyFrame(clip, clip, load_frame) except ValueError as e: pipe.terminate() print(e) clip.set_output() |
![]() |
![]() |
![]() |
#4045 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
VideoNode has a member function called output(), see: https://github.com/IFeelBloated/Oyst...a/Alpha.py#L49
|
![]() |
![]() |
![]() |
#4046 | Link |
Registered User
Join Date: May 2011
Posts: 370
|
yes, thats much better, using some filters on clip and then give it to ffmpeg:
Code:
import vapoursynth as vs from vapoursynth import core import subprocess ffmpeg = r'C:\tools\ffmpeg.exe' source_path=r'C:\videos\video.mp4' clip = core.lsmas.LibavSMASHSource(source_path) clip = clip.std.Expr(['x 20 -','','']) #just to demonstrate using some filters before ffmpeg ffmpeg_cmd = [ffmpeg, '-f', 'yuv4mpegpipe', '-i', '-','-c:v', 'libx264', 'F:\OUT\output.mp4'] process = subprocess.Popen(ffmpeg_cmd, stdin=subprocess.PIPE) clip.output(process.stdin, y4m = True) process.communicate() |
![]() |
![]() |
![]() |
#4047 | Link |
Registered User
Join Date: May 2011
Posts: 370
|
or how about this,
vs -> ffmpeg -> prores - > vs again -> vspipe -> whatever is it too crazy? Code:
import vapoursynth as vs from vapoursynth import core import subprocess ffmpeg = r'C:\tools\ffmpeg.exe' INTERMEDIATE = 'F:\OUT\prores.mov' source_path=r'C:\videos\video.mp4' clip = core.lsmas.LibavSMASHSource(source_path) clip = clip.std.Expr(['x 20 -','','']) #just to demonstarte using some filter before ffmpeg ffmpeg_cmd = [ffmpeg, '-f', 'yuv4mpegpipe', '-i', '-', '-c:v', 'prores', '-an', '-y', INTERMEDIATE] process = subprocess.Popen(ffmpeg_cmd, stdin=subprocess.PIPE) clip.output(process.stdin, y4m = True) process.communicate() clip = core.lsmas.LibavSMASHSource(INTERMEDIATE) clip = clip.std.Expr(['x 20 +','','']) #yet some more filters clip.set_output() Last edited by _Al_; 12th October 2020 at 23:19. |
![]() |
![]() |
![]() |
#4049 | Link | |
Registered User
Join Date: May 2011
Posts: 370
|
Quote:
Oh, I guess it is used for more instances, only one time created. Last edited by _Al_; 13th October 2020 at 01:54. |
|
![]() |
![]() |
![]() |
#4050 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
@Inject can dynamically inject any property into native types in python (stuff like list, or VideoNode), this is not normally allowed by python
Materialize() is used to speed up very slow scripts, it materializes intermediate results so they won’t be re-evaluated once things exceed max memory limit |
![]() |
![]() |
![]() |
#4051 | Link |
Registered User
Join Date: Jul 2019
Location: Russia
Posts: 88
|
How can make a smooth transition between different filters? For example:
Code:
clip1 = core.std.Trim(clip, 6223, 8361) clip1 = adjust.Tweak(clip1, hue=0.0, sat=1.3, bright=8.0, cont=1.1, coring=True) clip2 = core.std.Trim(clip, 8362, 9887) clip2 = adjust.Tweak(clip2, hue=0.0, sat=1.4, bright=15.0, cont=1.3, coring=True) |
![]() |
![]() |
![]() |
#4052 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,625
|
Quote:
|
|
![]() |
![]() |
![]() |
#4054 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,625
|
Quote:
Think of it like this: You have 1 clip. But 2 filtered versions. 1st clip fades out, but 2nd clip fades in , so the filter transition is applied smoothly over period "x" If that doesn't do what you want, another way would be to write an animation helper function in python, using std.FrameEval . I'm not strong in python , someone can help you with that Last edited by poisondeathray; 14th October 2020 at 18:56. |
|
![]() |
![]() |
![]() |
#4055 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,625
|
Here is an example of an parameter animation helper function, using tweak's sat .
Interpolation is linear from startframe to endframe , from sat0 to sat1 . (In this example from frame 100 to frame 160, sat=1 to sat=3) You can add other parameters, but linear interpolation and animation does not necessarily work with all parameters for all types of filters Code:
import vapoursynth as vs import adjust import functools core = vs.get_core() c = core.colorbars.ColorBars(format=vs.YUV444P10) c = core.std.SetFrameProp(c, prop="_FieldBased", intval=0) # progressive c = core.resize.Point(c,format=vs.YUV444P8) c = c * 300 c = core.std.AssumeFPS(c, fpsnum=30000, fpsden=1001) c = core.text.FrameNum(c, 7) def satanim(n, sat0, sat1, startframe, endframe): if n < startframe: return adjust.Tweak(c, sat=sat0) elif n > endframe: return adjust.Tweak(c, sat=sat1) else: return adjust.Tweak(c, sat=round(n-endframe)*(-1*sat0)/(endframe-startframe) + round(n-startframe)/(endframe-startframe) * sat1) ani = core.std.FrameEval(c, functools.partial(satanim, sat0=1, sat1=3, startframe=100, endframe=160)) ani.set_output() |
![]() |
![]() |
![]() |
#4056 | Link |
Registered User
Join Date: Jul 2019
Location: Russia
Posts: 88
|
@poisondeathray
Thanks, I'll try again later. I tried CrossFade and it really works as I suggested, that is, it does blending, while it loads the CPU very much. It also changes the total number of frames. Last edited by Jukus; 14th October 2020 at 22:51. |
![]() |
![]() |
![]() |
#4057 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,137
|
Note, that Jukus problem as posed, only applies correction 6223, 8361, and 8362, 9887, [ie below 6223 and above 9887 not touched]
whereas PDR script satanim alters entire clip [I assume that CrossFade does too]. This would seem to be correct, pointing this out to Jukus, that will not adjust only frames 6223 -> 9887. [CPU very much comment] Of course the blending thing would not be appropriate where tweening eg HUE [circular]. EDIT: Quote:
Try the PDR Satanim() thing, I think will preserve length. EDIT: Ignore this EDIT: Use trim to only process required range with satanim, then splice back into original clip.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th October 2020 at 23:22. |
|
![]() |
![]() |
![]() |
#4058 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,625
|
The helper function returns original clip, unless it's within startframe, endframe range. Length is unchanged . It's similar to animate() in avisynth, where parameters of a function are animated. It's a PITA IMO to setup. It's 100000x (or maybe more like 10000000x) easier to do any type of keyframe interpolation in a NLE or a GUI . And you can easily use other types of animation interpolation (not just linear), and some can GUIs have curves
Instead of using a dissolve function, the other way is to create an alpha channel control clip (white fade to black, or vice versa) where you use Overlay() with the alpha channel mask. This way the clip length is unchanged. This is essentially an animated blend between 2 or more layers. |
![]() |
![]() |
![]() |
#4059 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,137
|
Quote:
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
![]() |
![]() |
![]() |
#4060 | Link |
Registered User
Join Date: Jul 2019
Location: Russia
Posts: 88
|
I've already thought about some kind of graphic editor, but I still need filters that only Vapoursynth / Avisynth have.
Сan quickly encode the video in a graphics editor, and only then do it good in Vapoursynth, but that's bd 90 minutes video. |
![]() |
![]() |
![]() |
Tags |
speed, vaporware, vapoursynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|