1

我使用的是最新的 vlc 版本,它们是在同一个窗口中还是在多个窗口中都没有关系,只要你可以同时看到它们。

这是我正在尝试的:

int main(int argc, char **argv)
{
    libvlc_instance_t *inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;

    inst = libvlc_new(0, NULL);
    m = libvlc_media_new_path(inst, "/tmp/mpt-smart-travels-classical-clip.ts");
    mp = libvlc_media_player_new_from_media(m);
    libvlc_media_release(m);
    libvlc_media_player_play(mp);


    libvlc_track_description_t *videoIDs = libvlc_video_get_track_description(mp); 
    int numberOfTracks = sizeof videoIDs;
    int count = 0;
    int id;
    while (count <= numberOfTracks) {
      id = videoIDs[count];
      libvlc_video_set_track(mp,id);
      count += 1;
      }

    sleep(10);

    libvlc_media_player_stop(mp);
    libvlc_media_player_release(mp);
    libvlc_release(inst);


    return 0;
}

$ gcc $(pkg-config --cflags libvlc) -c test.c -o test.o

$ gcc test.o -o test $(pkg-config --libs libvlc)

可能需要使用名为“p_next”的指针来获取下一个流的 ID。videolan.org/developers/vlc/doc/doxyge/html/structlibvlc_track_description__t.html _ _

4

1 回答 1

0

你能更具体地说明你想要做什么吗?

问题中的代码无法编译,无法枚举任何流中的轨道。以下是使该代码变得有意义的最小更改。

#include <vlc/vlc.h>
#include <unistd.h>
#include <stdlib.h>

int main( int argc, char **argv )
{
    libvlc_instance_t *inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;

    if ( argc < 2 )
    {
        fprintf( stderr, "Please provide a file name to open.\n" );
        exit( 1 );
    }

    inst = libvlc_new( 0, NULL );
    m = libvlc_media_new_path( inst, argv[1] );
    mp = libvlc_media_player_new_from_media( m );
    libvlc_media_release( m );
    libvlc_media_player_play( mp );

    sleep( 1 );

    libvlc_track_description_t *track_desc = libvlc_video_get_track_description( mp );
    int numberOfTracks = libvlc_video_get_track_count( mp );

    fprintf( stderr, "numberOfTracks=%d\n", numberOfTracks );

    while ( track_desc != NULL )
    {
        int id = track_desc->i_id;

        if ( id == -1 )
        {
            fprintf( stderr, "Not switching to pseudo-track id=%d name=%s\n", id, track_desc->psz_name );
        }
        else
        {
            fprintf( stderr, "Switching to video track id=%d name=%s\n", id, track_desc->psz_name );
            libvlc_video_set_track( mp, id );
        }

        sleep( 1 );
        track_desc = track_desc->p_next;
    }

    fprintf( stderr, "Finished enumerating tracks. Waiting a little.\n" );

    sleep( 10 );

    libvlc_media_player_stop( mp );
    libvlc_media_player_release( mp );
    libvlc_release( inst );


    return 0;
}

同样,您能否更具体地说明您要做什么?

于 2014-12-18T19:06:04.830 回答