搭建nginx+ffmpeg服务

来源:互联网 发布:吉利知豆电动汽车官网 编辑:程序博客网 时间:2024/04/30 11:41

<u></u>

近日因为工作需要自己写了一个使用ffmeg进行推流的WIN32客户端程序【后续有时间会研究手机端的处理】。
目前推送到外网买的服务器上,结果使用vlc进行本地播放花屏,要么就是根本出不来。初步判断是在推送流的时候的时间戳有问题。对方也没法提供我的推流信息,无奈自己搭建了一套基于nginx+ffmpeg的服务。纯粹是便于调试,也便于这方面的学习。

搭建服务的过程历时3天吧。磕磕绊绊的,到目前为止总算是起来了。现在就来总结一下,同时也方便后人的学习。我的安装环境是Ubuntu

一.准备

根据需要,上网查资料,找到了篇这方面很好的帖子。

http://www.cnblogs.com/wainiwann/p/3866254.html

有些人可能就这篇帖子就可以很好的搭建好了。但是目前我想记录的是问题。

二.开始

首先,并不像上面介绍的开始那样,我是将用到的包都下载放到了启动路径下:


如图所示,这些包基本就是基于开篇提到的这个帖子里的包。并且在解压的时候也没单独设立文件夹,只是一股脑地都解压到当前这个目录下。


我的安装过程也基本上跟第二篇帖子中提到的一致。具体的可以进行参考那个。

git没有安装最新的,只是有种傻瓜式的安装git的方式:sudo yum install git

除去帖子中提到的问题之外,还有我遇到的其他问题。


根据上篇帖子介绍,安装完毕之后需要重新启动nginx以达到最终目的。

root@10-10-26-250:<strong>/usr/local/nginx/sbin# ./nginx -s reload</strong>nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"

如上,进入nginx/sbin下,使用./nginx -s reload进行重启,结果报错。解决如下:

查看所有进程:ps -aux


尽然没有nginx主进程。继续解决:

root@10-10-26-250:~# <strong>ps -ef |grep nginx</strong>www-data 10215     1  0 Nov09 ?        00:00:04 nginx: worker processwww-data 10216     1  0 Nov09 ?        00:00:04 nginx: worker processroot     20602 20582  0 14:09 pts/0    00:00:00 grep --color=auto nginx
进一步确定了心中所想,放大招:

root@10-10-26-250:~# <strong>killall -9 nginx</strong>

root@10-10-26-250:~# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

这里没有使用“server nginx start”,这个是需要先做“apt-get install rsplib-legacy-wrappers”处理。

root@10-10-26-250:~# <strong>ps -ef |grep nginx</strong>root     20613     1  0 14:11 ?        00:00:00 nginx: <strong><span style="color:#ff0000;">master process</span></strong> /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confnobody   20614 20613  0 14:11 ?        00:00:00 nginx: worker process                                          nobody   20615 20613  0 14:11 ?        00:00:00 nginx: worker process                                          nobody   20616 20613  0 14:11 ?        00:00:00 nginx: worker process                                          nobody   20617 20613  0 14:11 ?        00:00:00 nginx: worker process                                          nobody   20618 20613  0 14:11 ?        00:00:00 nginx: cache manager process                                   root     20620 20582  0 14:12 pts/0    00:00:00 grep --color=auto nginx


看到了红的发紫的master process,心中一片窃喜。至此问题就解决完毕了。



0 0
原创粉丝点击