CrendKing / avisynth_filter

DirectShow filters that put AviSynth and VapourSynth into video playing
MIT License
107 stars 8 forks source link

Video hangs quickly with MPC-HC + SVP where ffdshow works. #67

Closed OneOfMany07 closed 2 years ago

OneOfMany07 commented 2 years ago

Environment

Describe the bug

Can playback using ffdshow raw filter, but switching to AvsF doesn't update video anymore. No obvious error in the log to my eyes, but hoping you can help debug this further. Using SVP 4 + MPC-HC + EVR or MadVR (same results).

I get similar results if I try to playback in ffdshow using the other NVIDIA 1080ti I have installed, that has my monitor attached. I wish I knew how to read either SVP's log better, or yours. I also have 2x the entries to pick from in the GPU Acceleration selection area as real hardware (4 x NVIDIA 1080ti entries, and 2 x 4600 Iris entries, and a single Microsoft Basic Render Driver!?!?)

I've already tried uninstalling, then reinstalling all components except SVP's manager. Even reset the SVP settings. I have a bug report in to them, and a forum thread...but I'm hoping you can help while I'm waiting.

I started with Avisynth+ 3.5.1 according to a log, but have upgraded to v3.7.2. When I tried to downgrade again the log text said 3.5.0 so I'm confused where the previous copy came from (it'd been a while since install). This latest 3.5.1 was from the standard release site (same as the 3.7.2).

I have various developer tools installed, including the partial hyper-v platform for Windows Subsystem for Linux 2. I had docker desktop, but uninstalled it to see if that helped (didn't). I've enabled and disabled a few graphics options (GPU scheduling and VRR).

Tried MPV with VapourSynth version of this and it failed similarly on the user end (can't say in the log...I can get one made if that'll help).

To Reproduce

Play any H.264 mkv in MPC-HC I see the first frame or two of video, and audio plays back fine until I pause playback. And I often have to kill a separate task to clean up the video player, beyond the window.

With ffdshow instead I quickly see the green OSD from SVP for the higher framerate and profile it's using.

OneOfMany07 commented 2 years ago

Found what messed up my GPU list. Uninstalling the "openCL and OpenGL compatibility pack" from Microsoft's Store made the GPU list appear sane again.

But just now when I tried to play using AvsF it changed to a green image. ffdshow playback still worked fine. I'll keep poking for a bit. See if a log has something useful now...

CrendKing commented 2 years ago

Try to only use AVSF with the player, and not involve SVP. Put the bare minimum script to AVSF and see if it works.

AvsFilterSource()
return Info()
OneOfMany07 commented 2 years ago

Sorry, how do I use that script? I normally just run MPC-HC, point it at the video, and it plays. They added an external filter entry and I have it configured the way they say... https://www.svp-team.com/wiki/Avisynth_Filter_(AVSF) although the 10 and 16 bit entries are disabled (only 8 bit screen).

It seems like SVP creates the AVS file for each run, and I don't know how or where to override that. I have tried "disable SVP" in their Control Panel, but not with AvsF yet (will go look). Yeah, it plays OK (video looks normal at 25fps...a UK TV show). MPC-HC lists AvsF in the filter list. Status pane in filter's properties has frame numbers that change and other stuff.

As an aside, I've wondered why some of the MEDIATYPEvideo entries in the 2nd image (in their directions above) are just GUID's instead of names like MEDIASUBTYPE...

Attaching AVS logs for disabled and enabled. Enabled just froze the video again after a moment. Oh, it cheated and switched to ffdshow.

SVP-enabled.avs.txt

SetFilterMTMode("SVSmoothFps",1) SetFilterMTMode("AvsFilterSource",3) AvsFilterSource()

ConvertToYUV420() ConvertBits(8)

global source_width = width

SVP-disabled.avs.txt

SetFilterMTMode("SVSmoothFps",1) SetFilterMTMode("ffdshow_source",3) ffdshow_source()

ConvertToYUV420()

global source_width = width

...So I still don't know how to test with the settings you want. I don't know where the AVS that SVP makes is being forced on my player. They're being created (or shown to me) in a roaming profiles area for SVP 4.

CrendKing commented 2 years ago

The "Script to use" is the avs file to override SVP. Create a file with the content I posted. Also uncheck "Enable remote control" so that SVP can't take control over.

If you can play a video with some yellow stats text over, that means the filter is working fine. If not, post log. However, if there is something wrong with the player config or system codec, log alone won't be enough. We shall see.

As an aside, I've wondered why some of the MEDIATYPEvideo entries in the 2nd image (in their directions above) are just GUID's instead of names like MEDIASUBTYPE...

That's just how DirectShow is. DirectShow is a discontinued component. Microsoft won't fix those missing media type names. Just ignore them.

OneOfMany07 commented 2 years ago

OK, yeah...I see it playing with the yellow debug text.

So filter can work, but somehow this + SVP isn't happy. And I assume you don't know any tricks to debugging SVP4?

I already looked in their Event Log for anything interesting. I don't know how to increase the verbosity of logging (they have TONS of global settings that they suggest not messing with). Nor how to look for Avisynth+ errors in the middle of playback.

If you can't help I understand, and you can close this. I appreciate your time.

CrendKing commented 2 years ago

It's good that we can establish a working base. So we know the filter is fine.

Now, for SVP, let's try this. Check the "Enable remote control", so that SVP can inject. First open a video with SVP being disabled. You should still see the picture and debugging text. Then enable SVP. Do you see the whole video suddenly go black or green or hang? If so, then we know for sure SVP is corrupting the stream.

If SVP is the culprit, then we can try debugging their injected script line by line. Their generated script is in their profile dir (under APPDATA)/scripts. The log may also should the script name. The script is just regular avs file. If you have knowledge of AviSynth script, you can edit it, remove all code then add one line at a time. Eventually you can pinpoint which line corrupts the video (most likely gonna be SVSmoothFps(...)). Then you can change around function arguments see if the generated parameters are incorrect for your configuration. For example, in https://github.com/CrendKing/avisynth_filter/issues/65 people report SVP pass P010 format to AVSF, where we require P016 format. Even though that issue is fixed, there could be other undiscovered rare problem that only you experience.

Unfortunately, unless I remote desktop to you and debug by hand, which I strongly tend to avoid, you have to diagnose yourself at this point.

Here is a minimum SVP script you can try if it hangs:

threads = 8  # change to your physical core count

LoadPlugin("<path to svp>\plugins64\svpflow1.dll")
LoadPlugin("<path to svp>\plugins64\svpflow2.dll")

AvsFilterSource()
super = SVSuper("{}")
vectors = SVAnalyse(super, "{}")
SVSmoothFps(super, vectors, """{
    rate: {
        num: 2,
        den: 1
    }
}""", mt=threads)
Prefetch(threads)
OneOfMany07 commented 2 years ago

Thanks for all those ideas.

I want to report back that it just magically started working again. The only changes I can think of are I turned back on the 10 and 16 bit field types I'd disabled before in the MPC-HC external filter properties for AvsF (at least as compared to their wiki instruction's screenshot). I'd assumed having those on would only be bad. To waste bits that my screen can't show anyway. Most of my videos aren't HDR, including the test videos I was using while debugging this.

Other than changing the script manually, you don't know another way to debug Avisynth+ itself...right?

I'm curious to see if upgrading my Avisynth+ to 3.7.2 again will show me any issues again. I was getting SVP to disable after an episode or two of playback (just playing and hitting next chapter near the end to show the next one) until I reverted to 3.5.1. It seemed at a random spot, and I wasn't always watching to notice the OSD text.

Oh, and that thread value you said to set to my physical core count...Oddly I saw a 17 when I looked at the SVP AVS script. I have a 4c/8t CPU (i7-4790k basically a Haswell with a bug fix or two). It might have had the max quality slider set, which isn't where their "assess device performance" chose to set it. But I'd seen low device usage(25-35%), and even raising that to max only left me with 50% CPU usage (with a browser game playing too). I'd seen a claim that SVP was CPU bound generally. That it wants more cores.

CrendKing commented 2 years ago

10 and 16 bit field types I'd disabled before in the MPC-HC external filter properties for AvsF

Or equivalently, you can uncheck those format in AVSF's setting page, and leave MPC-HC as default.

Other than changing the script manually, you don't know another way to debug Avisynth+ itself...right?

For myself, since I have AviSynth+ source code as well as development environment, I can debug their code function by function. If you are developer yourself, you can do the same: build AVS+ with debug config, put it in MPC-HC directory, and AVSF will use it. Attach debugger to MPC-HC process, set breakpoint and there you go.

SVP only works in AVS 3.5.1, last time I checked. Only use AVS 3.6 and newer if you are doing other effects.

Don't worry about the thread number too much. It is highly system and content dependent.

Shall I close this issue?

OneOfMany07 commented 2 years ago

It probably won't hurt anything to keep them enabled. I was just playing around with things to see if I could improve anything. And to learn more about the parts. Unfortunately that leads to situations like this where I don't know what caused the failures, but am glad they're gone for the moment.

put it in MPC-HC directory That's a handy tip. Not sure I'm desperate enough to compile my own copy yet, but even the ability to override things by file placement is nice to know. I'm pretty sure SVP is doing the same thing for their special copies. I already got Plex's player to use the modified mvp dll. I just wish I understood more about what was going on. Like what that dll was changing...was it just adding vaporsynth support? Or what...

I'll close it. Let me know if you need someone to run something or another set of eyes. I keep meaning to work on software development again, but haven't found something I can both work on and am motivated for. Like I'd love to fix the SVP control panel's GPU selection feature for example :D. If only it was open source.