GithubHelp home page GithubHelp logo

qingtao / plugin-hls Goto Github PK

View Code? Open in Web Editor NEW

This project forked from monibuca/plugin-hls

0.0 0.0 0.0 2.09 MB

HLS协议的实现,提供HLS协议拉流,和HLS的写磁盘功能

License: MIT License

Go 100.00%

plugin-hls's Introduction

HLS插件

  • 该插件可用来拉取网络上的m3u8文件并解析后转换成其他协议
  • 可以直接访问http://localhost:8080/hls/live/user1.m3u8 进行播放,其中8080端口是全局HTTP配置,live/user1是streamPath,需要根据实际情况修改

插件地址

https://github.com/Monibuca/plugin-hls

插件引入

import (
    _ "m7s.live/plugin/hls/v4"
)

API

参数是可变的,下面的参数live/hls是作为例子,不是固定的

  • /hls/api/list 列出所有HLS流,是一个SSE,可以持续接受到列表数据,加上?json=1 可以返回json数据。
  • /hls/api/save?streamPath=live/hls 保存指定的流(例如live/hls)为HLS文件(m3u8和ts)当这个请求关闭时就结束保存(该API仅作用于远程拉流)
  • /hls/api/pull?streamPath=live/hls&target=http://localhost/abc.m3u8 将目标HLS流拉过来作为媒体源在monibuca内以live/hls流的形式存在

配置

  • 配置信息按照需要添加到配置文件中,无需复制全部默认配置信息
  • publish 和 subscribe 配置会覆盖全局配置
hls:
    publish: # 格式参考全局配置
    subscribe: # 格式参考全局配置
    pull: # 格式 https://m7s.live/guide/config.html#%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE
    fragment: 10s # TS分片长度
    window: 2 # 实时流m3u8文件包含的TS文件数
    filter: "" # 正则表达式,用来过滤发布的流,只有匹配到的流才会写入
    path: "" # 远端拉流如果需要保存的话,存放的目录
    defaultts: "" # 默认切片用于无流时片头播放,如果留空则使用系统内置
    defaulttsduration: 3.88s # 默认切片的长度
    relaymode: 0 # 转发模式,0:转协议+不转发,1:不转协议+转发,2:转协议+转发

转发模式

转发模式仅仅对从远端拉流的hls起作用。

relaymode 可以配置不同的转发模式

其中,转协议意味着hls可以拉流可以转换成其他协议格式,即需要对hls的数据进行解析, 转发意味着hls中的ts文件缓存在服务器,可以在从服务器拉流时直接读取ts文件。

例如,如果希望只做hls的纯转发,减少cpu消耗,可以配置

hls:
  relaymode: 1

plugin-hls's People

Contributors

langhuihui avatar dependabot[bot] avatar qingtao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.