FFMpeg set language as Unknown or unspecified in a QuickTime MOV I have to transcode with FFMpeg some video with multiple audio where various audio track are not language related, just music and so on.

I would like to assing as language something like Unspecified, Unknown, Not Applicable, Multilanguage, or so on.

Everything that is not a specific named language (English, French, Spanish, ...) works fine for me .

ffmpeg -i in.mov -map 0:a -metadata:s:a:0 language="und" -metadata:s:a:0 title="Just Music" out.mov


For what I researched FFMPeg uses the ISO 639-2 codes:

https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

In my example I tried to use the und that stands for Undetermined..

In the wikipedia list there are also other possible interesting options:

The standard includes some codes for special situations:

    mis, for "uncoded languages";
    mul, for "multiple languages";
    qaa-qtz, a range reserved for local use.
    und, for "undetermined";
    zxx, for "no linguistic content, not applicable";


Non of them seems to work, everytime I try to set that values with ffmpeg it just assume "English".

Following the Apple Documentation for Moov Format we have:

https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353

A very small list compared to the Wikipedia one but there's at least a Unspecified 32767

I tried with -metadata:s:a:0 language="und" or -metadata:s:a:0 language="32767" but is not working the same :(

So I tried to read the source code of ffmpeg, at ffmpeg/libavformat/isom.c line 382:

/* map numeric codes from mdhd atom to ISO 639 */
/* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
/* http://developer.apple.com/documentation/mac/Text/Text-368.html */
/* deprecated by putting the code as 3*5 bits ASCII */
static const char mov_mdhd_language_map[][4] = {
    /* 0-9 */
    "eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor",
    "heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/,
    "urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav",    "",
    "fo ",    "", "rus", "chi",    "", "iri", "alb", "ron", "ces", "slk",
    "slv", "yid", "sr ", "mac", "bul", "ukr", "bel", "uzb", "kaz", "aze",
    /*?*/
    "aze", "arm", "geo", "mol", "kir", "tgk", "tuk", "mon",    "", "pus",
    "kur", "kas", "snd", "tib", "nep", "san", "mar", "ben", "asm", "guj",
    "pa ", "ori", "mal", "kan", "tam", "tel",    "", "bur", "khm", "lao",
    /*                   roman? arabic? */
    "vie", "ind", "tgl", "may", "may", "amh", "tir", "orm", "som", "swa",
    /*==rundi?*/
       "", "run",    "", "mlg", "epo",    "",    "",    "",    "",    "",
    /* 100 */
       "",    "",    "",    "",    "",    "",    "",    "",    "",    "",
       "",    "",    "",    "",    "",    "",    "",    "",    "",    "",
       "",    "",    "",    "",    "",    "",    "",    "", "wel", "baq",
    "cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav"
};

int ff_mov_iso639_to_lang(const char lang[4], int mp4)
{
    int i, code = 0;

    /* old way, only for QT? */
    for (i = 0; lang[0] &amp;&amp; !mp4 &amp;&amp; i &lt; FF_ARRAY_ELEMS(mov_mdhd_language_map); i++) {
        if (!strcmp(lang, mov_mdhd_language_map[i]))
            return i;
    }
    /* XXX:can we do that in mov too? */
    if (!mp4)
        return -1;
    /* handle undefined as such */
    if (lang[0] == '\0')
        lang = "und";
    /* 5 bits ASCII */
    for (i = 0; i &lt; 3; i++) {
        uint8_t c = lang[i];
        c -= 0x60;
        if (c &gt; 0x1f)
            return -1;
        code &lt;&lt;= 5;
        code |= c;
    }
    return code;
}


They talk of "und" inside the code, but if you use -metadata:s:a:0 language="und" it just return English.. :\

What is the correct way to specify it? It could be a ffmpeg bug? I'm using the last zeranoe nightly build N-92405-ge24a754916
-map 0:v \
-map 0:1 -metadata:s:a:0 language=zxx \
-map 0:2 -metadata:s:a:1 language=eng \
-map 0:3 -metadata:s:a:2 language=fra \
-map 0:4 -metadata:s:a:3 language=kin