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

Any questions? Need some help?
Post Reply
ca81
Posts: 29
Joined: 14 Dec 2019, 20:08

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

Post 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
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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.
:idea: Please read the FAQ and How to Request Help.
ca81
Posts: 29
Joined: 14 Dec 2019, 20:08

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

Post by ca81 »

Thanks for quick your response.
Will try to figure out 3rd party tools for the purpose.
ca81
Posts: 29
Joined: 14 Dec 2019, 20:08

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

Post 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?
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

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

Post 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}]
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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 }'
:idea: Please read the FAQ and How to Request Help.
ca81
Posts: 29
Joined: 14 Dec 2019, 20:08

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

Post by ca81 »

kim wrote: 10 Sep 2021, 01:17
Thanks!!. This seems like it will solve the purpose. Will try and report back.
Last edited by ca81 on 21 Sep 2021, 18:39, edited 1 time in total.
ca81
Posts: 29
Joined: 14 Dec 2019, 20:08

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

Post 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.
ca81
Posts: 29
Joined: 14 Dec 2019, 20:08

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

Post 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??
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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)
:idea: Please read the FAQ and How to Request Help.
Post Reply