oltodosel / interSubs

Interactive subtitles for mpv. Instantly translate selected word/sentence.
MIT License
225 stars 20 forks source link

Sometimes subtitles are not visible/video stutters #12

Closed stebotron closed 6 years ago

stebotron commented 6 years ago
  1. Sometimes every second or third (I haven't really noticed any system) subtitle is not displaying (or invisible to be exact, since I can translate "invisible" words with cursor over them) if "extend_subs_duration2max_B = True". Such "invisible" subtitles appear for a fraction of second and then become invisible.

  2. Video stutters a little on subtitle change, but this is noticable and quete annoying.

System: ArchLinux, Python 3.7.1, KDE plasma 5.14.2

oltodosel commented 6 years ago

Does it happen in other WM?

stebotron commented 6 years ago

Number 1 happens only in KDE, there is no such issue in LXDE. Number 2 happens both in KDE and LXDE.

oltodosel commented 6 years ago
    1. Most likely KDE hijacks window focus and interSubs 'thinks' mpv window was switched or minimized with xdotool getwindowfocus getwindowname.
    2. Maybe try playing with kwin settings.
    3. Or use different WM. Can't help there.
    1. Try increasing mpv's cache. If your /tmp is on the same disk as a video file - it might cause stutters from mpv's side.
    2. Looks at cpu usage during the sub change with something like htop -d1. Although it works well on 8y.o intel i3
    3. Is also might be something with composite manager. Try a different one.
stebotron commented 6 years ago
  1. I tried to remove completely section "# hide subs when mpv isn't in focus or in fullscreen" with "xdotool getwindowfocus getwindowname". No effect at all. Problem remains.

  2. CPU usage < 10%, /tmp is in the ram. Anyway, just wanted to let you know, that there is such problem with video stuttering with different WM.

oltodosel commented 6 years ago

Can't reproduce, so there's nothing I can help you with besides as I've said previously - try another composite manager. If you'll find a solution - be sure to post it.

stebotron commented 6 years ago

Stuttering is rather subtle, and can be clearly seen only in dynamic scenes, maybe you are just not noticing it? I tried kwin manager in KDE and compton composite manager in LXDE. Both have stuttering. Just tried xcompmgr, small stuttering remains. Missing subtitles only with kwin.

oltodosel commented 6 years ago

Maybe try xcompmgr. Idk. Because your description suggest that your composite manager can't handle it. Try changing rendering backend. I might be mistaken, but I vaguely remember something similar with other C.M. back when I wrote interSubs.

Believe me, if there was some stuttering at my system, I would've noticed.

p.s. You can always use Tk version. It doesn't need C.M.

stebotron commented 6 years ago

By the way in KDE when "extend_subs_duration2max_B = False" there are no problems with missing subtitles, only when "extend_subs_duration2max_B = True". This is very strange. Anyway, thanks for your help and very useful software!

stebotron commented 6 years ago

I solved stuttering by changing video output in mpv from vdpau to gpu (mpv -vo gpu). Problem with missing subtitles when extended duration in kde still remains.

oltodosel commented 6 years ago

As I've suggested in previous message, have you tried changing rendering backend at kwin? Or simply switch from kwin to other C.M. (if it's possible in KDE)

stebotron commented 6 years ago

Yes, I tried all, xrender, OpenGL 2, OpenGL 3.1, disabling vsync, no effect. I just disabled extended duration, this is not so important. I can switch to openbox+compton instead of kwin while running KDE, then I don't have missing subtitles, kind of a solution, but I don't see the point to do so. I stay with kwin and without extended duration for now. Maybe I'll find a solution with time other then switching from kwin to something else.

stebotron commented 6 years ago

Solved missing subtitles with extended duration by adding small delay "time.sleep(0.1)" in "def render_subtitles" after the line "self.clearLayout('subs2')" (line 1452 in current version).

oltodosel commented 6 years ago

Strange. But since it works for you - good. See if it works with sleep(0.01) - it should be plenty. 100ms is quite noticeable delay with subtitles.

stebotron commented 6 years ago

It seems to me that self.clearLayout without delay was applying right after new subtitle appears. Maybe it is too slow (if kwin is used) or called a little later then necessary for some reason. Short (few words) subtitles where missing much more often, maybe because they are faster to render and they are rendered before self.clearLayout apply? At least that is what I thought when I added this line. I haven't understood the logic of the program completely yet. Sleep(0.01) work just fine too. Thank you.