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. |
|
|
Thread Tools | Search this Thread | Display Modes |
25th February 2020, 03:50 | #1 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
DirectShow filter as Avisynth source (other than ffdshow)?
I might be asking a dumb question since I'm very new to Avisynth world. I'm trying to use Avisynth to load some frame manipulation script in MPC-HC / MPC-BE, which allows me to add subtitle or change FPS. I'd done a lot of searches, but AFAIK ffdshow is the only DirectShow filter that can provide the video being played as an Avisynth clip (ffdshow_source), am I correct? One alternative is Daum PotPlayer, which basically has the ffdshow's Avisynth (AND VapourSynth, good job!) built in. Unfortunately it is closed source. All other Avisynth source filters requires a filename as parameter.
I'm asking because ffdshow has stopped development for years, and VapourSynth is not supported (by briefly looking at it). ----- Update: wrote my own filter at https://github.com/CrendKing/avisynth_filter. See this post. Last edited by CrendKing; 9th March 2020 at 21:08. |
25th February 2020, 16:11 | #2 | Link |
Registered User
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,407
|
What is wrong with using a filename?
PotPlayer is closed source while also using open source code...
__________________
madVR options explained |
25th February 2020, 18:26 | #3 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
Well, it is a tad more inconvenient to have to edit a text file every time watching a video than just double clicking or passing an argument to the executable from a batch. Well, technically I would write a simpler filter that automatically generate an avs script and feed to the player, but I just feel so dumb if I have to do that. It does not feel right.
I'm experimenting on implementing just the Avisynth loading logic from ffdshow on a filter. It seems pretty straight forward. If nobody has ever done this before, I guess there must be a good reason. That's also why I refuse to use PotPlayer. |
1st March 2020, 07:07 | #4 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
You can install just the ffdshow raw video filter and audio processor, At least the custom installer options suggest you can. I've never installed them without the rest of ffdshow, but it's worth a look. They can be added to MPC-HC as external filters.
To configure them, you can double click on each in MPC-HC's external filters section. Or.... someone told me how to create shortcuts for opening the configurations as it's more convenient. They work on XP. C:\WINDOWS\system32\rundll32.exe "C:\Program Files\ffdshow\ffdshow.ax",configureRaw C:\WINDOWS\system32\rundll32.exe "C:\Program Files\ffdshow\ffdshow.ax",configureAudioRaw Does ffdshow's Avisynth filter allow you to change the frame rate? I'm reasonably sure frame rate stuff in a script is ignored. Probably because it could mess with the audio sync.I tried AssumeFPS(50) in ffdshow but it had no effect. |
9th March 2020, 21:06 | #5 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
Anyways, I wrote a filter to replace ffdshow. The project is at https://github.com/CrendKing/avisynth_filter . Comparing to ffdshow, I put NV12, P010 and P016 into support since they are more popular 4:2:0 formats than YV12. I've never seen 4:2:2 or 4:4:4 video, so I did not put effort into writing those transform code, yet.
I understand AviSynth has large amount of internal functions and plugins, 99% of which I have no idea what they do. I just tested against my own use cases and some simple internal functions. I've been running it for like a week without major problem. If you are interested, feel free to give it a try, or fork it. Just remember, if you ever publish your own version, release it under GPL (since AviSynth is under GPL). Don't be another PotPlayer. I've briefly studied VapourSynth C API. It largely resembles AviSynth+'s API. So with a few changes, I should be able to migrate the logic to VapourSynth. |
9th March 2020, 21:14 | #6 | Link | |
Registered User
Join Date: May 2019
Posts: 42
|
Quote:
Well, my filter does not have this problem. If you put AssumeFPS(50) on a 25fps video, every other frame will be a duplicate frame. If you put AssumeFPS(15) on a 30fps video, every other frame will be skipped. Maybe you could give it a try. Last edited by CrendKing; 9th March 2020 at 21:19. |
|
10th March 2020, 02:57 | #7 | Link |
Registered User
Join Date: Nov 2008
Posts: 137
|
Hi, i just tested your filter. Not sure if there is a problem with my system, but the audio is not in sync with video. Tried this with mpc-hc. Used something simple like ChangeFPS(23.976)
I did see that the player rate changed in mpc-hc. By the way, as far as i know in ffdshow avisynth filters changing frame rate do work like the ChangeFPS() for example. But the buffer back/ahead sometimes have to be adjusted sometimes for it to work. However ffdshow reports in the info section the source's original frame rate. however whatever player i might be using reports the changed frame rate. Also is there a buffer back/ahead option in your filter? Like the one in ffdshow or is this even needed? Does the filter work with capture cards as a source? It just crashed with an error when i tried that. |
10th March 2020, 20:03 | #8 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
I tried AssumeFPS, ChangeFPS and ConvertFPS in MPC-HC. Did not see audio sync problem. I did mess up with the x64 release though (it had a wrong old version). I reuploaded the archive.
------------- About ffdshow's buffer option. According to their wiki, it is used to allow filters to access a configurable range of frame within the current position. I implemented a similar buffer in the filter. Here's the detail. In DirectShow, the upstream filters usually process a few frames ahead of time (like prefetch), and send them down to the renderer with a "render timestamp". The renderer (e.g. madVR) caches whatever it receives and presents them when the time comes. The heavier the system is under load, the shorter the prefetch becomes (could even lag behind, where it starts to drop frames). This filter just saves all frames between the tip of the prefetch and the current play timestamp. Once a frame is "out of sight", it is discarded from buffer. Like ffdshow, if any frame is requested outside of the buffer range, the nearest one is returned. Whenever a seeking happens, I just flush the buffer to avoid the "ghost frame" problem I had with ffdshow. Because this mechanism totally relies on the upstream (or more specifically splitter), I do not provide any option for it. If anyone finds a use case where "out of sight" frames are needed, I could provide option to save those extra frames. ------------- About the crash, first please try the current archive. If it still crashes, I need more information (e.g. frame rate, color format, duration, etc). I can upload a debug version if you'd like to help, because I do not have a capture card. Last edited by CrendKing; 10th March 2020 at 20:33. |
11th March 2020, 02:45 | #9 | Link |
Registered User
Join Date: Nov 2008
Posts: 137
|
It must be my computer that's having issues, tried a different pc and there was no audio sync problem.
However mpc-hc crashed again as soon as i tried to use a capture card. I uploaded a screenshot of the error message. Let me know if you need more info and i would be glad to test a debug version thanks in advance. Frame rate is at 29.97 original, YUY2 color format. Last edited by Milardo; 11th March 2020 at 03:18. |
12th March 2020, 04:37 | #10 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
I did not have YUY2 video, so I did not implement that as input format. But if you use LAV Filters, they should convert it into some 4:2:0 format such as NV12. Should not be a crash. Unless something else is in the filter graph?
The attachment is still pending, so I can't tell for sure. If there is not private in the video, I wonder if you could send me a sample for test? Last edited by CrendKing; 12th March 2020 at 05:10. |
1st May 2020, 10:18 | #12 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
I've worked with Milardo to hunt down bugs and bring improvements. I released version 0.3 a while ago and haven't found any problem with it. If you are interested in using AviSynth in a video player with DirectShow support (e.g. MPC-HC/BE), please give it a try.
|
6th June 2020, 06:06 | #13 | Link |
47.952fps@71.928Hz
Join Date: Mar 2011
Posts: 940
|
Would this work in something like SVP?
Say, I threw in a hi10p encode to interpolate. This would accept P010 without reducing the quality in the flow chain to allow it to be interpolated, as if it were using FFDShow? SVP requires FFDShow and its limited support of formats. I can use the Vapoursynth port to get it to play back 10bit with SVP's modified MPV player. But, say, I want to use MPC-HC (madvr, et al) instead. Without having to reduce to 8bits. Would this be the tool for me?
__________________
Win10 (x64) build 19041 NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4) NTSC | DVD: R1 | BD: A AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
|
9th June 2020, 16:04 | #14 | Link |
Registered User
Join Date: May 2019
Posts: 42
|
My filter is pretty much a replacement of ffdshow (regarding the AviSynth part). So if there is anything ffdshow can but my filter can't do, let me know.
More specifically, the filter should work with SVP. Also individually the filter supports P010 format. However, I remember SVP only works on YV12 input, so you need to either put something like ConvertBits(8) in your script to convert that 10 bit video to 8 bit, or simply uncheck P010 in the setting page (in this case, LAV Video Decoder will do the conversion, which could be more efficient). Here is a simple script to use SVP (doubling framerate): Code:
AvsFilterSource() LoadPlugin("plugins\SysInfo\SysInfo64.dll") LoadPlugin("plugins\SVPflow\windows\x64\svpflow1.dll") LoadPlugin("plugins\SVPflow\windows\x64\svpflow2.dll") super = SVSuper("{gpu: 1}") vectors = SVAnalyse(super, "{}") SVSmoothFps(super, vectors, "{rate: {num: 2"}}", mt=SI_LogicalCores()) Prefetch(SI_LogicalCores()) |
9th June 2020, 16:49 | #15 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
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 ??? |
|
9th June 2020, 17:10 | #16 | Link |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
Is it? Why?
__________________
Groucho's Avisynth Stuff |
9th June 2020, 17:17 | #17 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Well I cant test, (I dont have hyperthreading), just 4 physical. [but for me Prefetch(4) or 3 or 2 near same when encoding, I now use 4, just recently started using Prefetch].
But has been suggested as best by Atak_Snajpera (I think) and others as performant, especially when also encoding, encode needs some CPU too.
__________________
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; 9th June 2020 at 17:52. |
9th June 2020, 17:20 | #18 | Link |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
I see. I suppose that makes sense.
__________________
Groucho's Avisynth Stuff |
9th June 2020, 23:01 | #19 | Link |
Registered User
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
|
The following follows a recommendation from Myrsloik a while ago:
Code:
Prefetch(Min(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8)) For my CORE i5 (two physical cores plus HyperThreading) this means a prefetch value of 4, and this really works best for me - I did make extensive speed and stability tests. |
10th June 2020, 02:25 | #20 | Link |
47.952fps@71.928Hz
Join Date: Mar 2011
Posts: 940
|
It works with YV12 because it depends on FFDShow which only has YV12. They'd use something else if it was available.
I'll let them know you made this and show this to them. I'd rather not depend on MPV for 10bit SVP. I'm looking for fidelity in the workflow and still keep MadVR.
__________________
Win10 (x64) build 19041 NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4) NTSC | DVD: R1 | BD: A AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
|
|
|