Jestson NX安装nginx

安装过程

1.安装依赖工具

sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev

2.查看opnssl

openssl version 
#查看openssl版本,如果是1.1.1安装nginx-1.17.9,我的jetpacket 4.4.1里面是openssl-1.1.1
#如果是1.0.x,安装nginx-1.7.5
wget http://nginx.org/download/nginx-1.17.9.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

3.安装编译

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make
sudo make install
sudo wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo update-rc.d nginx defaults

如果遇到报错

cc1: all warnings being treated as errors
objs/Makefile:460: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/home/wzj/tools/nginx/nginx-1.17.1'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

只需要去./objs/Makefile文件中将gcc参数中的-Werror去掉

4.启动或者停止服务

sudo service nginx start
sudo service nginx stop

5.配置rtmp服务

打开/usr/local/nginx/conf/nginx.conf

events {
  #  use epoll;
    worker_connections  20480;
}


rtmp{
    server {
	listen 1935;  #监听端口,自己设置
	#drop_idle_publisher 10s;
	chunk_size 4096;
	application live_result {
	    live on;
	    wait_key on;
	    #gop_cache on;
	    #record off;
	}

	application live_original { #端口子目录
	    live on;
	    #record off;
	}
    }
}


http{
……
……
}

6.编写脚本

import cv2
import subprocess as sp
import numpy as np

gst_elements = str(sp.check_output('gst-inspect-1.0'))
if 'nvcamerasrc' in gst_elements:
# On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
    gst_str = ('nvcamerasrc ! '
               'video/x-raw(memory:NVMM), '
               'width=(int)2592, height=(int)1458, '
               'format=(string)I420, framerate=(fraction)30/1 ! '
               'nvvidconv ! '
               'video/x-raw, width=(int){}, height=(int){}, '
               'format=(string)BGRx ! '
               'videoconvert ! appsink').format(1280, 720)
elif 'nvarguscamerasrc' in gst_elements:
    gst_str = ('nvarguscamerasrc ! '
               'video/x-raw(memory:NVMM), '
               'width=(int)1280, height=(int)720, '
               'format=(string)NV12, framerate=(fraction)30/1 ! '
               'nvvidconv flip-method=0 ! '
               'video/x-raw, width=(int){}, height=(int){}, '
               'format=(string)BGRx ! '
               'videoconvert ! appsink').format(1280, 720)
else:
    raise RuntimeError('onboard camera source not found!')


cap = cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)  # video capture object
cap.set(cv2.CAP_PROP_BUFFERSIZE, 3)  # set buffer size

command = ['ffmpeg',
           '-y',
           '-f', 'rawvideo',
           '-vcodec', 'rawvideo',
           '-pix_fmt', 'bgr24',
           '-s', "{}x{}".format(1280, 720),
           '-r', str(30),
           '-i', '-',
           '-c:v', 'libx264',
           '-pix_fmt', 'yuv420p',
           '-preset', 'ultrafast',
           '-f', 'flv',
           'RtmpUrl']   #推送Rtmp的服务器地址,例如'rtmp://localhost:1935/live_original/4'


if __name__ == "__main__":
    p = sp.Popen(command, stdin=sp.PIPE)
    while True:
        if cv2.waitKey(1) == ord('q'):  # q to quit
            cap.release()
            cv2.destroyAllWindows()
            raise StopIteration
        ret_val, img = self.cap.read()
        p.stdin.write(img.tostring())


7.播放

在同一局域网下的另一台机器上使用可以播放视频流的软件(我用的VLC),输入上文中RtmpUrl播放

8.参考

https://blog.csdn.net/u010285974/article/details/92796964

https://blog.csdn.net/xiao__run/article/details/114662994

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值