Page 1 of 1

[SOLVED] Cannot get the subtitles

Posted: 24 Jan 2013 06:26
by pgpoulsen
Hi

When I try to get the number of subtitles (spu) libvlc always returns 0 even though that I know there are more. If I play the same video in the standard VLC player it can access the other subtitles so it must be something in my code. As you can see from the code below it is an mkv file if that matters.

Anyone that can tell me what I'm doing wrong?

Code: Select all

#include <stdio.h> #include <stdlib.h> #include <vlc/vlc.h> #include <windows.h> int main(int argc, char* argv[]) { libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; /* Load the VLC engine */ inst = libvlc_new (0, NULL); /* Create a new item */ m = libvlc_media_new_path (inst, "C:\\Users\\Public\\Videos\\101-pilot.mkv"); /* Create a media player playing environement */ mp = libvlc_media_player_new_from_media (m); // Trouble spot - start printf("Number of subtitles: %d\n", libvlc_video_get_spu_count(mp)); // Always says 0 // Trouble spot - end /* No need to keep the media now */ libvlc_media_release (m); /* play the media_player */ libvlc_media_player_play (mp); Sleep (10000); /* Let it play a bit */ /* Stop playing */ libvlc_media_player_stop (mp); /* Free the media_player */ libvlc_media_player_release (mp); libvlc_release (inst); return 0; }

Re: Cannot get the subtitles

Posted: 24 Jan 2013 09:34
by RĂ©mi Denis-Courmont
You need to wait until the SPU tracks are actually parsed. It can't work immediately.

Re: Cannot get the subtitles

Posted: 24 Jan 2013 19:30
by pgpoulsen
Hi

didn't know that, but it fixed my problem. Thanks!