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

本文介绍如何使用nginx-vod-module快速搭建HLS、Dash流媒体服务及生成缩略图,通过编译源码或Docker容器方式安装,并提供示例配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

备注:
以前写过使用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/

 
 
 
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值