Html Http 媒体流服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20369046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:20:26  来源:igfitidea点击:

Http Media Streaming Server

htmlvideo-streamingaudio-streaminghttp-live-streaminghttp-streaming

提问by DIVAKAR SRINIVASAN

I have developed video streaming application with RED5 media server(RTMP). Instead of RTMP need to stream live video through HTTP.

我已经使用 RED5 媒体服务器 (RTMP) 开发了视频流应用程序。而不是 RTMP 需要通过 HTTP 流式传输实时视频。

Any open source HTTP media server??

任何开源 HTTP 媒体服务器?

Is any open source server which supports both RTMP and HTTP ?

是否有同时支持 RTMP 和 HTTP 的开源服务器?

Thanks in advance.

提前致谢。

回答by Fernando Silva

Primarily, HTTP and RTMP are different protocols. You won't serve RTMP inside the HTTP. (Although you can do this for a tunneling solution).

首先,HTTP 和 RTMP 是不同的协议。您不会在 HTTP 内提供 RTMP。(尽管您可以为隧道解决方案执行此操作)。

Exist several ways to do HTTP Streaming. Such as HLS, DASH, Smooth and Progresive Download. If you need serve streaming to iOS (iPad, iPhone, Apple TV) you will need to use HLS.

存在多种方式来进行 HTTP Streaming。例如 HLS、DASH、平滑和渐进式下载。如果您需要向 iOS(iPad、iPhone、Apple TV)提供流媒体服务,则需要使用 HLS。

As well as arcyqwerty said. Any HTTP server is able to serve HTTP Streaming. But you will need to prepare your media files and the manifest files before serving.

正如arcyqwerty所说。任何 HTTP 服务器都能够提供 HTTP 流。但是您需要在服务之前准备好媒体文件和清单文件。

Here are some links very important for read about HLS (HTTP Live Streaming):

以下是一些对于阅读 HLS(HTTP 实时流媒体)非常重要的链接:

What about open source servers. I know these:

开源服务器呢。我知道这些:

Or you can do like me and use GStreamer for segmenting and make manifest. And finaly I use the Nginx only to serve them.

或者你可以像我一样使用 GStreamer 进行分割和制作清单。最后我只使用 Nginx 来为他们服务。

I hope I helped you a little bit.

我希望我对你有所帮助。

回答by arcyqwerty

Any HTTP server that can serve files (apache, nginx, IIS, etc) can "stream" media over HTTP. So if you want, you can keep RED5 for RTMP and set up an HTTP server to serve the same files.

任何可以提供文件服务的 HTTP 服务器(apache、nginx、IIS 等)都可以通过 HTTP“流式传输”媒体。因此,如果您愿意,您可以为 RTMP 保留 RED5,并设置一个 HTTP 服务器来提供相同的文件。

You may want to look into Media streaming basics - HTTP vs RTMPfor info about the protocols

您可能需要查看媒体流基础知识 - HTTP 与 RTMP以获取有关协议的信息

Adding the nginx-rtmp module to nginx might be what you're looking for if you need a single-product solution

如果您需要单一产品的解决方案,将 nginx-rtmp 模块添加到 nginx 可能就是您所需要的

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

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

回答by Zsolt Boszormenyi

I use this and it works properly. (Ubuntu 12.04 TLS server)

我使用它并且它工作正常。(Ubuntu 12.04 TLS 服务器)

Step by step:

一步步:

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 Config:(/usr/local/nginx/conf/nginx.conf)

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;
    #}
    }
}

Save the config file and:

保存配置文件并:

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

Next... Create two directories:

下一步... 创建两个目录:

mkdir /var/flvs
mkdir /var/mp4s

You need copy an mp4 file to the mp4s directory. For example: sample.mp4

您需要将 mp4 文件复制到 mp4s 目录。例如:sample.mp4

Finaly

最后

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

Try:

尝试:

rtmp://your_server_ip/vod2/sample.mp4

(suggest: you use the VLC media player)

(建议:您使用 VLC 媒体播放器)

or html code

或 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>