libVLC get language code from audio track

This forum is about all development around libVLC.
Jo2003
Blank Cone
Blank Cone
Posts: 67
Joined: 08 Feb 2010 13:29

libVLC get language code from audio track

Postby Jo2003 » 13 Nov 2015 12:41

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!

grindstone
New Cone
New Cone
Posts: 9
Joined: 27 Oct 2015 14:04

Re: libVLC get language code from audio track

Postby grindstone » 13 Nov 2015 14:47

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

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: libVLC get language code from audio track

Postby Rémi Denis-Courmont » 13 Nov 2015 15:00

You'd have to add the language code to the LibVLC media track infos. Note that not all containers carry this information.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Jo2003
Blank Cone
Blank Cone
Posts: 67
Joined: 08 Feb 2010 13:29

Re: libVLC get language code from audio track

Postby Jo2003 » 14 Nov 2015 12:35

OK, so I'll do it on my own. Thanks for your help!

Best regards,
Jörg


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 28 guests