[RTMP]JWPLAYER: Could not connect to server

Days ago, I reinstalled nginx + nginx-rtmp-module on my notebook, and had it tested in my local environment with firefox and VLC player, made sure it worked(You can refer to this post for guide: http://rg4.net/archives/1414.html).

However, when I tried to redo the working on my VPS, only to find that it failed to connected to the stream with JWPlayer. Continue reading “[RTMP]JWPLAYER: Could not connect to server”

A simple guide to start rtmp streaming with nginx

I was once using nginx, nginx-rtmp-module and EasyRTMP(http://rg4.net/easyrtmp) to streaming live video with rtmp mode.

It was just for fun, and I didn’t find a chance to utilize it in work. I suggested it to my boss year ago, but it was turned down, comparing to the works on schedule it was always a minor factor to the products. So one day when I found my disk out of usage, I re-installed my OS without backup any data of the previous working environment. Continue reading “A simple guide to start rtmp streaming with nginx”

Migrated my blog to a VPS

It was last week when my virtual host service ended. Instead of continue with the virtual host, I decided to upgrade and migrate my blog to a VPS. Here are the major steps you need to do to start a VPS hosting.

——————————————————–
LNMP
——————————————————–

1. Installing LNMP to your VPS server.
————————–
wget http://soft.vpser.net/lnmp/lnmp1.0.tar.gz
tar -xvf lnmp1.0.tar.gz
cd lnmp1.0
./ubuntu.sh 2>&1 | tee lnmp.log

You need to input your password for mysql root user right after started the installation.
Then you can have a drink, or watch a TV, while waiting for the installation to be finished, because it would be a long long time.

2. Configurating tht LNMP

1) Virtual host management
a) Add a new virtual host
./vhost.sh
Follow the prompt hint.
Add the domain name you want to bind. If you want to bind multiple domains, you can redo it, or just simply add them together with a BLANK seperated the domains.
Input the host directory for the domain(s).

b) Remove a virtual host
rm /usr/local/nginx/conf/vhost/YOUR-DOMAIN-NAME.conf

3) Install PureFTPd and FTP management console panel.
./pureftpd.sh
You need to input:
    Your MySQL's root user password.
    FTP management console password.
    MySQL ftp database password(Just press Enter, the system will generate a password for you automaticly).
After installed PureFTPd, navigate to http://YOUR-DOMAIN-NAME-OR-IP/ftp to start to manage your FTP server

If you ran into an error like this:
    Error: Table 'admin' from database 'ftpusers' doesn't exist.
    MySql error : Table 'ftpusers.admin' doesn't exist

You can go to phpmyadmin (http://198.211.33.14/phpmyadmin), run these scripts

    DROP USER 'ftp'@'localhost';
    DROP database ftpusers;

Then

wget http://rg4.net/p/vps/lnmp/ext/fix_pureftpd_mysql55.sh
./fix_pureftpd_mysql55.sh

If this still can not work for you, you can choose to not integrate pureftpd with mysql, and manage your ftp accounts with commands like these:
/usr/local/pureftpd/bin/pure-pw useradd ftp -u ftp -d /home/wwwroot
/usr/local/pureftpd/bin/pure-pw mkdb
You can visit http://bbs.rosoo.net/blog-3-8984.html for more details about this configuration for pureftpd.

4) Install eAccelerator
./eaccelerator.sh

5) Install ionCube
./ionCube.sh

6) Install imageMagick
./imageMagick.sh

7) Install memcached
./memcached.sh


4. LNMP direcotries
————————–

nginx: /usr/local/nginx
mysql: /usr/local/mysql
php: /usr/local/php
www root: /home/wwwroot/
Nginx log: /home/wwwlogs/

5. LNMP configuration files
————————–

Nginx: /usr/local/nginx/conf/nginx.conf
MySQL: /etc/my.cnf
PHP: /usr/local/php/etc/php.ini
PureFtpd: /usr/local/pureftpd/pure-ftpd.conf
PureFtpd MySQL: /usr/local/pureftpd/pureftpd-mysql.conf

6. Server status
————————–

LNMP status: /root/lnmp {start|stop|reload|restart|kill|status}
Nginx status: /etc/init.d/nginx {start|stop|reload|restart}
PHP-FPM status: /etc/init.d/php-fpm {start|stop|quit|restart|reload|logrotate}
PureFTPd status: /etc/init.d/pureftpd {start|stop|restart|kill|status}
MySQL status: /etc/init.d/mysql {start|stop|restart|reload|force-reload|status}

7. GUI
————————–

phpinfo: http://YOUR-DOMAIN-NAME-OR-IP/phpinfo.php
phpMyAdmin: http://YOUR-DOMAIN-NAME-OR-IP/phpmyadmin/
sniffer: http://YOUR-DOMAIN-NAME-OR-IP/p.php
PureFTP management: http://YOUR-DOMAIN-NAME-OR-IP/ftp/

 

Getting started with nginx rtmp

Download, build and install

CD to build directory (home)

cd /usr/build

Download & unpack latest nginx-rtmp (you can also use http)

git clone git://github.com/arut/nginx-rtmp-module.git

Download & unpack nginx (you can also use svn)

wget http://nginx.org/download/nginx-1.2.4.tar.gz
tar xzf nginx-1.2.4.tar.gz
cd nginx-1.2.4

Build nginx with nginx-rtmp

./configure --add-module=/usr/build/nginx-rtmp-module
make
make install

For nginx 1.3.4-1.5.0 more options are needed

./configure --add-module=/usr/build/nginx-rtmp-module --with-http_ssl_module
make
make install

Set up live streaming

To set up RTMP support you need to add rtmp{} section to nginx.conf (can be found in PREFIX/conf/nginx.conf). Stock nginx.conf contains only http{} section.

Use this nginx.conf instead of stock config:

#user  nobody;
worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8080;
        server_name  localhost;

        # sample handlers
        #location /on_play {
        #    if ($arg_pageUrl ~* localhost) {
        #        return 201;
        #    }
        #    return 202;
        #}
        #location /on_publish {
        #    return 201;
        #}

        #location /vod {
        #    alias /var/myvideos;
        #}

        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /usr/build/nginx-rtmp-module;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application myapp {
            live on;

            # sample play/publish handlers
            #on_play http://localhost:8080/on_play;
            #on_publish http://localhost:8080/on_publish;

            # sample recorder
            #recorder rec1 {
            #    record all;
            #    record_interval 30s;
            #    record_path /tmp;
            #    record_unique on;
            #}

            # sample HLS
            #hls on;
            #hls_path /tmp/hls;
            #hls_sync 100ms;
        }

        # Video on demand
        #application vod {
        #    play /var/Videos;
        #}

        # Video on demand over HTTP
        #application vod_http {
        #    play http://localhost:8080/vod/;
        #}
    }
}

Statistics

Navigate your browser to http://localhost:8080/stat to see current streaming statistics, connected clients, bandwidth etc.

Publishing with ffmpeg

The easiest way to publish live video stream is using ffmpeg (or avconv). It’s already installed on most systems and easy to install on others.

RTMP supports only a limited number of codecs. The most popular RTMP video codecs are H264, Sorenson-H263 (aka flv) and audio codecs AAC, MP3, Nellymoser, Speex. If your video is encoded with these codecs (the most common pair is H264/AAC) then you do not need any conversion. Otherwise you need to convert video to one of supported codecs.

We’ll stream test file /var/videos/test.mp4 to server with ffmpeg.

Streaming without conversion (given test.mp4 codecs are compatible with RTMP)

ffmpeg -re -i /var/Videos/test.mp4 -c copy -f flv rtmp://localhost/myapp/mystream

Streaming and encoding audio (AAC) and video (H264), need libx264 and libfaac

ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libfaac -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Streaming and encoding audio (MP3) and video (H264), need libx264 abd libmp3lame

ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Streaming and encoding audio (Nellymoser) and video (Sorenson H263)

ffmpeg -re -i /var/Videos/test.mp4 -c:v flv -c:a nellymoser -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Publishing video from webcam

ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -an -f flv rtmp://localhost/myapp/mystream

Playing with ffplay

ffplay rtmp://localhost/myapp/mystream

Publishing and playing with flash

See test/rtmp-publisher directory for test flash applets and html.

正式版SVN服务器配置清单

正式版SVN服务器配置清单,具体的操作指令,请看: http://rg4.net/archives/665.html

非常抱歉,我还不会用这个SyntaxHighlighter,结果这个格式全乱套了。所以若出现问题,请直接下载这个包:http://rg4.net/p/vps/svn.7z

Continue reading “正式版SVN服务器配置清单”

正式版SVN服务器安装记录

之前已经发过一次测试版服务器的安装记录,为我在本机安装的虚拟机的操作过程,之后为了应对正式版的服务器,我重新装了一次虚拟机,并且重新将每一步的操作记录明细。一者,为了方便我日后翻查记录,二者,接手工作的人,也可以有一个基本记录可参照。

文本内容主要包含执行过的命令,项目的配置文件在此http://rg4.net/archives/667.html,增加了sshd和dropbox的配置,系统为CentOS 6.2。

Continue reading “正式版SVN服务器安装记录”

Nginx开发从入门到精通

缘起

nginx由于出色的性能,在世界范围内受到了越来越多人的关注,在淘宝内部它更是被广泛的使用,众多的开发以及运维同学都迫切的想要 了解nginx模块的开发以及它的内部原理,但是国内却没有一本关于这方面的书,源于此我们决定自己来写一本。本书的作者为淘宝核心系统服务器平台组的成 员,本书写作的思路是从模块开发逐渐过渡到nginx原理剖析。书籍的内容会定期在这里更新,欢迎大家提出宝贵意见,不管是本书的内容问题,还是字词错 误,都欢迎大家提交issue(章节标题的左侧有评注按钮),我们会及时的跟进。

taobao / nginx-book

Watch587 Fork214

master分支代码最近更新:2013-04-14

下载zip

版权申明

本书的著作权归作者淘宝核心系统服务器平台组成员所有。你可以:

  • 下载、保存以及打印本书
  • 网络链接、转载本书的部分或者全部内容,但是必须在明显处提供读者访问本书发布网站的链接
  • 在你的程序中任意使用本书所附的程序代码,但是由本书的程序所引起的任何问题,作者不承担任何责任

你不可以:

  • 以任何形式出售本书的电子版或者打印版
  • 擅自印刷、出版本书
  • 以纸媒出版为目的,改写、改编以及摘抄本书的内容