4e6 / mpv-reload

mpv plugin for automatic reloading of slow/stuck video streams
MIT License
118 stars 12 forks source link

external files are not connected #13

Open AdventurerRussia opened 2 years ago

AdventurerRussia commented 2 years ago

Hello, there is such a problem. If I opened the video and pulled the subtitles to the player from another folder or they had a different name, then after reloading these subtitles do not remain, and are included that are stitched or have the name of the video itself, is there a way to solve this problem?

4e6 commented 2 years ago

Hi, thanks for reporting. Please provide some details on your setup, and how you load the subtitles. I was not able to reproduce the issue when using the --sub-file option:

AdventurerRussia commented 2 years ago

I mean what if the subtitle and video names are not the same and if they are in different folders for example. then when using your script it does not connect them. Can the script support this? so that it remembers the tracks that were connected before the reboot.

I videotaped myself dragging a file with a different name and then reloading through your script, and it does not connect this file after reloading. Also on the video you can see that I used a clean player build without scripts and settings https://disk.yandex.ru/i/7ceYL-moqDuVHg

AdventurerRussia commented 2 years ago

@4e6

4e6 commented 2 years ago

I see. I'm not sure what's happening when you drag the subtitles file in the player window. Can you please run the same scenario with --msg-level='reload=debug' option and show me the log https://github.com/4e6/mpv-reload#debugging

AdventurerRussia commented 2 years ago

Microsoft Windows [Version 10.0.22000.493] (c) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.

C:\Users\overe\Desktop\mpv-x86_64-20220116-git-1ba0547>mpv --no-msg-color --msg-level='reload=debug "C:\Торенты[VCB-Studio] Ryuuou no Oshigoto! [Ma10p_1080p][VCB-Studio] Ryuuou no Oshigoto! [01][Ma10p_1080p][x265_flac_aac].mkv" (+) Video --vid=1 () (hevc 1920x1080 23.976fps) (+) Audio --aid=1 --alang=jpn () (flac 2ch 48000Hz) Audio --aid=2 --alang=jpn (aac 2ch 48000Hz) AO: [wasapi] 44100Hz stereo 2ch float VO: [gpu] 1920x1080 yuv420p10 (Paused) AV: 00:00:01 / 00:24:32 (0%) A-V: 0.000 Track added: (+) Video --vid=1 () (hevc 1920x1080 23.976fps) (+) Audio --aid=1 --alang=jpn () (flac 2ch 48000Hz) Audio --aid=2 --alang=jpn (aac 2ch 48000Hz) (+) Subs --sid=1 '1.ass' (ass) (external) AV: 00:00:05 / 00:24:32 (0%) A-V: 0.000 [reload] reloading video from 5.505000 second [reload] file 1 of 1 in playlist

(+) Video --vid=1 () (hevc 1920x1080 23.976fps) (+) Audio --aid=1 --alang=jpn () (flac 2ch 48000Hz) Audio --aid=2 --alang=jpn (aac 2ch 48000Hz) (Paused) AV: 00:00:07 / 00:24:32 (0%) A-V: 0.000 [input] No key binding found for key '"'. [input] No key binding found for key 'C'. [input] No key binding found for key ':'. [input] No key binding found for key '\'. [input] No key binding found for key 'Т'. [input] No key binding found for key 'о'. [input] No key binding found for key 'р'. [input] No key binding found for key 'е'. [input] No key binding found for key 'н'. [input] No key binding found for key 'т'. [input] No key binding found for key 'ы'. [input] No key binding found for key '\'. (Paused) AV: 00:00:07 / 00:24:32 (0%) x0.91 A-V: 0.000 [input] No key binding found for key 'C'. [input] No key binding found for key 'B'. [input] No key binding found for key '-'. [input] No key binding found for key 'y'. [input] No key binding found for key 'n'. [input] No key binding found for key 'h'. [input] No key binding found for key 'g'. [input] No key binding found for key 'M'. [input] No key binding found for key 'a'. [input] No key binding found for key '\'. [input] No key binding found for key 'C'. [input] No key binding found for key 'B'. (Paused) AV: 00:00:07 / 00:24:32 (0%) A-V: 0.000 [input] No key binding found for key '-'. [input] No key binding found for key 'y'. [input] No key binding found for key 'n'. [input] No key binding found for key 'h'. [input] No key binding found for key 'g'. (Paused) AV: 00:00:07 / 00:24:32 (0%) x1.10 A-V: 0.000 [input] No key binding found for key 'M'. [input] No key binding found for key 'a'. (Paused) AV: 00:00:00 / 00:24:32 (0%) A-V: 0.000 [input] No key binding found for key 'a'. [input] No key binding found for key 'c'. Screenshot: 'mpv-shot0001.jpg' [input] No key binding found for key 'a'. [input] No key binding found for key 'a'. [input] No key binding found for key 'c'. [input] No key binding found for key 'k'. [input] No key binding found for key '"'. Track switched: Video --vid=1 () (hevc 1920x1080 23.976fps) (+) Audio --aid=1 --alang=jpn () (flac 2ch 48000Hz) Audio --aid=2 --alang=jpn (aac 2ch 48000Hz) Speed: 1.21 A: 00:00:00 / 00:24:32 (0%) x1.21 Screenshot: 'mpv-shot0002.jpg'

A

4e6 commented 2 years ago

Something is very peculiar happening here

(Paused) AV: 00:00:07 / 00:24:32 (0%) A-V: 0.000
[input] No key binding found for key '"'.
[input] No key binding found for key 'C'.
[input] No key binding found for key ':'.
[input] No key binding found for key ''.
[input] No key binding found for key 'Т'.
[input] No key binding found for key 'о'.
[input] No key binding found for key 'р'.
[input] No key binding found for key 'е'.
[input] No key binding found for key 'н'.
[input] No key binding found for key 'т'.
[input] No key binding found for key 'ы'.
[input] No key binding found for key ''.

Is it the moment when you drag the subtitles file in?

krackers commented 1 year ago

I think it's because sending loadfile discards all external files. You can try updating function reload to the following so it loads it. The 0.5 wait is a bit of a hack since otherwise loadfile clobbers it immediately

function reload(path, time_pos)
  msg.debug("reload", path, time_pos)

  local ext_subs = ''
  local sid = mp.get_property_native("sid")
  if sid ~= "no" then
    for _, track in pairs(mp.get_property_native('track-list')) do
      if track.type == 'sub' and track['id'] == sid and track['external'] then
         ext_subs = track['external-filename']
      end
    end
  end
  msg.info("External sub:", ext_subs)

  if time_pos == nil then
    mp.commandv("loadfile", path, "replace")
  else
    mp.commandv("loadfile", path, "replace", "start=+" .. time_pos)
  end

  if ext_subs ~= '' then
    mp.add_timeout(0.5, function ()
        mp.commandv("sub-add", ext_subs)
    end)
  end
end
krackers commented 1 year ago

Also note that newer mpv has dedicated video-reload and audio-reload commands, and I believe these will also preserve position. But I think loadfile might still be better for network streaming since it seems like it's lower-level and ensures all state from before is discarded

AdventurerRussia commented 1 year ago

my player does not start after adding the code, I may not understand exactly where to insert it in the script code

krackers commented 1 year ago

You don't add it, you replace the reload function in the script with the snippet I shared.

AdventurerRussia commented 1 year ago

You don't add it, you replace the reload function in the script with the snippet I shared.

I figured it out and it works, thank you very much. I think this should be included in the main code. I also noticed that it only works with one file, that is, if files are added from different places and reloaded, only the last one added will be pulled up.

AdventurerRussia commented 1 year ago

@4e6

krackers commented 1 year ago

Correct. If for some reason you have multiple external subtitle tracks, it should not be too hard to support that as well. You just need to change the inner loop of for _, track in pairs to capture the filenames of all external tracks instead of the currently selected one. I will leave that as an exercise for you.

4e6 commented 1 year ago

I figured it out and it works, thank you very much. I think this should be included in the main code.

Glad that it worked in the end. You can make a pull request with the changes if you like to include them in the repo.