简介
初次接触RTMP推流,先在win10上跑一边,然后再使用开发板推流。同时hisi的SDK版本为Hi3516EV200_SDK_V1.0.1.1
,芯片为hisi3516ev200
win10-ubuntu推流
ubuntu搭建服务器,win10推流,同时win10拉流播放。
# ubuntu IP
192.168.1.104
# win10 IP
192.168.1.03
推流服务器搭建
https://github.com/illuspas/Node-Media-Server 开源库搭建RTMP服务器
git clone https://github.com/illuspas/Node-Media-Server
cd Node-Media-Server/
sudo apt install nodejs -y
sudo apt install npm -y
npm i
node app.js
# 端口默认为 1935
# 5/20/2020 14:38:53 17125 [INFO] Node Media Rtmp Server started on port: 1935
win10推流程序
使用雷神的代码
- https://github.com/leixiaohua1020/simplest_librtmp_example
在win10上面运行 vs2019运行, 记得修改推流地址为RTMP服务器地址 ```simplest_librtmp_send264.cpp
- RTMP264_Connect(“rtmp://192.168.1.104:1935/live/stream”); ```
win10拉流
使用VLC打开 rtmp://192.168.1.104:1935/live/stream
网络拉流
rtmp://192.168.1.104:1935/live/stream
win10拉流海思保存的H264文件
sample_venc.c
文件的SAMPLE_VENC_MJPEG_JPEG函数将会保存H264文件。将其复制到win10下面,使用雷神的代码推流即可。
hisi推流
编译librtmp
export LC_ALL=C
参考 https://blog.csdn.net/weixin_36983723/article/details/83377010 需要另外编译 zlib 以及 openssl。
最后我们将所有的库安装在/home/zhou/hisi/rtmp/install
zlib
下载地址 https://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz/download?use_mirror=nchc&download=
export OSDRV_CROSS=arm-himix100-linux
export CC=${OSDRV_CROSS}-gcc
./configure --prefix=/home/zhou/hisi/rtmp/install
make
make install
openssl
tar -zxvf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l/
CC=gcc ./config no-asm no-async shared --prefix=/home/zhou/hisi/rtmp/install --cross-compile-prefix=arm-himix100-linux-
-修改Makefile
删除 **-m64**
make
make install
librtmp
https://rtmpdump.mplayerhq.hu/
git clone git://git.ffmpeg.org/rtmpdump
cd rtmpdump/librtmp/
我的目的是将librtmp全部编译成为静态,以及他提供的测试代码也编译成为静态的。
- 修改Makefile,修改了下面两个Makefile文件
- Makefile # 主要是为了生成demo
- librtmp/Makefile # 生成lib库 ``` zhou@zhou:~/hisi/rtmp/rtmpdump$ git diff Makefile diff —git a/Makefile b/Makefile index a1595a8..9f0476c 100644 —- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ VERSION=v2.4
-prefix=/usr/local +prefix=/home/zhou/hisi/rtmp/install
CC=$(CROSS_COMPILE)gcc LD=$(CROSS_COMPILE)ld
SYS=posix +#SYS=posix
SYS=mingw
CRYPTO=OPENSSL @@ -36,7 +37,7 @@ LIBSposix= LIBS_darwin= LIBS_mingw=-lws2_32 -lwinmm -lgdi32 LIB_RTMP=-Llibrtmp -lrtmp -LIBS=$(LIB_RTMP) $(CRYPTO_LIB) $(LIBS$(SYS)) $(XLIBS) +LIBS=-Wl,-Bstatic -Wl,—start-group $(LIBRTMP) $(CRYPTO_LIB) $(LIBS$(SYS)) $(XLIBS) -Wl,—end-group -Wl,-Bdynamic -ldl
THREADLIB_posix=-lpthread THREADLIB_darwin=-lpthread
zhou@zhou:~/hisi/rtmp/rtmpdump$ git diff librtmp/Makefile diff —git a/librtmp/Makefile b/librtmp/Makefile index 2c1c790..b41ba46 100644 —- a/librtmp/Makefile +++ b/librtmp/Makefile @@ -1,6 +1,6 @@ VERSION=v2.4
-prefix=/usr/local +prefix=/home/zhou/hisi/rtmp/install
编译
make SHARED= CROSS_COMPILE=arm-himix100-linux- INC=-I/home/zhou/hisi/rtmp/install/include LDFLAGS=-L/home/zhou/hisi/rtmp/install/lib make install CROSS_COMPILE=arm-himix100-linux- INC=-I/home/zhou/hisi/rtmp/install/include LDFLAGS=-L/home/zhou/hisi/rtmp/install/lib
最后生成的路径位于/home/zhou/hisi/rtmp/install
cd /home/zhou/hisi/rtmp/install/bin/
查看库依赖,只有这两个库的依赖,将rtmpdump复制到开发板上面即可运行
arm-himix100-linux-objdump -p rtmpdump | grep NEEDED NEEDED libdl.so.0 NEEDED libc.so.0 ```