gpt4 book ai didi

c - 使用 libvlc (ubuntu) 播放多轨文件/流

转载 作者:太空宇宙 更新时间:2023-11-04 04:49:20 25 4
gpt4 key购买 nike

我使用的是最新的 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

最佳答案

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

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

#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;
}

再一次,你能更具体地说明你想做什么吗?

关于c - 使用 libvlc (ubuntu) 播放多轨文件/流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17452121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com