Open peno64 opened 2 years ago
In my repository https://peno64.github.io/repository.peno64 you can find an addon called LocalSubtitle which I adapted to also have the ability to have two subtitles. It also loads a subtitle from your local system to be shown on the video. Now it has also the feature to show dual subtitles. The reason why I crerated this addon is because the standard way in kodi to add a local subtitle sometimes just hangs the system. Especially when the subtitle is from the internet. Something that the kodi developers don't want to fix. Check this addon to see what the effect is of the improved sync.
Hi sorry for taking so long to reply, I've been a bit busy. I think I understand what you're saying though, except for the part where you minus 10ms. Where did you get this number from? It was a little unclear to me what you meant by "If the next start timing of the second subtitle is smaller, then I take this one minus 10 ms." I put in something for what I think you were saying though.
for i in range(len(mastArray)):
mastTime = [timeConv(mastArray[i][0]),timeConv(mastArray[i][1])]
while onSubLine < len(subMastArray):
#Added a third value to subMastTime, which corresponds to the next beginning time.
subMastTime = [timeConv(subMastArray[onSubLine][0]),timeConv(subMastArray[onSubLine][1]),timeConv(subMastArray[onSubLine + 1][0])]
#Only checking if the start timings are within the threshold now.
difs = mastTime[0] - subMastTime[0]
if abs(difs) <= timeThresh:
subMastArray[onSubLine][0] = mastArray[i][0]
#Checking if the next subMaster start time is greater than current Master end time.
#"I look at the next start timing of the second subtitle and if that is greater than the end timing of the current subtitle of the master subtitle I set the end timing of the second one equal to the end timing of the first one."
if subMastTime[2] > mastTime[1]:
subMastArray[onSubLine][1] = mastArray[i][1]
#"If the next start timing of the second subtitle is smaller, then I take this one minus 10 ms."
else:
#Not sure exactly what you want to go here.
onSubLine += 1
break
#Only checking start times again
elif difs < 0:
break
else:
onSubLine += 1
Does this look like what you are talking about? Tried to comment everything I changed, but tell me if anything is still confusing or if I didn't do what you were thinking of.
Your current routine to auto sync is like this:
I think this can be improved. I improved it anyway for the opensubtitles addon and I am almost ready also with the a4kSubtitles addon. The improvement is in the end times of the two subtitles. First of all I don't see any reason why the difference between the end times should also be smaller than timeThresh t o sync. So in first instance I only compare the start times and make these equal when close enough. Then I look at the next start timing of the second subtitle and if that is greater than the end timing of the current subtitle of the master subtitle I set the end timing of the second one equal to the end timing of the first one. If the next start timing of the second subtitle is smaller, then I take this one minus 10 ms. The result is that both subtitles are more in sync, both start and ending time. It makes the coding complexer but as I say, the result is better.