简体   繁体   中英

Mpeg-dash support in nginx

I searched enough but couldn't sort out how to configure mpeg-dash vod in nginx using nginx_vod_module .

Configuration inside http server block for enabling dash is

  location /voddash {
        vod dash;
        vod_mode local;
        root /usr/share/nginx/html;
        gzip on;
        gzip_types application/dash+xml mpd;
        add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer";
        add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range";
        add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
        add_header Access-Control-Allow-Origin "*";
        expires 100d;
        add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
    }

Request url is http://localhost/voddash/Input.mp4/manifest.mpd . I have placed only Input.mp4 in dash location. How can i stream dash content .Also is there anything like streaming of precreated manifest and chunks in nginx for mpeg dash?

For VoD its probably much simpler and effective to encode the content by your own to MPEG-DASH/HLS with ffmpeg as shown for example here , or using services such as bitcodin or zencoder.

Using this solution you can encode the content to multiple different resolutions and bitrates which will give your clients a better streaming experience. For HTTP based streaming like MPEG-DASH and HLS there is no logic needed on the server side. You just need to place the segments and the index (MPD or M3U8) at an ordinary HTTP server such as nginx or also others and it works.

I have the same configuration on my server and use the following html + js code to play the dynamically generated manifest.mpd file:

<!doctype html>
<html>
    <head>
        <title>Dash.js Rocks</title>
        <style>
            video {
                width: 640px;
                height: 360px;
            }
        </style>
    </head>
    <body>
        <div>
            <video id="videoPlayer" controls></video>
        </div>
        <script src="http://dashif.org/reference/players/javascript/nightly/dash.js/dist/dash.all.min.js"></script>
        <script>
            (function(){
                var url = "http://localhost/voddash/Input.mp4/manifest.mpd";
                var player = dashjs.MediaPlayer().create();
                player.initialize(document.querySelector("#videoPlayer"), url, true);
            })();
        </script>
    </body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM