gstreamer for ARM
一:准备环境。
1。 首先需要一个交叉编译器。如:
/usr/local/arm-linux-gcc-3.4.3/
安装的路径:/usr/local
$ ls /usr/local/arm-linux-gcc-3.4.3/
arm-linux arm-linux-uclibc bin bin-ccache include info lib libexec man usr
编译出来的文件都保存在:/usr/local/arm-linux里面
2. gstramer 依赖以下的packages:glib and libxml,这些包都可以从网上下载。
我用的是:glib-2.22.2.tar.bz2 gstreamer-0.10.25.tar.bz2 libxml2-git-snapshot.tar.gz
3。 有些版本的ulibc并不带有 libiconv 和 gettext 。编译glib 需要这两个包。
二:编译
1。编译libxml
CC=arm-linux-gcc ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux CFLAGS=-I/usr/local/arm-linux/include/ --with-python=/usr/lib
make && make install
2。编译libiconv
CC=arm-linux-gcc ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux
make && make install
3。编译gettext
CC=arm-linux-gcc ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux
在我的系统上面会有wchar相关的错误。
find . -name "wchar.h"
rm ./gettext-tools/gnulib-lib/wchar.h ./gettext-runtime/gnulib-lib/wchar.h
vim ./gettext-tools/libgettextpo/Makefile (把编译wchar 的删除)
make
会有符号没有定义
HAVEICONV=1 make
wchar相关错误
find . -name "wchar.h"
vim ./gettext-tools/libgettextpo/Makefile(把编译wchar 的删除)
rm ./gettext-tools/libgettextpo/wchar.h
make && make install
4。编译glib
CC=arm-linux-gcc CFLAGS="-L/usr/local/arm-linux/lib -I/usr/local/arm-linux/include -liconv" ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes ac_cv_lib_rt_clock_gettime=no glib_cv_monotonic_clock=yes
make && make install
5。编译gstreamer
CC=arm-linux-gcc PKG_CONFIG_PATH=/usr/local/arm-linux/lib/pkgconfig/ ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux CFLAGS=-I/usr/local/arm-linux/include/ --disable-loadsave --disable-gtk-doc --disable-tests --disable-valgrind
make && make install
三:安装和测试
1。 安装:把/usr/loca/arm-linux拷贝到测试机上面。比如目录为:/usr/local//arm-linux
2。 编写测试程序 helloworld.c
int main (int argc, char *argv[]) { const gchar *nano_str; guint major, minor, micro, nano; gst_init (NULL, NULL); gst_version (&major, &minor, µ, &nano); if (nano == 1) nano_str = "(CVS)"; else if (nano == 2) nano_str = "(Prerelease)"; else nano_str = ""; printf ("This program is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str); return 0; }
3。编译和运行测试程序
$arm-linux-gcc helloworld.c -I/usr/local/arm-linux/include/glib-2.0 -I/usr/local/arm-linux/lib/glib-2.0/include -I/usr/local/arm-linux/include/gstreamer-0.10 -L/usr/local/arm-linux/lib -lgstreamer-0.10 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -liconv -lgettextlib -lgettextpo -lgettextsrc -lintl
把生成的a.out拷贝到测试机上面。然后设置:LD_LIBRARY_PATH=/usr/local/arm-linux/lib 。
运行a.out应该有输出:
“This program is linked against GStreamer 0.10.25”
本文参考了:http://blog.csdn.net/dyzhu/archive/2009/07/02/4316177.aspx
附录:
一:编译 gstreamer 的 plugin。
1。 编译 plug-in base for gstreamer:
CC=arm-linux-gcc PKG_CONFIG_PATH=/usr/local/arm-linux/lib/pkgconfig/ ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux CFLAGS=-I/usr/local/arm-linux/include/ --disable-valgrind --disable-x --disable-gnome_vfs --disable-alsa --disable-ogg --disable-pango --disable-theora --disable-vorbis --disable-examples
2。编译 plug-in good for gstramer
CC=arm-linux-gcc PKG_CONFIG_PATH=/usr/local/arm-linux/lib/pkgconfig/ ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux CFLAGS=-I/usr/local/arm-linux/include/ --disable-valgrind --disable-examples --disable-gconftool --disable-avi --disable-id3demux --disable-libpng --disable-jpeg --disable-gdk_pixbuf --disable-x --disable-osx_audio --disable-oss --disable-aalib --disable-cairo --disable-esd --disable-hal --disable-directsound --disable-xvideo --disable-gconf --disable-libdv --disable-libpng --disable-soup --disable-taglib --disable-bz2 --disable-zlib --disable-shout2 --disable-shout2test --disable-speex
然后去修改tests/Makefile,把和check相关的去掉
make && make install
3。编译 plug-in bad for gstramer
CC=arm-linux-gcc PKG_CONFIG_PATH=/usr/local/arm-linux/lib/pkgconfig/ ./configure --build=i686-linux --host=arm-linux --prefix=/usr/local/arm-linux CFLAGS=-I/usr/local/arm-linux/include/ --disable-valgrind --disable-examples --disable-h264parse --disable-oss4 --disable-vdpau --disable-mpeg4videoparse --disable-mpegvideoparse --disable-mpegdemux --disable-mpegtsmux --disable-id3tag --disable-librfb --disable-liveadder --disable-alsa --disable-sdl --disable-xvid --disable-theoradec --disable-soundtouch --disable-dvb --disable-wininet --disable-vcd
make && make install
二:运行测试程序
#gst-launch v4l2src num-buffers=1 ! ffmpegcolorspace ! video/x-raw-yuv,width=640,height=480! filesink location=test.yuv (生成yuv格式的文件)
#gst-launch v4l2src num-buffers=1 ! ffmpegcolorspace ! video/x-raw-yuv,width=640,height=480 ! jpegenc ! filesink location=test.jpg (生成jpege文件)
三:加入video的支持
1。编译 libjpeg-6a, libvorbis-1.2.3, libogg-1.1.4
2。 去http://www.theora.org/downloads/ 下载 theora支持
更改libtheora-1.1.1/lib/Makefile, 在am__objects_11定义的地方加上info.lo,否则在libtheoraenc.so中会有没有定义的符号。
3。 重新配置 gst-plugin-base,把 --disable-ogg --disable-theora去掉
录制一段:#gst-launch v4l2src ! 'video/x-raw-yuv,width=640,height=480' ! queue ! videorate ! 'video/x-raw-yuv,framerate=30/1' ! theoraenc ! queue ! oggmux ! filesink location=me_funny_dancing.ogg
有关cannot restore segment prot after reloc: Permission denied 问题的解答
在linux上安装有些东西时会出现 Permission denied 的情况:以下就是解决它的办法之一
编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。
......
编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。
如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。
-------------------------------------------------------------------------------------
郁闷的是.我把SELinux关闭后还是不行.于是到google上search.发现这个很有用.
在你保证SElinux 被disable后.还执行下
chcon -t texrel_shlib_t
如: chcon -t texrel_shlib_t /路径/路径/名字.so (这个文件视具体执行文件.)
问题2:在编译glib时如果出现下面的提示:
libtool: eval: line 964: syntax error near unexpected token `|'
solution(解决方案):http://hi.baidu.com/amixyue/blog/item/944adadfc1532aaacd1166bc.html
USE_ARCH=32 NM=nm CC="mipsel-linux-gnu-gcc ${BUILD32}" ./configure \
--with-gnu-ld \
--target=mipsel-linux \
--host=mipsel-linux \
CC=mipsel-linux-gnu-gcc \
--prefix=/usr
上面的nm的用途:nm是用来查看指定程序中的符号表相关内容的工具
gstreamer for mips
2.1 辅助库和版本libiconv: libiconv-1.14.tar
configure选项:
CC=mipsel-linux-gnu-gcc ./configure --build=i686-linux --host=mipsel-linux --prefix=/home/xxx/mipsel-linux
make & make install
gettext: gettext-0.18.1.1.tar
CC=mipsel-linux-gnu-gcc ./configure --build=i686-linux --host=mipsel-linux --prefix=/home/xxx/mipsel-linux
make & make install
zlib:zlib-1.2.3
CC=mipsel-linux-gnu-gcc ./configure --prefix=/home/xxx/mipsel-linux --shared
libxml2: libxml2-sources-2.7.8
CC=mipsel-linux-gnu-gcc ./configure --build=i686-linux --host=mipsel-linux --prefix=/home/xxx/mipsel-linux CFLAGS=-I/home/xxx/mipsel-linux/include/
make && make install
glib: glib-2.24.1.tar.bz2
USE_ARCH=32 NM=nm CC=mipsel-linux-gnu-gcc CFLAGS="-L/home/xxx/mipsel-linux/lib
-I/home/xxx/mipsel-linux/include -liconv" ./configure --build=i686-linux
--host=mipsel-linux --target=mipsel-linux --prefix=//home/xxx/mipsel-linux
glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=yes
ac_cv_func_posix_getgrgid_r=yes ac_cv_lib_rt_clock_gettime=no
glib_cv_monotonic_clock=yes --with-libiconv=gnu --with-gnu-ld
在编译glib时有时会遇上上面提到的问题2,解决方法如上所述。
glib_cv_uscore=no:不要设置为yes,否则可能会出现问题"blacklist"
gstreamer: gstreamer-0.10.33.tar
C=mipsel-linux-gnu-gcc PKG_CONFIG_PATH=/home/xxx/mipsel-linux/lib/pkgconfig/
./configure --build=i686-linux --host=mipsel-linux
--prefix=/home/xxx/mipsel-linux/ CFLAGS=-I/home/xxx/mipsel-linux/include/
--disable-loadsave --disable-gtk-doc --disable-tests --disable-valgrind
base_plugin: gst-plugins-base-0.10.30.tar.gz
CC=mipsel-linux-gnu-gcc NM=nm PKG_CONFIG_PATH=/home/xxx/mipsel-linux/lib/pkgconfig/
./configure --build=i686-linux --host=mipsel-linux --prefix=/home/xxx/mipsel-linux CFLAGS=-I/home/xxx/mipsel-linux/include/ --disable-valgrind --disable-x --disable-gnome_vfs --disable-alsa --disable-ogg --disable-pango --disable-theora --disable-vorbis --disable-examples
编译完成后,只需要将/home/xxx/mipsel-linux这个目录下载到小机上即可。
在小机上运行时,需要在/usr/lib中建立一个soft link:
ln -s mipsel-linux/lib /usr/lib
设置好GST_PLUGIN_PATH,GST_PLUGIN_SCANNER 变量。
就可以正常运行:gst-inspect.