{"id":13906262,"url":"https://github.com/etherlabsio/go-m3u8","last_synced_at":"2025-07-18T04:30:38.872Z","repository":{"id":57490205,"uuid":"177246460","full_name":"etherlabsio/go-m3u8","owner":"etherlabsio","description":"Parse and generate m3u8 playlists for Apple HTTP Live Streaming (HLS) in Golang (ported from gem https://github.com/sethdeckard/m3u8)","archived":false,"fork":false,"pushed_at":"2022-09-20T14:11:49.000Z","size":104,"stargazers_count":29,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-07T23:47:26.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tools.ietf.org/html/rfc8216","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etherlabsio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-23T05:04:52.000Z","updated_at":"2024-07-27T06:31:04.000Z","dependencies_parsed_at":"2022-09-02T12:01:34.663Z","dependency_job_id":null,"html_url":"https://github.com/etherlabsio/go-m3u8","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fgo-m3u8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fgo-m3u8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fgo-m3u8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fgo-m3u8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etherlabsio","download_url":"https://codeload.github.com/etherlabsio/go-m3u8/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226344589,"owners_count":17610172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T23:01:32.201Z","updated_at":"2024-11-25T14:31:12.797Z","avatar_url":"https://github.com/etherlabsio.png","language":"Go","funding_links":[],"categories":["Video","HarmonyOS","视频"],"sub_categories":["Utility/Miscellaneous","Windows Manager","实用程序/Miscellaneous"],"readme":"[![Build Status](https://travis-ci.org/etherlabsio/go-m3u8.svg?branch=master)](https://travis-ci.org/etherlabsio/go-m3u8)\n[![codecov](https://codecov.io/gh/etherlabsio/go-m3u8/branch/master/graph/badge.svg)](https://codecov.io/gh/etherlabsio/go-m3u8)\n[![Go Report Card](https://goreportcard.com/badge/github.com/etherlabsio/go-m3u8)](https://goreportcard.com/report/github.com/etherlabsio/go-m3u8)\n[![GoDoc](https://godoc.org/github.com/etherlabsio/go-m3u8/m3u8?status.svg)](https://godoc.org/github.com/etherlabsio/go-m3u8/m3u8)\n\n# go-m3u8\nThis is an actively maintained fork of go module https://github.com/quangngotan95/go-m3u8, initally intended for internal use only and later made public.\n\nGolang package for m3u8 (ported m3u8 gem https://github.com/sethdeckard/m3u8)\n\n`go-m3u8` provides easy generation and parsing of m3u8 playlists defined in the HTTP Live Streaming (HLS) Internet Draft published by Apple.\n* The library completely implements version 20 of the HLS Internet Draft.\n* Provides parsing of an m3u8 playlist into an object model from any File, io.Reader or string.\n* Provides ability to write playlist to a string via String()\n* Distinction between a master and media playlist is handled automatically (single Playlist class).\n* 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).\n\n## Installation\n`go get github.com/etherlabsio/go-m3u8`\n\n## Usage (creating playlists)\nCreate a master playlist and child playlists for adaptive bitrate streaming:\n```go\nimport (\n    \"github.com/etherlabsio/go-m3u8/m3u8\"\n    \"github.com/AlekSi/pointer\"\n)\n\nplaylist := m3u8.NewPlaylist()\n```\nCreate a new playlist item:\n```go\nitem := \u0026m3u8.PlaylistItem{\n    Width:      pointer.ToInt(1920),\n    Height:     pointer.ToInt(1080),\n    Profile:    pointer.ToString(\"high\"),\n    Level:      pointer.ToString(\"4.1\"),\n    AudioCodec: pointer.ToString(\"aac-lc\"),\n    Bandwidth:  540,\n    URI:        \"test.url\",\n}\nplaylist.AppendItem(item)\n```\nAdd alternate audio, camera angles, closed captions and subtitles by creating MediaItem instances and adding them to the Playlist:\n```go\nitem := \u0026m3u8.MediaItem{\n    Type:          \"AUDIO\",\n    GroupID:       \"audio-lo\",\n    Name:          \"Francais\",\n    Language:      pointer.ToString(\"fre\"),\n    AssocLanguage: pointer.ToString(\"spoken\"),\n    AutoSelect:    pointer.ToBool(true),\n    Default:       pointer.ToBool(false),\n    Forced:        pointer.ToBool(true),\n    URI:           pointer.ToString(\"frelo/prog_index.m3u8\"),\n}\nplaylist.AppendItem(item)\n```\nCreate 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):\n```go\nplaylist := \u0026m3u8.Playlist{\n    Target:   12,\n    Sequence: 1,\n    Version:  pointer.ToInt(1),\n    Cache:    pointer.ToBool(false),\n    Items: []m3u8.Item{\n        \u0026m3u8.SegmentItem{\n            Duration: 11,\n            Segment:  \"test.ts\",\n        },\n    },\n}\n```\nYou can also access the playlist as a string:\n```go\nvar str string\nstr = playlist.String()\n...\nfmt.Print(playlist)\n```\nAlternatively you can set codecs rather than having it generated automatically:\n```go\nitem := \u0026m3u8.PlaylistItem{\n    Width:     pointer.ToInt(1920),\n    Height:    pointer.ToInt(1080),\n    Codecs:    pointer.ToString(\"avc1.66.30,mp4a.40.2\"),\n    Bandwidth: 540,\n    URI:       \"test.url\",\n}\n```\n\n## Usage (parsing playlists)\nParse from file\n```go\nplaylist, err := m3u8.ReadFile(\"path/to/file\")\n```\nRead from string\n```go\nplaylist, err := m3u8.ReadString(string)\n```\nRead from generic `io.Reader`\n```go\nplaylist, err := m3u8.Read(reader)\n```\n\nAccess items in playlist:\n```go\ngore\u003e playlist.Items[0]\n(*m3u8.SessionKeyItem)#EXT-X-SESSION-KEY:METHOD=AES-128,URI=\"https://priv.example.com/key.php?r=52\"\ngore\u003e playlist.Items[1]\n(*m3u8.PlaybackStart)#EXT-X-START:TIME-OFFSET=20.2\n```\n\n## Misc\nCodecs:\n* Values for audio_codec (codec name): aac-lc, he-aac, mp3\n* Values for profile (H.264 Profile): baseline, main, high.\n* Values for level (H.264 Level): 3.0, 3.1, 4.0, 4.1.\n\nNot all Levels and Profiles can be combined and validation is not currently implemented, consult H.264 documentation for further details.\n\n## Contributing\n1. Fork it https://github.com/etherlabsio/go-m3u8/fork\n2. Create your feature branch `git checkout -b my-new-feature`\n3. Run tests `go test ./test/...`, make sure they all pass and new features are covered\n4. Commit your changes `git commit -am \"Add new features\"`\n5. Push to the branch `git push origin my-new-feature`\n6. Create a new Pull Request\n\n## License\nMIT License - See [LICENSE](https://github.com/etherlabsio/go-m3u8/blob/master/LICENSE) for details\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fetherlabsio%2Fgo-m3u8.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fetherlabsio%2Fgo-m3u8?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetherlabsio%2Fgo-m3u8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetherlabsio%2Fgo-m3u8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetherlabsio%2Fgo-m3u8/lists"}