Removing certain audios and subtitles from the video files

I have multiple videos and each of them have multiple audios and subtitles that I don’t need.

Instead of using Mkvtoolnix Gui to remove the audios and subtitles video by video, is there a way to do it by batch.

I need audio #8 and I am assuming that in every video file, the audio #8 is the one I need.

In the same way, I need text #5 (subtitle).

Welcome!

There are several examples available on how to automate directly with MKVToolNix that you can use as a basis. You can also look into the available third-party tools.

Thank you for the links.
I checked them, but I’m not sure which third party tool to use for my purpose.
I’m sorry, I don’t have time to read the documentation in detail.
I will appreciate if you could advise more in detail.

I was able to create a batch file to solve the problem:

@echo off
echo Add mkvtool to path in system variables for this to work.
echo.
echo You will see ID just below Audio #1 or Text #1 in MediaInfo
echo To get the Track ID you will need to minus 1 from the number you see in MediaInfo
echo If you wish to keep multiple audio and subtitles, just add a comma (e.g. 1,2)

echo.

set /p audio=Enter Audio Track ID to keep:
set /p subtitle=Enter Subtitle Track ID to keep:

set input_dir=%~dp0
set output_dir=%input_dir%output
if not exist "%output_dir%" mkdir "%output_dir%"

for %%a in ("%input_dir%*.mkv") do (
    mkvmerge.exe -o "%output_dir%\%%~na.mkv" --audio-tracks %audio% --subtitle-tracks %subtitle% "%%a"
)

pause
1 Like

Hi Akashv108,

I want to remove only all non english subtitle from the mkv file, but I don’t know how to modify your batch file.

is it possible that if I want to keep all audio tracks and remove all except subtitle with English. Could you point me out how I can do that please? thank you.

update:1
I’ve edited and it seems working now.

set input_dir=%~dp0
set output_dir="C:\Users\Smith\Desktop\temp_movie"

if not exist "%output_dir%" mkdir "%output_dir%"

for %%a in ("%input_dir%*.mkv") do (
    "C:\Program Files\MKVToolNix\mkvmerge.exe" -o "%output_dir%\%%~na.mkv" -s eng,en,en-us -a eng,en-us  "%%a"
)