ubuntu中安装gstreamer开发环境:
* 安装gstreamer基本库,工具,以及插件
sudo apt-get install libgstreamer0.-dev gstreamer-tools gstreamer0.-tools gstreamer0.-doc
sudo apt-get install gstreamer0.-plugins-base gstreamer0.-plugins-good gstreamer0.-plugins-ugly gstreamer0.-plugins-bad gstreamer0.-plugins-bad-multiverse
* 安装ffmpeg支持
sudo apt-get install gstreamer0.-ffmpeg
* 测试
gst-launch autovideosrc ! ffmpegcolorspace ! autovideosink
或
gst-launch v4l2src ! ffmpegcolorspace ! autovideosink
* 录制摄像头视频
以上内容转自 http://foyo99.zhuidaniu.com/blogs/724
1,设置环境变量
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/usr/local/lib
2,安装mad插件
下载libmad-0.15.1b.tar.gz
http://sourceforge.net/project/showfiles.php?group_id=12349
./configure --prefix=/usr/local/
make
make install
下载libid3tag-0.15.1b.tar.gz
http://sourceforge.net/project/showfiles.php?group_id=12349
./configure --prefix=/usr/local/
make
make install
下载gst-plugins-ugly-0.10.9.tar.bz2 2008.8.26
http://gstreamer.freedesktop.org/src/
./configure
make
make install
这样,在/usr/local/lib/gstreamer-0.10目录下就出现了
libgstmad.a libgstmad.la libgstmad.so
mad插件也就安装成功了!
检测mad插件是否安装上的命令
gst-inspect mad
会显示已安装的mad插件的详细信息
3,用gst-launch测试播放mp3
gst-launch filesrc location="beyond.mp3" ! mad ! audioconvert ! alsasink
可以听到音乐了。
4,用mp3_dec.c文件测试
----------------
#include <gst/gst.h>
int
main(int argc,char *argv[])
{
GstElement *pipeline,*filesrc,*decoder,*convert,*audiosink;
gst_init(&argc,&argv);
if(argc != 2){
g_print("usage: %s <mp3 filename>\n",argv[0]);
exit(-1);
}
pipeline=gst_pipeline_new("pipeline");
if(!pipeline)
{
g_print("Maybe pipeline cann't be created!\n");
exit(-1);
}
filesrc=gst_element_factory_make("filesrc","disk_source");
if(!filesrc)
{
g_print("Maybe filesrc cann't be created!\n");
exit(-1);
}
g_object_set(G_OBJECT(filesrc),"location",argv[1],NULL);
decoder=gst_element_factory_make("mad","decoder-audio");
if(!decoder)
{
g_print("Maybe decoder cann't be created!\n");
exit(-1);
}
convert = gst_element_factory_make("audioconvert", "a-convert");
if(! convert)
{
g_print("Maybe convert cann't be created!\n");
exit(-1);
}
audiosink=gst_element_factory_make("osssink","play_audio");
if(! audiosink)
{
g_print("Maybe audiosink cann't be created!\n");
exit(-1);
}
gst_bin_add_many(GST_BIN(pipeline),filesrc,decoder,convert,audiosink,NULL);
gst_element_link_many(filesrc,decoder,convert,audiosink,NULL);
gst_element_set_state(pipeline,GST_STATE_PLAYING);
while(gst_bin_iterate_recurse(GST_BIN(pipeline)));
gst_element_set_state(pipeline,GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
exit(0);
}
----------------
编译命令
gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10)mp3_dec.c -o mp3_dec
生成可执行文件
mp3_dec
播放mp3
./mp3_dec beyond.mp3
就可以听到音乐了!
note:
Element为null,说明没安装mad插件,可以通过