[![Build Status](https://travis-ci.org/quangngotan95/go-m3u8.svg?branch=master)](https://travis-ci.org/quangngotan95/go-m3u8)
[![codecov](https://codecov.io/gh/quangngotan95/go-m3u8/branch/master/graph/badge.svg)](https://codecov.io/gh/quangngotan95/go-m3u8)
[![Go Report Card](https://goreportcard.com/badge/github.com/quangngotan95/go-m3u8)](https://goreportcard.com/report/github.com/quangngotan95/go-m3u8)
[![GoDoc](https://godoc.org/github.com/quangngotan95/go-m3u8/m3u8?status.svg)](https://godoc.org/github.com/quangngotan95/go-m3u8/m3u8)
# go-m3u8
Golang package for m3u8 (ported m3u8 gem https://github.com/sethdeckard/m3u8)
`go-m3u8` provides easy generation and parsing of m3u8 playlists defined in the HTTP Live Streaming (HLS) Internet Draft published by Apple.
* The library completely implements version 20 of the HLS Internet Draft.
* Provides parsing of an m3u8 playlist into an object model from any File, io.Reader or string.
* Provides ability to write playlist to a string via String()
* Distinction between a master and media playlist is handled automatically (single Playlist class).
* Optionally, the library can automatically generate the audio/video codecs string used in the CODEC attribute based on specified H.264, AAC, or MP3 options (such as Profile/Level).
## Installation
`go get github.com/quangngotan95/go-m3u8`
## Usage (creating playlists)
Create a master playlist and child playlists for adaptive bitrate streaming:
```go
import (
"github.com/quangngotan95/go-m3u8/m3u8"
"github.com/AlekSi/pointer"
)
playlist := m3u8.NewPlaylist()
```
Create a new playlist item:
```go
item := &m3u8.PlaylistItem{
Width: pointer.ToInt(1920),
Height: pointer.ToInt(1080),
Profile: pointer.ToString("high"),
Level: pointer.ToString("4.1"),
AudioCodec: pointer.ToString("aac-lc"),
Bandwidth: 540,
URI: "test.url",
}
playlist.AppendItem(item)
```
Add alternate audio, camera angles, closed captions and subtitles by creating MediaItem instances and adding them to the Playlist:
```go
item := &m3u8.MediaItem{
Type: "AUDIO",
GroupID: "audio-lo",
Name: "Francais",
Language: pointer.ToString("fre"),
AssocLanguage: pointer.ToString("spoken"),
AutoSelect: pointer.ToBool(true),
Default: pointer.ToBool(false),
Forced: pointer.ToBool(true),
URI: pointer.ToString("frelo/prog_index.m3u8"),
}
playlist.AppendItem(item)
```
Create a standard playlist and add MPEG-TS segments via SegmentItem. You can also specify options for this type of playlist, however these options are ignored if playlist becomes a master playlist (anything but segments added):
```go
playlist := &m3u8.Playlist{
Target: 12,
Sequence: 1,
Version: pointer.ToInt(1),
Cache: pointer.ToBool(false),
Items: []m3u8.Item{
&m3u8.SegmentItem{
Duration: 11,
Segment: "test.ts",
},
},
}
```
You can also access the playlist as a string:
```go
var str string
str = playlist.String()
...
fmt.Print(playlist)
```
Alternatively you can set codecs rather than having it generated automatically:
```go
item := &m3u8.PlaylistItem{
Width: pointer.ToInt(1920),
Height: pointer.ToInt(1080),
Codecs: pointer.ToString("avc1.66.30,mp4a.40.2"),
Bandwidth: 540,
URI: "test.url",
}
```
## Usage (parsing playlists)
Parse from file
```go
playlist, err := m3u8.ReadFile("path/to/file")
```
Read from string
```go
playlist, err := m3u8.ReadString(string)
```
Read from generic `io.Reader`
```go
playlist, err := m3u8.Read(reader)
```
Access items in playlist:
```go
gore> playlist.Items[0]
(*m3u8.SessionKeyItem)#EXT-X-SESSION-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=52"
gore> playlist.Items[1]
(*m3u8.PlaybackStart)#EXT-X-START:TIME-OFFSET=20.2
```
## Misc
Codecs:
* Values for audio_codec (codec name): aac-lc, he-aac, mp3
* Values for profile (H.264 Profile): baseline, main, high.
* Values for level (H.264 Level): 3.0, 3.1, 4.0, 4.1.
Not all Levels and Profiles can be combined and validation is not currently implemented, consult H.264 documentation for further details.
## Contributing
1. Fork it https://github.com/quangngotan95/go-m3u8/fork
2. Create your feature branch `git checkout -b my-new-feature`
3. Run tests `go test ./test/...`, make sure they all pass and new features are covered
4. Commit your changes `git commit -am "Add new features"`
5. Push to the branch `git push origin my-new-feature`
6. Create a new Pull Request
## License
MIT License - See [LICENSE](https://github.com/quangngotan95/go-m3u8/blob/master/LICENSE) for details
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
go-m3u8 用于m3u8的Golang软件包(已移植的m3u8 gem ) go-m3u8可以轻松生成和解析Apple发行的HTTP Live Streaming(HLS)Internet草案中定义的m3u8播放列表。 该库完全实现了HLS Internet Draft版本20。 提供从任何File,io.Reader或字符串将m3u8播放列表解析为对象模型的功能。 提供通过String()将播放列表写入字符串的功能 母版播放列表与媒体播放列表之间的区别是自动处理的(单个播放列表类)。 (可选)该库可以根据指定的H.264,AAC或MP3选项(例如配置文件/级别)自动生成在C
资源详情
资源评论
资源推荐
收起资源包目录
go-m3u8-master.zip (82个子文件)
go-m3u8-master
.gitignore 6B
README.md 5KB
test
mapItem_test.go 750B
byteRange_test.go 973B
playlist_test.go 5KB
sessionDataItem_test.go 864B
playlistItem_test.go 7KB
keyItem_test.go 679B
fixtures
variantAudio.m3u8 1KB
livePlaylist.m3u8 5KB
variantAngles.m3u8 1KB
dateRangeScte35.m3u8 561B
encrypted.m3u8 459B
iframes.m3u8 199B
playlistWithComments.m3u8 6KB
sessionData.m3u8 254B
mapPlaylist.m3u8 195B
masterIframes.m3u8 440B
timestampPlaylist.m3u8 656B
master.m3u8 825B
playlist.m3u8 5KB
common.go 977B
playbackStart_test.go 635B
sessionKeyItem_test.go 710B
common_test.go 414B
mediaItem_test.go 1KB
segmentItem_test.go 1KB
discontinuityItem_test.go 290B
dateRangeItem_test.go 2KB
writer_test.go 5KB
reader_test.go 8KB
timeItem_test.go 650B
Gopkg.toml 803B
LICENSE 1KB
vendor
github.com
stretchr
testify
LICENSE 1KB
assert
forward_assertions.go 388B
doc.go 1KB
http_assertions.go 5KB
assertion_format.go.tmpl 184B
assertion_forward.go.tmpl 185B
assertions.go 38KB
assertion_format.go 19KB
assertion_forward.go 34KB
errors.go 326B
pmezard
go-difflib
difflib
difflib.go 22KB
LICENSE 1KB
AlekSi
pointer
pointer.go 1KB
README.md 1KB
LICENSE 1KB
.travis.yml 78B
davecgh
go-spew
LICENSE 766B
spew
bypasssafe.go 2KB
doc.go 8KB
common.go 10KB
spew.go 6KB
bypass.go 5KB
dump.go 13KB
config.go 13KB
format.go 11KB
m3u8
mapItem.go 739B
tags.go 3KB
reader.go 6KB
dateRangeItem.go 3KB
sessionKeyItem.go 523B
common.go 2KB
playbackStart.go 884B
segmentItem.go 1KB
sessionDataItem.go 1KB
resolution.go 767B
encryptable.go 1KB
byteRange.go 802B
playlistItem.go 5KB
mediaItem.go 3KB
writer.go 2KB
keyItem.go 450B
timeItem.go 1KB
playlist.go 3KB
codecs.go 1KB
discontinuityItem.go 450B
errors.go 1KB
Gopkg.lock 1KB
.travis.yml 225B
共 82 条
- 1
PLEASEJUM爬
- 粉丝: 17
- 资源: 4576
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 09MnNiDR钢制低温压力容器焊接工艺的确定.pdf
- 09MnNiDR钢制球罐用W707DRQ焊条焊接性能 - .pdf
- 09MnNiDR低温压力容器钢板的试验及焊接检验.pdf
- 9Ni钢低温储罐焊接工艺研究.pdf
- 9Cr与CrMoV异种焊接接头疲劳裂纹扩展门槛值研究.pdf
- 10CrMo910耐热钢的焊接工艺.pdf
- 10CrMo910炉管焊接.pdf
- 10Ni3MoVD锻件焊接裂纹敏感性试验研究.pdf
- 10t电动单梁桥式起重机主梁焊接变形的控制 - .pdf
- 10CrNi3MoV钢双面双弧焊接头组织与性能研究 - .pdf
- 10焊接工字形钢轴压构件截面设计的直接算法.pdf
- 10吨级叉车驱动桥体焊接工艺设计 - .pdf
- 10T级后桥焊接工艺分析.pdf
- 10万m 3原油储罐底板现场焊接及变形控制.pdf
- 10万m3大型原油储罐底板焊接质量控制分析.pdf
- 10万m3原油储罐典型焊接质量缺陷分析与处理.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0