只是记录而已,防止日后忘记。
由于最新版本的nginx要求比较新的automake版本,但是我们老大是保守类型的,系统版本很老了 然后有些东西不方便升级,以免造成不必要的麻烦,因此需要用比较老版本的nginx来实现。下面参考这几个链接中提供的内容:
http://blog.csdn.net/crazyman2010/article/details/18266487
http://blog.csdn.net/u011641885/article/details/49863723
http://blog.csdn.net/fish43237/article/details/40515897
我这里下载了他修改后的nginx-1.5..8_arm库,斌修改了nginx-1.5.8_arm/auto/types/sizeof 文件,因为现在大部分linux都是i686 64位的系统了,通过讲$CC修改为系统的gcc那还是不能获取正确的size。所以这里就直接修改了
ngx_size=4
cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
#include <sys/time.h>
$NGX_INCLUDE_UNISTD_H
#include <signal.h>
#include <stdio.h>
#include <sys/resource.h>
$NGX_INCLUDE_INTTYPES_H
$NGX_INCLUDE_AUTO_CONFIG_H
int main() {
printf("%d", (int) sizeof($ngx_type));
return 0;
}
END
ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
ngx_size=4
echo " $ngx_size bytes"
fi
下面我贴出我的my_configure_arm.sh文件的内容:
#!/bin/sh
BUILD_PATH=$PWD/arm-build
CC_PATH=arm-linux-gcc
CPP_PATH=arm-linux-g++
./configure \
--prefix=$PWD/install \
--user=root \
--group=root \
--builddir=$BUILD_PATH \
--with-pcre \
--with-pcre=../pcre-8.20 \
--with-pcre-jit \
--with-http_flv_module \
--with-http_mp4_module \
--add-module=../nginx-rtmp-module \
--with-cc=$CC_PATH \
--with-cpp=$CPP_PATH
其中builddir目录不能是build目录,不然make的时候会出现make:没有什么可以做的为`default',我看了Makefile文件里面有build伪指令。添加的nginx-rtmp-module工程是最新的,在master分支,还添加了flv和MP4的module。
然后make install 后会安装到当前的install目录,主要是我没有根用户的权限,所以nginx所使用的nginx.conf配置文件的路径,要保持和你安装时候的路径一致。
问题:
# ./nginx
nginx: [emerg] getpwnam("root") failed (2: No such file or directory)
这个问题查阅网上的解决方法没有用,通过strace命令来跟踪进程执行时的系统调用和所接收的信号,得到如下信息:
open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=4163, ...}) = 0
mmap2(NULL, 4163, PROT_READ, MAP_PRIVATE, 4, 0) = 0x2ab4d000
close(4) = 0
open("/lib/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0x2ab4d000, 4163) = 0
open("/etc/ld.so.cache", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=4163, ...}) = 0
mmap2(NULL, 4163, PROT_READ, MAP_PRIVATE, 4, 0) = 0x2aba4000
close(4) = 0
open("/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0x2aba4000, 4163) = 0
write(3, "1970/01/04 08:41:42 [emerg] 8091"..., 91) = 91
write(2, "nginx: [emerg] getpwnam(\"root\") "..., 70nginx: [emerg] getpwnam("root") failed (2: No such fi)
) = 70
exit_group(1) = ?
发现缺少libnss_*相关的库文件,讲缺少的库补上后,nginx可以正常运行了。
修改配置文件/home/fulinux/nginx-src/nginx-1.5.8_arm/install/conf/nginx.conf,最后加上:
rtmp {
server {
listen 1935;
application live {
live on;
record off;
}
}
}
./nginx -s reload
通过如下命令向rtmp服务发送视频流:
# gst-launch -e v4l2src do-timestamp=true ! 'video/x-raw-yuv, format=(fourcc)I42
0, width=(int)640, height=(int)480, interlaced=(boolean)false, framerate=(fracti
on)15/1' ! vpuenc codec=6 bitrate=458752 seqheader-method=3 ! flvmux streamable=
true name=mux alsasrc device=plughw:1,0 blocksize=22050 ! audioconvert ! faac bi
trate=65536 ! mux. mux. ! rtmpsink location="rtmp://localhost:1935/live/video"
会有如下提示:
# ./nginx
# gst-launch -e v4l2src do-timestamp=true ! 'video/x-raw-yuv, format=(fourcc)I42
0, width=(int)640, height=(int)480, interlaced=(boolean)false, framerate=(fracti
on)15/1' ! vpuenc codec=6 bitrate=458752 seqheader-method=3 ! flvmux streamable=
true name=mux alsasrc device=plughw:1,0 blocksize=22050 ! audioconvert ! faac bi
trate=65536 ! mux. mux. ! rtmpsink location="rtmp://localhost:1935/live/video"
Setting pipeline to PAUSED ...
[INFO] Product Info: i.MX6Q/D/S
vpuenc versions :)
plugin: 3.0.7
wrapper: 1.0.35(VPUWRAPPER_ARM_LINUX Build on May 18 2017 16:22:43)
vpulib: 5.4.12
firmware: 2.3.10.40778
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
[INFO] chromaInterleave 0, mapType 0, linear2TiledEnable 0
WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can't record audio fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Dropped 64386 samples. This is most likely because downstream can't keep up and is consuming samples too .
WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can't record audio fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Dropped 11907 samples. This is most likely because downstream can't keep up and is consuming samp
不过这个提示在我的平台上暂且忽略,然后在PC上可以通过如下方法播放:
ffplay rtmp://192.168.0.51:1935/live/video