Page 1 of 1

Possible to remove non-english subtitles from MKV's ??

Posted: 09 Sep 2021, 15:12
by ca81
Hi,

I have been using FileBot for a while to rename TV episodes and Movie files and it's an awesome piece of software :)
I am not aware of all the functionality that FileBot offers so in case this is a dumb question please ignore.

Want to check if it is possible for FileBot to remove all non-english subtitles from *.mkv or *.mp4 files....i.e. I have multiple *.mkv files that have subtitles for multiple languages muxed in the file. As I do not need subtitles for any language other than English, I want to check if there is a way by which FileBot can remove the non-english subtitles from *.mkv or *.mp4 files when renaming TV episodes or Movies ?
If yes, then can someone please advise how can it be done.

peace,
~kg

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 09 Sep 2021, 15:43
by rednoah
FileBot does not modify files, and so it cannot remove subtitle streams from container files. There are 3rd party tools (e.g. ffmpeg command-line tool) that can do what you want, but likely only by copying / rewriting the entire file.

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 09 Sep 2021, 18:35
by ca81
Thanks for quick your response.
Will try to figure out 3rd party tools for the purpose.

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 09 Sep 2021, 18:37
by ca81
On a 2nd thought.
Would FileBot be able to identify if a *.mkv file has English subtitles and if yes then provide the track number for the English subtitle along with the total number of subtitiles?

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 10 Sep 2021, 01:17
by kim
I don't see why not

you can something like this:

Code: Select all

{ text.collect{[ 'ID': it.StreamKindID, 'Count': it.StreamCount, 'Language': it.LanguageString,'Default':  it.Default]} }
sample
[{ID=0, Count=34, Language=English, Default=Yes}, {ID=1, Count=34, Language=English, Default=No}, {ID=2, Count=34, Language=Arabic, Default=No}]

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 10 Sep 2021, 02:40
by rednoah
You can use filebot -find -exec to find the files you want to rewrite, and then generate rewrite commands:
viewtopic.php?t=12622

e.g.

Code: Select all

filebot -find . --filter '/en/ in text.Language' -exec echo '{ text.find{ it.Language == /en/ }.ID }' '{ f }'

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 21 Sep 2021, 17:30
by ca81
kim wrote: 10 Sep 2021, 01:17
Thanks!!. This seems like it will solve the purpose. Will try and report back.

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 21 Sep 2021, 17:31
by ca81
rednoah wrote: 10 Sep 2021, 02:40 You can use filebot -find -exec to find the files you want to rewrite, and then generate rewrite commands:
viewtopic.php?t=12622

e.g.

Code: Select all

filebot -find . --filter '/en/ in text.Language' -exec echo '{ text.find{ it.Language == /en/ }.ID }' '{ f }'
Apologies but unable to understand the above code :(
Will try the code snippet by Kim and then will try to figure this one.

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 21 Sep 2021, 18:38
by ca81
kim wrote: 10 Sep 2021, 01:17

Code: Select all

{ text.collect{[ 'ID': it.StreamKindID, 'Count': it.StreamCount, 'Language': it.LanguageString,'Default':  it.Default]} }
Tried this code snippet and finally able to understand it too :) This code snippet provides the track number for EACH subtitle track along the total number of subtitle tracks.
Please advise on how to modify this to provide the track number for ONLY those subtitles for which the language is either 'eng' or 'und' and not provide the track information for any other language??

Re: Possible to remove non-english subtitles from MKV's ??

Posted: 22 Sep 2021, 06:03
by rednoah
filebot -find -exec allows you to find files and then call arbitrary commands on them, e.g. find files with English subtitles, and then call ffmpeg on the file with some custom options, some of which are constant, some of which are generated and provided by FileBot (e.g. subtitle stream ID for English subtitle track).


e.g. filter in files that have an English subtitle track; ignore all other files:

Code: Select all

--filter '/en/ in text.Language'
e.g. call echo with English subtitle stream ID as $1 and absolute file path as $2:

Code: Select all

-exec echo '{ text.find{ it.Language == /en/ }.ID }' '{ f }'
:arrow: You'll want to replace echo with your own custom script that takes in English subtitle stream ID as $1 and absolute file path as $2 and then call ffmpeg to do something, e.g. re-encode the container to a new file while keeping only the given subtitle stream ID.

(I'm not too familiar with using the ffmpeg command-line tool, so I can't give you copy & paste solution for this part)