nginx rtmp-module にてオンデマンド配信を実現

映像配信

本ページは広告が含まれています。気になる広告をクリック頂けますと、サーバ運営費になります(^^

すでにあるflvや、mp4 をrtmpで映像配信する。

leaseweb
Postings from Leaseweb engineers about tech.

https://github.com/arut/nginx-rtmp-module/wiki/Directives
Video on demand

mp4または、flvファイルを準備し、
/usr/local/nginx/mp4s;
/usr/local/nginx/flvs;

に配置しておく

今回のテストでは、
https://www.leaseweb.com/labs/2013/11/streaming-video-demand-nginx-rtmp-module/

から、bbb.mp4をダウンロードし、/usr/local/nginx/mp4s に配置した。

 

vi /etc/nginx/nginx.conf
worker_processes  1;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;

        # video on demand for flv files
        application vod {
            live off;
            play /usr/local/nginx/flvs;
        }

        # video on demand for mp4 files
        application vod2 {
            live off;
            play /usr/local/nginx/mp4s;
        }
    }
}

# HTTP can be used for accessing RTMP stats
http {
    access_log /usr/local/nginx/logs/access-streaming.log;
    error_log /usr/local/nginx/logs/error-streaming.log;

    server {
        # in case we have another web server on port 80
        listen      80;

        location / {
            root   html;
            index  index.html index.htm;
        }

    }
}

 

※live off; を入れる事で、rtmp://で直接ストリームが送られてくることを防ぐことができます。

VLC Plyerで再生できるかを確認

ネットワークストリームを開く
rtmp://IPアドレス/vod2/bbb.mp4

webプレーヤーで再生できるか確認

<html>
<head>
   <link href="http://vjs.zencdn.net/5.11.6/video-js.css" rel="stylesheet">
   <script src="http://vjs.zencdn.net/5.11.6/video.js"></script>
</head>
<body>
   <video id="rtmp_test" class="video-js vjs-default-skin" autoplay="autoplay" controls="controls" width="800" height="450" data-setup="{}">
   <source src="rtmp:// IPアドレス/vod2/bbb.mp4" type="rtmp/mp4" />
</video>
</body>
</html>

 

 

タイトルとURLをコピーしました