[SOLVED] Cannot get the subtitles

This forum is about all development around libVLC.
pgpoulsen
New Cone
New Cone
Posts: 6
Joined: 01 Jun 2011 23:35

[SOLVED] Cannot get the subtitles

Postby pgpoulsen » 24 Jan 2013 06:26

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; }
Last edited by pgpoulsen on 24 Jan 2013 19:30, edited 1 time in total.

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

Re: Cannot get the subtitles

Postby Rémi Denis-Courmont » 24 Jan 2013 09:34

You need to wait until the SPU tracks are actually parsed. It can't work immediately.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

pgpoulsen
New Cone
New Cone
Posts: 6
Joined: 01 Jun 2011 23:35

Re: Cannot get the subtitles

Postby pgpoulsen » 24 Jan 2013 19:30

Hi

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


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 5 guests