总的来说把VLC内嵌入自己的应用有4种途径:
•直接调用VLC进程•VLC的plugin for Mozilla•VLC的ActiveX插件•调用libvlc最近需要VLC动态库做开发,故需要编译vlc,并修改VLC 将自己的API借口添加到Lib动态库中。
下面来编译VLC2.0.1,从官网下载最新VLC。(新版本的VLC需要gcc和glibc的支持,所以使用centOS 6.2或者ubunt10.0版本)
如果想要加载全部功能,需要安装如下库
yum install a52dec a52dec-devel caca-utils dirac dirac-devel expat expat-devel faac faac-devel faad2 faad2-devel ffmpeg \ ffmpeg-libs flac flac-devel fribidi-devel gettext gnutls gnutls-devel gnutls-utils lame lame-devel live555 live555-devel \ libass libass-devel libcaca libcaca-devel libcddb libcddb-devel libcdio libcdio-devel libdap libdap-devel libdca-devel \ libdvbpsi libdvbpsi-devel libdvdnav libdvdnav-devel libdvdread libebml libebml-devel freetype freetype-devel fribidi \ libgcrypt libgcrypt-devel libgpg-error libgpg-error-devel libjpeg-turbo libmad libmad-devel libmatroska libmatroska-devel \ libmodplug libmodplug-devel libmpcdec-devel libmpeg2-devel libogg-devel liboil-devel libpng libpng-devel libshout \ libshout-devel libtheora-devel libtiff libupnp libupnp-devel libvorbis-devel libX11 libX11-devel libxcb libxcb-devel \ libxml2 libxml2-devel mpeg2dec portaudio-devel qt4 qt4-devel schroedinger-devel SDL-devel SDL_image SDL_image-devel speex \ speex-devel taglib-devel twolame twolame-devel vcdimager vcdimager-devel vcdimager-libs x264 x264-devel yasm zlib \ lua xcb-util-devel libsamplerate-devel那这里有好多是我不想要的,所以在configure时将不需要的屏蔽掉了
./configure --disable-nls --disable-dbus --disable-lua --disable-mad --disable-avcodec --disable-swscale --disable-postproc --disable-a52 --disable-xcb --disable-alsa --disable-libgcrypt
生成makefile后,make;make install;
可能make 是缺少gcc++ yum之,安装后,记得重新configure。
增加自定义API接口:
需求:增加VLC视频存储功能
1)在libvlc_media_play.h文件中声明为LIBVLC_API类型的接口函数
2)并将接口在lib/libvlc.sym 文件中添加,否则make编译时会在连接进动态库时变为静态,不可被外部调用。
include\vlc\libvlc_media_player.h文件,
搜索 libvlc_video_take_snapshot(实现截图功能的)这个函数,找到libvlc_video_take_snapshot后,在其后面添加名
int libvlc_video_toggle_record( libvlc_media_player_t *p_mi, const char *psz_filepath, const char *psz_filename ) { input_thread_t *p_input = libvlc_get_input_thread( p_mi ); if(p_input == NULL) return -1; var_SetString( p_input, "input-record-path", psz_filepath ); var_SetString( p_input, "sout-record-dst-prefix", psz_filename ); var_ToggleBool( p_input, "record"); vlc_object_release(p_input); return 0; }
3)编译自己程序时指定连接动态库-lvlc
安装成功!