分享

SUSE10.2环境下gstreamer安装全记录

 moyqsky 2011-01-14

SUSE10.2环境下gstreamer安装全记录 收藏

SUSE10.2环境下gstreamer安装全记录

 


1.         安装gstreamer (gstreamer-0.10.29.tar.gz)

# tar xzf gstreamer-0.10.29.tar.gz

# cd gstreamer-0.10.29/

# ./configure

出现错误:

configure: Requested 'glib-2.0 >= 2.18' but version of GLib is 2.8.6

configure: error: This package requires GLib >= 2.18 to compile.


2.         安装glib (glib-2.24.1.tar.gz)

# tar xzf glib-2.24.1.tar.gz

# cd glib-2.24.1/

# ./configure

# make

# make install


3.         返回安装gstreamer

# cd ../gstreamer-0.10.29/

# ./configure

又出现错误:

configure: error:

Need libxml2 and development headers/files to build GStreamer.

 

You can do without libxml2 if you pass --disable-loadsave to

configure, but that breaks ABI, so don't do that unless you

are building for an embedded setup and know what you are doing.


4.         安装libxml (libxml2-2.7.4.tar.gz)

# tar xzf libxml2-2.7.4.tar.gz

# cd libxml2-2.7.4/

# ./configure

最后出现:

/bin/rm: cannot remove `libtoolT': No such file or directory

Done configuring

没报错,就不管它,继续

# make

# make install


5.         再次返回安装gstreamer

# cd ../gstreamer-0.10.29/

# ./configure

总算是成功了,出现提示:

Configuration

Version                    : 0.10.29

Source code location       : .

Prefix                     : /usr/local

Compiler                   : gcc

Package name               : GStreamer source release

Package origin             : Unknown package origin

 

Documentation (manuals)    : no

Documentation (API)        : no

 

Debug Logging              : yes

Pipeline XML load/save     : yes

Command-line parser        : yes

Option parsing in gst_init : yes

Tracing subsystem          : yes

Allocation tracing         : yes

Plugin registry            : yes

Plugin support             : yes

Network support            : yes

Unit testing support       : yes

 

Debug                      : yes

Profiling                  : no

 

Building examples          : yes

Building test apps         : yes

Building tests that fail   : no

继续

# make

# make install


6.         安装gst-plugins-base插件 (gst-plugins-base-0.10.29.tar.gz)

# tar xzf gst-plugins-base-0.10.29.tar.gz

# cd gst-plugins-base-0.10.29/

# ./configure

又报错了:

configure: error: liboil-0.3.14 or later is required


7.         安装liboil (liboil-0.3.17.tar.gz)

# tar xzf liboil-0.3.17.tar.gz

# cd liboil-0.3.17/

# ./configure

# make

# make install


8.         返回安装gst-plugins-base插件

# cd ../gst-plugins-base-0.10.29/

# ./configure

成功,出现提示:

configure: *** Plug-ins without external dependencies that will be built:

adder

app

audioconvert

audiorate

audioresample

audiotestsrc

ffmpegcolorspace

gdp

playback

subparse

tcp

typefind

videorate

videoscale

videotestsrc

volume

 

configure: *** Plug-ins without external dependencies that will NOT be built:

 

configure: *** Plug-ins with dependencies that will be built:

gio

video4linux

ximagesink

xvimagesink

 

configure: *** Plug-ins with dependencies that will NOT be built:

alsa

cdparanoia

gnomevfs

ivorbisdec

libvisual

ogg

pango

theora

vorbis

应该是缺少一些插件,不管,继续先:

# make

# make install


9.         安装gst-plugins-good插件 (gst-plugins-good-0.10.23.tar.gz)

# tar xzf gst-plugins-good-0.10.23.tar.gz

# cd gst-plugins-good-0.10.23/

# ./configure

成功,出现提示:

configure: *** Plug-ins without external dependencies that will be built:

alpha

apetag

audiofx

auparse

autodetect

avi

cutter

debugutils

deinterlace

effectv

equalizer

flv

flx

goom

goom2k1

icydemux

id3demux

imagefreeze

interleave

law

level

matroska

multifile

multipart

qtdemux

replaygain

rtp

rtpmanager

rtsp

shapewipe

smpte

spectrum

udp

videobox

videocrop

videofilter

videomixer

wavenc

wavparse

y4m

 

configure: *** Plug-ins without external dependencies that will NOT be built:

monoscope

 

configure: *** Plug-ins with dependencies that will be built:

annodex

cairo

gdkpixbuf

oss4

ossaudio

png

v4l2src

ximagesrc

 

configure: *** Plug-ins with dependencies that will NOT be built:

1394

aasink

cacasink

directsoundsink

dv

esdsink

flac

gconfelements

halelements

jpeg

osxaudio

osxvideosink

pulseaudio

shout2

souphttpsrc

speex

sunaudio

taglib

wavpack

貌似比上面那个缺少的还多,本人只要不报错,就不理它,真有问题,返工。继续:

# make

# make install


10.     测试

至此,gstreamer安装结束,可进行简单测试:

# gst-launch -vm audiotestsrc ! audioconvert ! audioresample ! osssink

很不幸,报错了:

/usr/local/bin/gst-launch-0.10: symbol lookup error: /usr/local/bin/gst-launch-0.10: undefined symbol: g_malloc0_n

差不多也就是路径没设置好的问题,在/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

再次运行:

# gst-launch -vm audiotestsrc ! audioconvert ! audioresample ! osssink

成功:能从杨声器里听到蜂鸣音了。


注意了:下面要实现一个简单的MP3播放。

不过,在安装下面3个插件的时候,特别注意安装顺序,具体原因下面有详细分析,不过你可以先按照我的顺序试一下,呵呵。


11.     安装gst-plugins-ugly插件 (gst-plugins-ugly-0.10.15.tar.gz)

# tar xzf gst-plugins-ugly-0.10.15.tar.gz

# cd gst-plugins-ugly-0.10.15/

# ./configure

# make

# make install


12.     安装libmad插件 (libmad-0.15.1b.tar.gz)

# tar xzf libmad-0.15.1b.tar.gz

# cd libmad-0.15.1b/

# ./configure

# make

# make install


13.     安装libid3tag插件 (libid3tag-0.15.1b.tar.gz) (非必须)

# tar xzf libid3tag-0.15.1b.tar.gz

# cd libid3tag-0.15.1b/

# ./configure

# make

# make install


14.     编写最简单的mp3播放程序

代码如下:(有拷贝嫌疑,不管怎么样,请注意代码中的convert

只是让你测试一下,想搞明白代码的意思,请参考以下链接,本人也是这里参考过来的。

http://www.cnblogs.com/phinecos/archive/2009/06/07/1498166.html

 

#include <gst/gst.h>

#include <glib.h>

 

static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)

{

         GMainLoop *loop = (GMainLoop *)data;        

         switch (GST_MESSAGE_TYPE(msg))

         {

         case GST_MESSAGE_EOS:

                   g_print("End of stream\n");

                   g_main_loop_quit(loop);

                   break;

         case GST_MESSAGE_ERROR:

                   {

                            gchar *debug;

                            GError *error;

                            gst_message_parse_error(msg, &error, &debug);

                            g_free(debug);

                            g_printerr("ERROR:%s\n", error->message);

                            g_error_free(error);

                            g_main_loop_quit(loop);

                            break;

                   }

         default:

                   break;

    }   

         return TRUE;

}

 

int main(int argc, char *argv[])

{

         GMainLoop     *loop;

         GstBus             *bus;

         GstElement    *pipeline, *source, *decoder, *convert, *sink;

 

         gst_init(&argc, &argv);

         loop = g_main_loop_new(NULL, FALSE);

         if (argc != 2)

         {

                   g_printerr("Usage:%s <mp3 filename>\n", argv[0]);

                   return -1;

         }

        

         pipeline = gst_pipeline_new("audio-player");

         source = gst_element_factory_make("filesrc", "file-source");

         decoder = gst_element_factory_make("mad", "mad-decoder");

         convert = gst_element_factory_make("audioconvert", "a-convert");

         sink = gst_element_factory_make("autoaudiosink", "audio-output");

         if (!pipeline || !source || !decoder || !convert || !sink)

         {

                   g_printerr("One element could not be created. Exiting...\n");

                   return -1;

         }

        

         g_object_set(G_OBJECT(source), "location", argv[1], NULL);

        

         bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));

         gst_bus_add_watch(bus, bus_call, loop);

         gst_object_unref(bus);

        

         gst_bin_add_many(GST_BIN(pipeline), source, decoder, convert, sink, NULL);

         gst_element_link_many(source, decoder, convert, sink, NULL);

         gst_element_set_state(pipeline, GST_STATE_PLAYING);

         g_print("Running\n");

 

         g_main_loop_run(loop);

         g_print("Returned,stopping playback\n");

 

         gst_element_set_state(pipeline, GST_STATE_NULL);

         gst_object_unref(GST_OBJECT(pipeline));

        

         return 0;

}

 

编译:

# gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) -g my_mp3.c -o my_mp3

编译成功,生成可执行文件my_mp3

开始运行:

# ./my_mp3 /home/chenjj/my_test/src/yanhua.mp3

 

眼看快要成功了,但是可恶的错误又回来了:

./my_mp3: /usr/lib/libxml2.so.2: no version information available (required by /usr/local/lib/libgstreamer-0.10.so.0)

One element could not be created. Exiting...


15.     分析和解决问题

n  关于libxml2.so.2的问题

# cd /usr/lib/

# ls -l libxml2*

lrwxrwxrwx 1 root root      17 2010-06-25 20:05 libxml2.so.2 -> libxml2.so.2.6.23

-rwxr-xr-x 1 root root 1259452 2008-04-22 07:30 libxml2.so.2.6.23

# cd /usr/local/lib/

# ls -l libxml2*

-rw-r--r-- 1 root root 4176246 2010-06-30 18:33 libxml2.a

-rwxr-xr-x 1 root root     932 2010-06-30 18:33 libxml2.la

lrwxrwxrwx 1 root root      16 2010-06-30 18:33 libxml2.so -> libxml2.so.2.7.4

lrwxrwxrwx 1 root root      16 2010-06-30 18:33 libxml2.so.2 -> libxml2.so.2.7.4

-rwxr-xr-x 1 root root 3264492 2010-06-30 18:33 libxml2.so.2.7.4

由此可以看出,是路径的问题。简单一点,直接把/usr/lib/下面的那个软连接删除,并手动建立一个软连接:

# cd /usr/lib

# rm libxml2.so.2

# ln -sf /usr/local/lib/libxml2.so.2.7.4 libxml2.so.2

再次运行:

# ./my_mp3 /home/chenjj/my_test/src/yanhua.mp3

明显第一个错误就没有了:

One element could not be created. Exiting...

 

n  下面解决第2个错误

很明显这个错误是程序本身打印出来的,修改程序添加打印信息:

if (!pipeline || !source || !decoder || !convert || !sink)

{

         g_printerr("One element could not be created. Exiting...\n");

         g_printerr("%d %d %d %d %d\n", pipeline, source, decoder, convert, sink);

         return -1;

}

重新编译,符号不匹配报警,不管,继续。

再次运行,打印信息如下:

One element could not be created. Exiting...

135155728 135168456 0 135200912 135209000

说明是decode没有创建成功,即下面这条语句执行不成功:

decoder = gst_element_factory_make("mad", "mad-decoder");

 

难道是mad没有安装成功???

使用下面命令,检测mad插件是否安装上的命令:

# gst-inspect mad

没有那样的组件或插件‘mad

疯掉,再看其他几个:

# gst-inspect filesrc

# gst-inspect audioconvert

# gst-inspect autoaudiosink

都是有信息打印出来的,唯独这个mad没有。。。

 

重装?试试看:

# cd libmad-0.15.1b/

# make uninstall

# make clean

# ./configure --prefix=/usr/local/

# make

# make install

查看一下,有没有生成lib库:

# cd /usr/local/lib

# ls -l libmad*

-rw-r--r-- 1 root root 241596 2010-06-30 20:21 libmad.a

-rwxr-xr-x 1 root root    798 2010-06-30 20:21 libmad.la

lrwxrwxrwx 1 root root     15 2010-06-30 20:21 libmad.so -> libmad.so.0.2.1

lrwxrwxrwx 1 root root     15 2010-06-30 20:21 libmad.so.0 -> libmad.so.0.2.1

-rwxr-xr-x 1 root root 191090 2010-06-30 20:21 libmad.so.0.2.1

说明该有的也都有了。

 

再次检测mad插件是否安装上:

# gst-inspect mad

没有那样的组件或插件‘mad

天哪!问题不在这里。

 

回想,在安装gst-plugins-ugly插件的时候,好像有什么警告,再看一下。

为了查明此gst-plugins-ugly插件是否和mad插件有关系,还得把mad先卸载掉。

# cd libmad-0.15.1b/

# make uninstall

# cd ../gst-plugins-ugly-0.10.15/

# ./configure

configure: *** Plug-ins without external dependencies that will be built:

asfdemux

dvdlpcmdec

dvdsub

iec958

mpegaudioparse

mpegstream

realmedia

 

configure: *** Plug-ins without external dependencies that will NOT be built:

synaesthesia

 

configure: *** Plug-ins with dependencies that will be built:

 

configure: *** Plug-ins with dependencies that will NOT be built:

a52dec

amrnb

amrwbdec

cdio

dvdreadsrc

lame

mad

mpeg2dec

sid

twolame

x264

好,现在问题就明显了,Plug-ins with dependencies that will NOT be built,包括mad

这样就好办了,先装mad,再装gst-plugins-ugly

# cd ../libmad-0.15.1b/

# make install

# cd ../gst-plugins-ugly-0.10.15/

# ./configure

configure: *** Plug-ins with dependencies that will be built:

mad

 

configure: *** Plug-ins with dependencies that will NOT be built:

a52dec

amrnb

amrwbdec

cdio

dvdreadsrc

lame

mpeg2dec

sid

twolame

x264

# make

# make install

 

再次检测mad插件是否安装上:

# gst-inspect mad

一堆信息出来了。。。

 

回去重新运行程序:

# ./my_mp3 /home/chenjj/my_test/src/yanhua.mp3

Running

恭喜,你是不是听到歌曲了(如果你装了音响或使用耳机)

 

再次总结:

在装libmad插件和gst-plugins-ugly插件时:

1)         先装libmad

2)         再装gst-plugins-ugly

原因嘛,后者依赖前者吧。。。


16.     总结:

1)         安装gstreamer

n  安装glib

n  安装libxml

n  安装gstreamer

2)         安装几个插件

n  安装liboil

n  安装gst-plugins-base插件

n  安装gst-plugins-good插件

3)         测试

n  # gst-launch -vm audiotestsrc ! audioconvert ! audioresample ! osssink

4)         实现MP3播放

n  安装libmad插件

n  安装libid3tag插件

n  安装gst-plugins-ugly插件

n  编写最简单的mp3播放程序

n  编译:

# gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) -g my_mp3.c -o my_mp3

n  运行:

# ./my_mp3 /home/chenjj/my_test/src/yanhua.mp3

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多