簡體   English   中英

Http Media Streaming Server

[英]Http Media Streaming Server

我用RED5媒體服務器(RTMP)開發了視頻流應用程序。 而不是RTMP需要通過HTTP流式傳輸實時視頻。

任何開源HTTP媒體服務器??

是否有支持RTMP和HTTP的開源服務器?

提前致謝。

首先,HTTP和RTMP是不同的協議。 您不會在HTTP中提供RTMP。 (雖然您可以為隧道解決方案執行此操作)。

存在幾種做HTTP流的方法。 如HLS,DASH,Smooth和Progresive下載。 如果您需要向iOS(iPad,iPhone,Apple TV)投放流媒體,則需要使用HLS。

以及arcyqwerty說。 任何HTTP服務器都能夠提供HTTP Streaming。 但您需要在投放前准備好媒體文件和清單文件。

以下是一些非常重要的關於HLS(HTTP Live Streaming)的鏈接:

那么開源服務器呢? 我知道這些:

或者你可以像我一樣使用GStreamer進行分段並制作清單。 最后我只使用Nginx為他們服務。

我希望我幫助你一點點。

任何可以提供文件的HTTP服務器(apache,nginx,IIS等)都可以通過HTTP“流式傳輸”媒體。 因此,如果您願意,可以將RED5保留為RTMP並設置HTTP服務器以提供相同的文件。

您可能需要查看媒體流基礎知識 - HTTP與RTMP有關協議的信息

如果您需要單一產品解決方案,那么將nginx-rtmp模塊添加到nginx可能就是您所需要的

https://github.com/arut/nginx-rtmp-module

我用它,它工作正常。 (Ubuntu 12.04 TLS服務器)

一步步:

sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
wget http://nginx.org/download/nginx-1.6.0.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar -zxvf nginx-1.6.0.tar.gz
unzip master.zip
cd nginx-1.6.0

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master --with-http_flv_module --with-http_mp4_module
make
sudo make install

sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx

NGINX配置: (/ usr / local / nginx / conf / nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

rtmp {
    server {
    listen 1935;
    chunk_size 4000;
    # video on demand for flv files
    application vod {
        play /var/flvs;
    }

    # video on demand for mp4 files
        application vod2 {
        play /var/mp4s;
        }
    }
}

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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       80;
        server_name  192.168.52.16;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        # This URL provides RTMP statistics in XML
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root /var/www/;
        }

    location /hls {
        # Serve HLS fragments
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }
        alias /tmp/app;
        expires -1;
    }

#   location /hds {
#       f4f;    # Use the HDS handler to manage requests
#           # serve content from the following location
#       alias /var/www/video;
#   }

    location /video {
        mp4;
        flv;
        mp4_buffer_size     4M;
        mp4_max_buffer_size 10M;
    }

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

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
    }
}

保存配置文件並:

sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx

下一步...創建兩個目錄:

mkdir /var/flvs
mkdir /var/mp4s

您需要將mp4文件復制到mp4s目錄。 例如:sample.mp4

Finaly

sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx

嘗試:

rtmp://your_server_ip/vod2/sample.mp4

(建議:你使用VLC媒體播放器)

或者HTML代碼

<html>
<head>
    <title>RTMP Video</title>
    <!-- flowplayer javascript component -->
    <script src="http://releases.flowplayer.org/js/flowplayer-3.2.12.min.js"></script>
</head>

<body>
<div id="player" style="width:644px;height:480;margin:0 auto;text-align:center">
    <img src="images/background.jpg" height="480" width="644" /></div>
<script>

$f("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.16.swf", {
    clip: {
        url: 'sample.mp4',
        scaling: 'fit',
        provider: 'hddn'
    },

    plugins: {
        hddn: {
            url: "swf/flowplayer.rtmp-3.2.13.swf",

            // netConnectionUrl defines where the streams are found
            netConnectionUrl: 'rtmp://your_server_ip:1935/vod2/'

        }
    },
    canvas: {
        backgroundGradient: 'none'
    }
});
</script>
</body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM