m3u8

package
v0.0.0-...-64f46e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(cryptByte []byte, key []byte, iv []byte) (decryptBytes []byte, err error)

AesDecrypt aes解密

func DownloadTs

func DownloadTs(ts Ts) (err error)

DownloadTs 下载单个ts

func PKCS7UnPadding

func PKCS7UnPadding(data []byte) []byte

PKCS7UnPadding 去掉尾部多余的数据

Types

type Key

type Key struct {
	// 加密方法,如果是NONE标识不需要解密,AES-128使用aes128解密
	Method string
	// 秘钥地址
	Uri string
	// key的值
	KeyValue []byte
	// 加密向量
	IV string
}

Key 加密信息

type M3U8

type M3U8 struct {
	IsM3U8 bool
	GNum   int
	// 上级m3u8的url
	ParentURL string
	// url
	Url string
	// 主域名
	BaseUrl string
	// m3u8版本
	Version int
	// 最大媒体段时长(秒)
	TargetDuration int
	// 首个list的序号
	MediaSequence int
	// ts列表
	//TsLists []string
	TsLists []Ts
	// 是否需要解密
	HasKey bool
	// 加密key
	Keys []Key
	// 播放列表,有带宽,分辨率等信息,用户根据带宽自行选择播放文件
	StreamInfos []StreamInfo
	// 保存的内容
	OutputName string
	// 保存目录
	OutputPath string
}

M3U8 参数: https://blog.csdn.net/weixin_41635750/article/details/108066684

func NewM3U8

func NewM3U8(url string) (m3u8 *M3U8, err error)

NewM3U8 生成实例

func (*M3U8) CleanTsLists

func (m *M3U8) CleanTsLists() (err error)

CleanTsLists 清理ts文件

func (*M3U8) DownloadTsList

func (m *M3U8) DownloadTsList() (err error)

DownloadTsList 下载ts列表

func (*M3U8) GetMaxBandwidthInfo

func (m *M3U8) GetMaxBandwidthInfo() (maxInfo *StreamInfo)

GetMaxBandwidthInfo 获取最大带宽的播放列表信息

func (*M3U8) MergeTsList

func (m *M3U8) MergeTsList() (err error)

MergeTsList 合并ts文件

func (*M3U8) ParseUrl

func (m *M3U8) ParseUrl(m3u8Url string) (err error)

ParseUrl 解析m3u8 地址

func (*M3U8) Run

func (m *M3U8) Run() (err error)

Run 启动下载解析任务

func (*M3U8) SetGNum

func (m *M3U8) SetGNum(gNum int)

func (*M3U8) SetOutputName

func (m *M3U8) SetOutputName(name string)

SetOutputName 甚至输出文件名

func (*M3U8) SetOutputPath

func (m *M3U8) SetOutputPath(name string)

SetOutputPath 设置输出路劲

type StreamInfo

type StreamInfo struct {
	// 带宽
	BandWidth int
	// 标识,一个playlist中可能有多个相同的标识
	ProgramId int
	// 文件格式列表
	Codecs string
	// 分辨率
	Resolution string
	Audio      string
	Video      string
	// 播放列表的m3u8信息
	SubM3u8 M3U8
}

StreamInfo 多带宽信息

type Ts

type Ts struct {
	Index int    // 文件顺序
	Url   string // 文件的url
	Dist  string // 文件的下载保存地址
	Key   Key    // 如果文件被加密,加密的信息
}

Ts ts文件

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL