Set Audio Language tag MP4/MKV

@NewPlaza said:
I know audio lang is important for auto-selecting subtitles and such but what about the language of the video. Does PLEX use this to determine anything?

Not at all, to my knowledge.

And how does that coincide with the lang of the audio?

It is completely separate and has no effect at all in Plex.

Just what I was looking for!

I only need to change the files where Audio Language is unknown, and cant risk foreign movies is modified. Could anyone please verify that it only changes unknown tags?

Thanks in advance!

find . -iname '*.mp4' -print0 | xargs -0 -n1 -P8 MP4Box -lang eng
find . -iname '*.mkv' -print0 | xargs -0 -n1 -P8 mkvpropedit --edit track:a1 --set language=eng --edit track:v1 --set language=eng

Does anyone have a script that checks if the language is Unknown before setting it to Eng?

I am hoping to find a script I can call from Sonarr/Radarr on Download, and conditionally update the language flag only if it needs to and only the correct stream.

Yep. Copy the below and save as WhatEverYouLike.cmd…

@ECHO OFF

ECHO.



ECHO Set all Undetermined(und) audio language to English(eng) in current folder.
ECHO.
ECHO.

FOR %%A IN (*.mkv) DO (
    FOR /F %%I IN ('mkvmerge.exe --identify "%%A" ^| FIND /C "Track ID"') DO (
        IF %%I GTR 0 (
	    FOR /L %%T IN (0,1,%%I) DO (
		mkvmerge.exe -I "%%~dpnxA" | FINDSTR /C:"Track ID %%T: audio" | FINDSTR /C:"language:und">NUL
		IF NOT ERRORLEVEL 1 ECHO Undetermined audio language found. & ECHO    "%%~nxA" & mkvpropedit.exe "%%~dpnxA" -e track:%%I -s language=eng & ECHO. & ECHO. & ECHO.

)
)
))

ECHO The end...
PAUSE
EXIT

You will need the programs mkvmerge.exe and mkvpropedit.exe and must be placed in the same location as this command script… This will scan the current directory and set all *.mkv files but you can modify to suit your needs… Good luck.

EDIT: Forgot to include the versions I was using.
mkvmerge v7.8.0
mkvpropedit v7.8.0
I imagine the newest versions would work but I haven’t tested.

2 Likes

Any way to include subfolders as well? :smiley:

Yep.
Replace the first loop FOR %%A IN (*.mkv) DO ( to FOR /R %%A IN (*.mkv) DO (

Just bare in mind that even though this will edit the headers and is relatively fast(milliseconds/file) this could take a VERY long time to complete if you run on a NAS or network share with thousands of files. It can be painstakingly slow if your shares have a 10/100 connection.

Thank you this script did the trick for me :slight_smile:

fairly new to scripting on windows, but I’ve made a Windows VM to run the script on.
Still looking for a way to refencence MKVToolNix folder, instead I copy the binaries to the folder my script is run.

Just reference the full path to the .exe in double quotes.
See How to remove tag spam and set language in several MKV files at once

Here, this might get you in the right path…

IF EXIST "%ProgramFiles%\MKVToolNix\mkvpropedit.exe" SET MKVEdit=C:\PROGRA~1\MKVToolNix\mkvpropedit.exe
IF EXIST "%ProgramFiles(x86)%\MKVToolNix\mkvpropedit.exe" SET MKVEdit=C:\PROGRA~2\MKVToolNix\mkvpropedit.exe
IF EXIST mkvpropedit.exe SET MKVEdit=mkvpropedit.exe

IF EXIST %MKVEdit% GOTO:TagRename

ECHO MKVToolNix not installed or not found.&PAUSE&EXIT

:TagRename
The rest of your code goes here.......
1 Like

Thank you so much for this link. Ive searched for many, Many days on how to batch edit audio/sub/video tracks. Saved me so much time!!! Thank you!!!

Thank @ferezvi

Does anyone know how to batch edit the audio language for MKV and MP4 files on OSX?

Look a few posts upwards.

thanks but which one is it? and is this using home-brew or something?

Sorry, I don’t know what homebrew is (no Mac user here) but my script for MKV files can be used on Mac as well.

For mp4 files you can use this for instance
http://www.emmgunn.com/mp4tools-home/

excellent thank you. I’m going to look at this now.

one thing that springs to mind, my movie folder has sub folders for each movie. Will this affect the script?

Yes. You’ll have to copy it into each subfolder and execute it there.
If you find an expert in shell scripting, you probably can modify the script to work recursively – but this is very dangerous IMHO.
If you have files with more than one audio language, working recursively can cause a lot of damage in a very short time.

1 Like

I second @OttoKerner concern on that. As he stated, you can “destroy” thousands of files in just a few seconds. And maybe the worst of that would be correcting them back. I have many scripts that do multiple tasks but even then, every file is treated differently… So, none of my scripts are recursive.

Windows Server with PowerShell

Windows Powershell functions to convert video files with mkvmerge from mp4 and avi to mkv and set all mkv default audio and video language to your desired language with mkvpropedit all in batch to be used for your PLEX server or something else.

1 Like

Maybe set video to undetermined(und) or not change the video track for this HowTo.