Given a hypothetical folder structure like this:

Star.Trek.Discovery.S04E06.German.DL.1080p.BluRay.x264-iNTENTiON/
├── star.trek.discovery.s04e06.german.dl.1080p.bluray.x264-intention.mkv
├── star.trek.discovery.s04e06.german.dl.1080p.bluray.x264-intention.nfo
└── Subs
    ├── star.trek.discovery.s04e06.german.dl.1080p.bluray.x264-intention-eng.idx
    ├── star.trek.discovery.s04e06.german.dl.1080p.bluray.x264-intention-eng.sub
    ├── star.trek.discovery.s04e06.german.dl.1080p.bluray.x264-intention.idx
    └── star.trek.discovery.s04e06.german.dl.1080p.bluray.x264-intention.sub
Star.Trek.Discovery.S04E07.German.DL.1080p.BluRay.x264-iNTENTiON/
├── star.trek.discovery.s04e07.german.dl.1080p.bluray.x264-intention.mkv
├── star.trek.discovery.s04e07.german.dl.1080p.bluray.x264-intention.nfo
└── Subs
    ├── star.trek.discovery.s04e07.german.dl.1080p.bluray.x264-intention-eng.idx
    ├── star.trek.discovery.s04e07.german.dl.1080p.bluray.x264-intention-eng.sub
    ├── star.trek.discovery.s04e07.german.dl.1080p.bluray.x264-intention.idx
    └── star.trek.discovery.s04e07.german.dl.1080p.bluray.x264-intention.sub

4 directories, 12 files

What’s the best way to integrate all the subtitles into the corresponding MKV file?

  • AnEilifintChorcra
    link
    fedilink
    English
    arrow-up
    2
    ·
    21 hours ago

    I like https://github.com/ruediger/VobSub2SRT

    for f in ./*.sub; do
        vobsub2srt --blacklist "\/_~" "${f%.*}"; done
    

    And then https://mkvtoolnix.download/ to remove any unwanted subtitles from the mkv files

    for f in ./*.mkv; do
        outdir="nosubs"
        mkvmerge -o "${outdir}/$f" --no-subtitles "$f"; done
    
    

    I find that it never recognises “I” properly and always defaults to “|” which is easier to replace than random characters that would appear if I blacklist “|” So, then I run

    sed -i 's/|/I/g' *.srt
    

    Finally, I merge the srt files with the mkv files

    for f in ./nosubs/*.mkv; do
        outdir=addedsubs
        g="${f##*/}"
        mkvmerge -o "${outdir}/$g" "$f" --language 0:ger --track-name 0:German "${g%.*}".srt; done
    

    Once the files in the addedsubs directory look good, I delete all of the other files. You can add it all to a bash file or make an alias or both and run it wherever

    • Lemmchen@feddit.orgOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      9 hours ago

      I’m pretty sure MKV can handle VOBSUB. Why do you convert them to .srt before merging them?

      Edit:

      I’ve also just found this: https://github.com/elizagamedev/vobsubocr

      The most comparable tool to vobsubocr is VobSub2SRT, but vobsubocr has significantly better output, especially for non-English languages, mainly because VobSub2SRT does not do much preprocessing of the image at all before sending it to Tesseract. For example, Tesseract 4.0 expects black text on a white background, which VobSub2SRT does not guarantee, but vobsubocr does. Additionally, vobsubocr splits each line into separate images to take advantage of page segmentation method 7, which greatly improves accuracy of non-English languages in particular.

      Edit 2:

      And a fork of it, of course: https://github.com/gwen-lg/subtile-ocr

      As you seems to not update this project anymore, I have done a fork to continue the project. With subtile-ocr I have use subtile subtile is a fork no longer maintained vobsub crate. With this I was able to :

      • modernise the code by :
        • update dependencies, especially nom who need a lot of code modification.
        • migrate to thiserror and anyhow for error management
      • do some small optim (by reducing a lot the memory allocation count) And it could be a better start to add functionality (like managing .sup: blue-ray subtitle format).
      • Bakkoda@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        7 hours ago

        Iirc vobsub is not text so while you can add it to the container it will always require a transcode on plex/jelly/etc to burn in.

        • Lemmchen@feddit.orgOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 hours ago

          I wasn’t aware of the transcoding requirement, thank you. So I guess converting the subtitles is a best practice I should adopt.

          • Bakkoda@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 hours ago

            If vobsub is image based (pretty sure it is) then it needs an OCR converter. Most streaming setups will burn the image based subs in. Honestly for 1080p and lower a modern cpu/gpu won’t miss a beat.