Gstreamer简单介绍:
GStreamer 作为流媒体应用框架,采用了基于插件(plugin)和管道(pipeline)的体系结构,框架中的所有的功能模块都被实现成可以插拔的组件(component),并且在需要的时候能够很方便地安装到任意一个管道上,由于所有插件都通过管道机制进行统一的数据,因此很容易利用已有的各种插件“组装”出一个功能完善的多媒体应用程序。
在Ubuntu上安装gstreamer:
在安装之前首先要设置代理
有三个地方:
1 network proxy
2
3 在命令行里输入 gedit
然后在文件里加入
Acquire::http::proxy "http://student102:student@10.1.243.240:8080/";这里面的账号和密码老自动删除了,如代理有问题在进来看看这
一、去http://gstreamer.freedesktop.org/下载源码包,一般要安装gstreamer以下最基本的包,分别下载:
Gstreamer-0.10.35.tar.bz2
gst-plugins-base-0.10.35.tar.bz2
gst-plugins-good-0.10.30.tar.bz2
二、安装gstreamer:
解压后,进入目录直接执行./configure,此时出现如下错误:
configure: error: Could not find bison
出现这个错误,说明找不到bison,那么解决方案也很简单,安装bison。
解决办法:
administrator@ubuntu:~/gstreamer-0.10.35$ sudo apt-get install bison
make
make install
cd ..
再次运行./configure,出现如下错误:
administrator@ubuntu:~/gstreamer-0.10.35$ ./configure
....
checking for bison... /usr/bin/bison
checking bison version 2.4.1 >= 1.875... Yes
checking for flex... No
configure: error: Could not find flex
解决办法,同上面安装bison的过程:
administrator@ubuntu:~/下载/gstreamer-0.10.35$ sudo apt-get install flex
make
make install
cd ..
再次运行./configure,出现如下错误:
checking for GLIB... No
configure: No package 'glib-2.0' found
No package 'gobject-2.0' found
No package 'gthread-2.0' found
No package 'gmodule-no-export-2.0' found
configure: error: This package requires GLib >= 2.22 to compile.
解决办法:
administrator@ubuntu:~/gstreamer-0.10.35$ sudo apt-get install glib-2.0
make
make install
cd ..
再次运行./configure,出现如下错误:
configure: error: *** Working zlib library and headers not found ***
解决办法:
administrator@ubuntu:~/下载/glib-2.29.4$ sudo apt-get install zlib1g
administrator@ubuntu:~/下载/glib-2.29.4$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
...
configure: error: Package requirements (libffi >= 3.0.0) were not met:
No package 'libffi' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBFFI_CFLAGS
and LIBFFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
安装libffi
错误解决
administrator@ubuntu:~/下载/glib-2.29.4$ ./configure
...
checking for msgfmt... no
configure: error:
*** You must have either have gettext support in your C library, or use the
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
安装gettex
administrator@ubuntu:~/下载/glib-2.29.4$ sudo apt-get install gettex
administrator@ubuntu:~/下载/glib-2.29.4$
无错误。
administrator@ubuntu:~/下载/glib-2.29.4$
administrator@ubuntu:~/下载/gstreamer-0.10.35$ ./configure
。。。。
checking for XML... no
no
configure: error:
安装libxml2
administrator@ubuntu:~/下载/gstreamer-0.10.35$ sudo apt-get install libxml2
解压libxml2-2.7.7.tar.gz
administrator@ubuntu:~/下载/libxml2-2.7.7$ ./configure
出错:
config.status: executing libtool commands
/bin/rm: cannot remove `libtoolT': No such file or directory
Done configuring
administrator@ubuntu:~/下载/libxml2-2.7.7$ make & sudo make install
administrator@ubuntu:~/下载/gstreamer-0.10.35$ ./configure
安装完成
Configuration
在安装完gstreamer后,安装其他plugins之前要设置PKG_CONFIG_PATH正确。
3.安装gst-plugins-base:
安装前要设置环境变量,由于gstreamer是默认安装,没有设置--prefix,所以将export
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH就行了
./configure,提示缺少liboil,去https://launchpad.net/ubuntu/+source/liboil/0.3.14
也可以在 gedit /etc/profile 末尾 加上下面的语句
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
export
LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
-3下载安装即可
make
make install
4.安装gst-plugins-good:
./configure
make
make install
这里有可能 在 Synaptic Package Manager里下载G++
到此可以用gst-launch -vm audiotestsrc ! audioconvert ! audioresample ! osssink
测试能在杨声器里听到蜂鸣音
注意:总之,在安装过程中,缺什么就apt-get install,找不到就去网上下载安装。
5.编写代码测试,最简单的mp3播放:
a.需要使用mad解码插件,因此首先要安装libid3tag0-dev和libmad0-dev
b.接着安装gstreamer0.10-plugins-ugly才会安装上mad
这上面三个包得按顺序安装,要不可能出问题
编写.c
#include
#include
#define
static
static
delete_event(GtkWidget
{
}
static
destroy(GtkWidget
{
}
static
window_create(void)
{
}
int
main(int
{
#if
#endif
#if
#else
#endif
编译运行:
gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) hello.c -o hello
../hello 路径/yourfilename.mp3