0

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] && !mp4 && i < 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 < 3; i++) {
        uint8_t c = lang[i];
        c -= 0x60;
        if (c > 0x1f)
            return -1;
        code <<= 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

  • At the time the code was written, the ref the devconsulted did not list a value for und so it's not accepted. Will patch it soon. – Gyan Nov 12 '18 at 6:00
  • @Gyan So the ffmpeg should be updated? Thanks :) Isn't it possible to add also mis, mul and zxx languages as wikipedia suggest? Would be cool also an "int" for International.. it would make very sense for some kind of tracks like international tracks (eg. Music and Effects) – user3450548 Nov 12 '18 at 8:30
  • Ok, will look into it. – Gyan Nov 12 '18 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.