Search code examples
androidlibvlcvlc-android

libVLC: How do I know if subtitles (text track) are external or part of video container file?


When using libVLC for Android how do I know if subtitles (text track) are external (.srt, ass) or part of video container file (text track inside .mkv)?

https://code.videolan.org/videolan/libvlc-android-samples

https://code.videolan.org/videolan/vlc-android

// MediaPlayer.getSpuTracks() - Get the list of available spu (subtitle) tracks.
MediaPlayer.TrackDescription[] trackDescriptions = mMediaPlayer.getSpuTracks();
for (int i = 1; i < trackDescriptions.length; i++) {
    MediaPlayer.TrackDescription description = trackDescriptions[i];
    Log.i(TAG, "loadSpuTrack " + description.name + ", id " + description.id);
}

Output

loadSpuTrack Track 1, id  2
loadSpuTrack Track 2, id  3
loadSpuTrack Track 3, id  4
loadSpuTrack Track 4, id  5
loadSpuTrack Track 5, id  6

It just searches and adds all external text track files (.srt, .ass) from parent file (directory) of video file (.mkv) and from video file itself

But there is no API (Java methods inside MediaPlayer or LibVLC classes) to identify if added subtitles are external or internal (from video file container), no method to disable adding external subtitles

Is there any solution?


Solution

  • this should work (will help to determine external subtitles) if external subtitles (slaves) are being added at end of the list:

    enter image description here