Reputation: 1148
I'm using ffmpeg
. Consider the following piece of code:
for(i=0; i<pFormatCtx->nb_streams; i++) {
if (pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
//how do I get the language of the stream?
}
}
I found out that there is a LangEntry
struct in libavformat
(avlanguage file), there's also a table containing languages and their codes, seems it's just what I need. But I don't know how to use it. I couldn't find any examples of its usage. There are no reference to the LangEntry
neither in AVStream
, nor in AVCodecContext
.
Upvotes: 1
Views: 1286
Reputation: 699
The LangEntry has nothing to do with your objective of detecting the language.
In fact, LangEntry table is to do with List of ISO 639-2 codes
Language code gets encoded as metadata, so you should be trying as below to identify the language
AVDictionaryEntry *lang;
for(i=0; i<pFormatCtx->nb_streams; i++)
{
if (pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
{
lang = av_dict_get(pFormatCtx->streams[i]->metadata, "language", NULL,0);
// Check lang->value, it should give 3-letter word matching to one of the LangEntry Table
}
}
Upvotes: 1