Page 1 of 1

libVLC get language code from audio track

Posted: 13 Nov 2015 12:41
by Jo2003
Hi all,
when playing a transport stream I can get the description to the played audio track with e.g. libvlc_audio_get_track_description(). This work fine and I get something like "[Russisch]". Is there a way to get the language code (ISO639) instead of the localized description? I tried something like this:

Code: Select all

// get current played media ... libvlc_media_t* pCurrentMedia = libvlc_media_player_get_media(pMediaPlayer); if (pCurrentMedia != NULL) { libvlc_media_track_t** mtArray; int iTracks; if ((iTracks = libvlc_media_tracks_get(pCurrentMedia, &mtArray)) > 0) { for (int i = 0; i < iTracks; i++) { cout << "Language: " << mtArray[i]->psz_language << ", Descr.: " << mtArray[i]->psz_description << endl; } libvlc_media_tracks_release(mtArray, iTracks); } }
... when the media is playing already. The array stored at mtArray has 2 elements (which is fine: video + audio), but language and description is empty. Is there another way I can try?

Thanks in advance,
Jörg

P.S. Many thanks for the great API and the nice support!

Re: libVLC get language code from audio track

Posted: 13 Nov 2015 14:47
by grindstone
Hello Jörg!

I guess for that backward assignment you have to write your own code: search the file >po\de.po< for the string >msgstr "Russisch"<. In the line above that string you'll find the english term for that language (>msgid "Russian"<) and one further line above the name of the file which contains the ISO639 - table (src/text/iso-639_def.h).

Happy coding! :)

Regards
grindstone

Re: libVLC get language code from audio track

Posted: 13 Nov 2015 15:00
by Rémi Denis-Courmont
You'd have to add the language code to the LibVLC media track infos. Note that not all containers carry this information.

Re: libVLC get language code from audio track

Posted: 14 Nov 2015 12:35
by Jo2003
OK, so I'll do it on my own. Thanks for your help!

Best regards,
Jörg