码迷,mamicode.com
首页 > 其他好文 > 详细

使用nginx-vod-module hls &&dash &&Thumbnail 处理

时间:2018-06-15 12:59:24      阅读:986      评论:0      收藏:0      [点我收藏+]

标签:dash   IV   fragment   math   mod   options   method   alt   m3u8   

备注:
以前写过使用ffmpeg 转换为m3u8进行hls 视频处理,实际上有一个开源的很强大的工具,我们基本不用什么代码就可以实现hls、
dash、Thumbnail ,很强大

安装

  • 使用源码编译

参考 https://github.com/kaltura/nginx-vod-module

./configure --add-module=/path/to/nginx-vod-module
make
make install
  • 使用容器

    已经有别人做好的镜像了

docker pull nytimes/nginx-vod-module

基本使用

我直接clone 别人的参考代码

docker run -p 3030:80 -v $PWD/videos:/opt/static/videos -v $PWD/nginx.conf:/usr/local/nginx/conf/nginx.conf nytimes/nginx-vod-module

访问

HLS: http://localhost:3030/hls/devito,360p.mp4,480p.mp4,720p.mp4,.en_US.vtt,.urlset/master.m3u8
Dash: http://localhost:3030/dash/devito,360p.mp4,480p.mp4,720p.mp4,.en_US.vtt,.urlset/manifest.mpd
Thumbnail: http://localhost:3030/thumb/devito360p.mp4/thumb-1000.jpg

配置说明

nginx config

   hls  dash   thumb
        location /hls/ {
            vod hls;
            alias /opt/static/videos/;
            add_header Access-Control-Allow-Headers ‘*‘;
            add_header Access-Control-Allow-Origin ‘*‘;
            add_header Access-Control-Allow-Methods ‘GET, HEAD, OPTIONS‘;
        }

        location /thumb/ {
            vod thumb;
            alias /opt/static/videos/;
            add_header Access-Control-Allow-Headers ‘*‘;
            add_header Access-Control-Allow-Origin ‘*‘;
            add_header Access-Control-Allow-Methods ‘GET, HEAD, OPTIONS‘;
        }

        location /dash/ {
            vod dash;
            alias /opt/static/videos/;
            add_header Access-Control-Allow-Headers ‘*‘;
            add_header Access-Control-Allow-Origin ‘*‘;
            add_header Access-Control-Allow-Methods ‘GET, HEAD, OPTIONS‘;
        }

     核心vod 配置

    vod_mode local;
    vod_metadata_cache metadata_cache 16m;
    vod_response_cache response_cache 2048m;
    vod_last_modified_types *;
    vod_segment_duration 9000;
    vod_align_segments_to_key_frames on;
    vod_dash_fragment_file_name_prefix "segment";
    vod_hls_segment_file_name_prefix "segment";
    vod_manifest_segment_durations_mode accurate;
    open_file_cache max=1000 inactive=5m;
    open_file_cache_valid 2m;
    open_file_cache_min_uses 1;
    open_file_cache_errors on;

参考资料

https://github.com/NYTimes/nginx-vod-module-docker/tree/master/examples
https://github.com/kaltura/nginx-vod-module
https://hub.docker.com/r/nytimes/nginx-vod-module/

使用nginx-vod-module hls &&dash &&Thumbnail 处理

标签:dash   IV   fragment   math   mod   options   method   alt   m3u8   

原文地址:https://www.cnblogs.com/rongfengliang/p/9186441.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!