Extract subtitles from mkv/mp4 containers
#1
Is there any way to extract subtitles from mkv or mp4 containers by add-on using only Kodi resources?
The naive way would be to use mkvextract, but it is not available in Kodi. Also ffmpeg has this ability, but it is statically linked in the Kodi and not available to the add-on - unless there is some API I'm not aware about.
Odroid C2; Libreelec 9.0.0
Reply
#2
It may be possible if someone develops a VFS addon for MKV container which will then give access to the individual streams (video, audio, subs, chapters).
VFS addons are binary addons so needs expert devs
Kodi 18.1 x64 Windows | LibreElec 9 RR S905X
Reply
#3
(2019-04-10, 18:14)bkiziuk Wrote: The naive way would be to use mkvextract

Naive? Meh. Just create a batch/bash file (whichever your OS is) for mkvextract to make the whole process simple, and extract the subtitle file into the same folder of the video. Works for me.
Got a Kodi problem? Provide us with a full Debug log (wiki) || Usefull pages: First time user (wiki) || Troubleshooting (wiki) || Free content (wiki) || Forum rules (wiki) || VPN policy (wiki)
Reply
#4
(2019-04-11, 12:50)Klojum Wrote: Naive? Meh. Just create a batch/bash file (whichever your OS is) for mkvextract to make the whole process simple, and extract the subtitle file into the same folder of the video. Works for me.

Yea, if I wanted to do it on a single machine, that would be a good course of action. Unfortunately, I want to implement it in a python plugin which in turn can be installed on any box under Kodi. Therefore, it doesn't make much sense to hack every device to include mkvextract.
Of course the mkvextract could solve my problem if it was already included in the Kodi installation and available for plugins Wink
Odroid C2; Libreelec 9.0.0
Reply
#5
If your video files collection is on a network, you don't need to install mkvextract on every (Kodi) client machine. One machine with mkvextract will be enough.
If you work with separate USB drives, then you will need to do extra file juggling, yes.
Got a Kodi problem? Provide us with a full Debug log (wiki) || Usefull pages: First time user (wiki) || Troubleshooting (wiki) || Free content (wiki) || Forum rules (wiki) || VPN policy (wiki)
Reply
#6
depending on what you want to support and what your target with addon (if you want to be in official repo or not), you can simply include portable version of mkvextract for both windows and linux, and run it process thry python if you want to extract subtitles while inside kodi.


import subprocess
subprocess.run(["ls", "-l"])
subprocess.call(["ls", "-l"])

# or

os.system("ls -l")

That would be the start - if you not targeting official repo that the easiest way, if you do then this won't be allow.
Reply
#7
(2019-04-15, 07:27)bigretromike Wrote: That would be the start - if you not targeting official repo that the easiest way, if you do then this won't be allow.

Yes, targeting official repo was my intention as well.
But aside from that, I was testing the similar solution for a while and I also hit limitations on nfs/smb shares.
If .mkv is on external share, it is not possible to access it directly from the program but instead there should be xmbcvfs implemented for it.  However I can't figure out, how to access the file via xmbcvfs and pipe into mkvinfo/mkvextract.
Doing a local copy is a rather enormous task for 2 GB file.
Odroid C2; Libreelec 9.0.0
Reply
#8
There are some MKV Python libraries out there that may do the job.
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Extract subtitles from mkv/mp4 containers00