3

I have the following :

  • a mkv file (let's call it A) with video, audio and subtitles correctly synchronized.
  • another mkv file (let's call it B) with video and audio also synchronized but without subtitles.

Both files are the showing same content but with different video/audio quality (B is much better than A). I would like to transfer subtitles from A to B. Both video streams are at 25 FPS but B contains a duplicate frame every 24 frames (it's probably the result of a 24 to 25 FPS conversion). Other than that, frames perfectly match (if we ignore the fact resolution is different).

I was wondering if there was a tool/method/script (even commercial) that would allow to me to sync subtitles with B automatically, using A video stream as reference and knowing it's perfectly synchronized.

For every frame in A, it's possible to find an almost 1:1 matching frame in B, so theoretically it should be possible to sync subtitles automatically.


What I already tried :

With Subtitle Edit : slowing down subtitles from 25 to 24 FPS and applying a given offset (since A and B do not start at same time). At first glance, it seems to work but after 15-20 minutes, subtitles start being unsync and it just get worse with time.

Additionally, I have notified that B contains additional content that A does no have (eg: there is a 10 seconds intermission in the middle of the stream).

EDIT: downvoters are invited to tell or explain what's wrong with this question.

tigrou
  • 943

1 Answers1

3

After searching and trying things for countless hours, I choose to write my own Python 3 script to do the job. I have decided to share it here. Here is a link to it : https://gist.github.com/tigrouind/8cd1564568b7582feb776ad21edc8fff

Requirements :

  • opencv-python
  • srt

What it does: It take a subtitle and related frame from movie A and search the best matching frame in movie B. Once it find it, it adjust subtitle timings accordingly (it proceed like that for every subtitle). The search is limited to a certains number of frames in forward and backward direction.

I have applied it over to a 2:30 hours movie (which contains many small differences with reference movie and over 2000 subtitles) and it worked very well.

tigrou
  • 943