Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video freezing while switching subtitles #76

Closed
chainikdn opened this issue Jun 28, 2022 · 17 comments
Closed

Video freezing while switching subtitles #76

chainikdn opened this issue Jun 28, 2022 · 17 comments
Labels
bug Something isn't working

Comments

@chainikdn
Copy link
Contributor

chainikdn commented Jun 28, 2022

Regression in ver. 1.4.1.
Switch between subtitles -- notice video freezing from several seconds to forever.
Environment: MPC-HC, madVR, AVSF, no script, no SVP.
For me this only happens with MPC-HC+madVR, doesn't happen with other renderers (EVR, MPC) or other players (MPC-BE, PotPlayer). However another user said "it also freezes on other renderers".

@chainikdn chainikdn added the bug Something isn't working label Jun 28, 2022
@CrendKing
Copy link
Owner

I tried all combinations below on latest version and can't repro

  • MPC-HC / MPC-BE
  • madVR / EVR
  • Internal / External subtitles
  • Even tried switch audio tracks

When you say "Regression in ver. 1.4.1." do you mean it only happens in 1.4.1 and not 1.4.2 and 1.4.3, or since 1.4.1?

Also, I probably need a video to help repro.

@chainikdn
Copy link
Contributor Author

chainikdn commented Jun 29, 2022

or since 1.4.1?

this

I probably need a video to help repro.

https://www.svp-team.com/forum/viewtopic.php?pid=80667
https://www.youtube.com/watch?v=leq8ov-iaD0

@CrendKing
Copy link
Owner

Tried so many times, and only managed to "freeze" for 1 second, twice. Seems extremely rare, and only happens for the remote injection scenario. Never happens with fixed script.

Probably need a more reliable way to repro to handle this issue.

@chainikdn
Copy link
Contributor Author

chainikdn commented Jul 1, 2022

only happens for the remote injection scenario. Never happens with fixed script.

no script, no SVP

external AviSynth Filter disabled -> runs normally;
SVP not running, external AviSynth Filter enabled -> freeze on subtitle change;
SVP running, external AviSynth Filter enabled -> runs normally.

@Skaitliuk
Copy link

Hello, i'm the user, who posted this on SVP forum, I recorded another video with more info on screen, maybe it will help. basically, I'm cycling through the subtitles with a hotkey, and freezes happen. I reverted avisynth filter to version v1.3.1, and the freezes are gone.
https://www.youtube.com/watch?v=cAPgSQknBPs

@CrendKing
Copy link
Owner

I tried the exact same setup and can't reproduce. There is always slight freeze when switching tracks, because that's basically equivalent to re-opening the video file. However, there shouldn't be a difference between remote injection vs fixed script. They go through the same process. Would you please upload log of the those two scenarios?

@Skaitliuk
Copy link

Would you please upload log of the those two scenarios?

I don't really understand how this works and what scenarios you need. I uploaded log with filter version 1.4.3 and no SVP running (when freezes happen), 1.4.3 with SVP running and 1.3.1 no SVP. Is this what you wanted? each time I start the same video and cycle through subtitles ~8 times.

1.3.1 no svp running.log
1.4.3 no SVP running.log
1.4.3 SVP running.log

@CrendKing
Copy link
Owner

The second log shows lots of message about "Rejecting source sample due to start time going backward". I'm theorizing that you are facing a race condition that I can reproduce locally, which is the usual nature of race condition.

That race condition exists because I deliberately chose to not lock most of AddInputSample() exclusively for performance concern. However, if it is the case of this bug, we may have to sacrifice that bit of performance for correctness.

Please test https://github.com/CrendKing/avisynth_filter/actions/runs/2768521271. If it indeed fixes your problem, we can discuss about performance.

@Skaitliuk
Copy link

The freezes are gone for me. Logs attached just in case.
avisynth_filter.log

@CrendKing
Copy link
Owner

Thanks. I optimized the logic a bit. Could you please test this?

https://github.com/CrendKing/avisynth_filter/actions/runs/2831024679

@Skaitliuk
Copy link

Freezes are back again when switching subtitles.
avisynth_filter.log

@CrendKing
Copy link
Owner

CrendKing commented Aug 12, 2022

I think I found the root cause. Hope https://github.com/CrendKing/avisynth_filter/actions/runs/2845275349 fix for real.

Also reverted all the "performance-hitting" change above.

Technical detail for the record:

Switching subtitle basically stops the filter chain for a brief moment, and restart the chain. This means the input pin's Inactive() is called then Active().

The current input pin's Inactive() calls BeginFlush() followed by a EndFlush(). This sets _isFlushing to true then back to false, which leaves a small window for the filter to receive input samples before Active(). If upstream indeed sends an excessive sample with bad start sample time in that window, we are screwed from there.

This change moves the EndFlush() to the end of Active(), guaranteeing all new samples are post-flush, with correct start time.

@Skaitliuk
Copy link

yes, subtitles freezes are gone, but now MPC-HC freezes(not responding) on video seek.
With MPC renderer, MPC-HC freezes on the first video time seek;
With MadVR, freezes when I seek a paused video....
avisynth_filter.log

@CrendKing
Copy link
Owner

CrendKing commented Aug 13, 2022

Sorry, I forgot to test the change on some video renderers, such as EVR and MPC. Fix: https://github.com/CrendKing/avisynth_filter/actions/runs/2851210801

@Skaitliuk
Copy link

No more issues from me, everything works, thank you

@ssssssbbb
Copy link

ssssssbbb commented Aug 14, 2022

Potplayer with madVR renderer freezes on immediate seek after start playing, EVR(CP) is OK, and MPC-HC is OK with both renderers.

1.log

This version is good, https://github.com/CrendKing/avisynth_filter/actions/runs/2831024679, later ones are not.

@CrendKing
Copy link
Owner

CrendKing commented Aug 15, 2022

I can't reproduce the issue, and I can't find anything extraordinary from your log. Again, even if I can repro, most of the time there is not much I can do, as both PotPlayer and madVR are closed source.

If you really want to use PotPlayer, and you don't experience this issue, feel free to use previous working version. v1.4.4 does not introduce any new feature or performance improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants