{"id":31890564,"url":"https://github.com/luispater/matroska-go","last_synced_at":"2026-07-22T15:32:38.894Z","repository":{"id":308034629,"uuid":"1031398000","full_name":"luispater/matroska-go","owner":"luispater","description":"A Pure Go full-surface Matroska demuxer","archived":false,"fork":false,"pushed_at":"2025-08-16T17:06:02.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-21T04:01:47.675Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"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/luispater.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-03T16:50:25.000Z","updated_at":"2025-09-09T02:45:09.000Z","dependencies_parsed_at":"2025-08-03T19:31:54.058Z","dependency_job_id":"5ee2b4ae-88e2-42fb-8a58-6740111b9de3","html_url":"https://github.com/luispater/matroska-go","commit_stats":null,"previous_names":["luispater/matroska-go"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/luispater/matroska-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2Fmatroska-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2Fmatroska-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2Fmatroska-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2Fmatroska-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luispater","download_url":"https://codeload.github.com/luispater/matroska-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luispater%2Fmatroska-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35768236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-13T07:49:45.006Z","updated_at":"2026-07-22T15:32:38.873Z","avatar_url":"https://github.com/luispater.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pure Go Matroska Parser\n\nA high-performance, pure Go implementation of a Matroska (MKV) container parser and demuxer.\n\n## Overview\n\nThis Go package provides a complete solution for parsing Matroska video files without CGO dependencies. It offers both high-level demuxing capabilities and low-level EBML parsing, making it suitable for applications ranging from simple media information extraction to full-featured media processing tools.\n\n## Features\n\n- **Pure Go Implementation**: No CGO dependencies, easy cross-compilation\n- **Complete EBML/Matroska Support**: Full parsing of EBML structure and Matroska-specific elements\n- **Streaming Support**: Works with both seekable files and non-seekable streams\n- **Multi-track Demuxing**: Support for video, audio, and subtitle tracks\n- **Codec Integration**: Handles codec private data and format conversion (AVCC to Annex B for H.264/H.265)\n- **Subtitle Processing**: Built-in SRT format conversion for subtitle tracks\n- **Memory Efficient**: Stream-based processing with minimal memory footprint\n\n## Installation\n\n```bash\ngo get github.com/luispater/matroska-go\n```\n\n## Quick Start\n\n### Basic Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"io\"\n    \"os\"\n    \"github.com/luispater/matroska-go\"\n)\n\nfunc main() {\n    file, err := os.Open(\"video.mkv\")\n    if err != nil {\n        panic(err)\n    }\n    defer file.Close()\n\n    // Create demuxer\n    demuxer, err := matroska.NewDemuxer(file)\n    if err != nil {\n        panic(err)\n    }\n    defer demuxer.Close()\n\n    // Get file information\n    fileInfo, _ := demuxer.GetFileInfo()\n    fmt.Printf(\"Duration: %d ms\\n\", fileInfo.Duration)\n\n    // Get track information\n    numTracks, _ := demuxer.GetNumTracks()\n    for i := uint(0); i \u003c numTracks; i++ {\n        track, _ := demuxer.GetTrackInfo(i)\n        fmt.Printf(\"Track %d: Type=%d, Codec=%s\\n\", i, track.Type, track.CodecID)\n    }\n\n    // Read packets\n    for {\n        packet, err := demuxer.ReadPacket()\n        if err == io.EOF {\n            break\n        }\n        if err != nil {\n            panic(err)\n        }\n        fmt.Printf(\"Track %d: %d bytes at %d ms\\n\", \n            packet.Track, len(packet.Data), packet.StartTime)\n    }\n}\n```\n\n### Streaming Support\n\nFor non-seekable streams (e.g., network streams):\n\n```go\n// Use NewStreamingDemuxer for io.Reader streams\ndemuxer, err := matroska.NewStreamingDemuxer(networkStream)\n```\n\n## Track Extraction Tool\n\nA complete track extraction tool is included that demonstrates advanced usage:\n\n```bash\ngo run ./example/extracter/main.go\n```\n\nThis tool extracts all tracks from MKV files with:\n- Video tracks: Converts AVCC format to Annex B format with proper NAL unit handling\n- Audio tracks: Raw stream extraction  \n- Subtitle tracks: Converts to SRT format with proper timing\n\n## Architecture\n\nThe library is structured in three layers:\n\n1. **EBML Layer** (`ebml.go`): Low-level EBML parsing\n2. **Matroska Parser** (`parser.go`): Matroska-specific structure parsing\n3. **Demuxer API** (`matroska.go`): High-level demuxing interface\n\n## Track Types\n\n- **Video (Type 1)**: H.264, H.265, VP8, VP9, AV1\n- **Audio (Type 2)**: AAC, AC-3, DTS, FLAC, Opus, Vorbis\n- **Subtitle (Type 17)**: ASS, SRT, VobSub, PGS\n\n## API Reference\n\n### Core Types\n\n```go\ntype Packet struct {\n    Track     uint8   // Track number\n    StartTime uint64  // Start time in milliseconds\n    EndTime   uint64  // End time in milliseconds\n    Data      []byte  // Packet data\n    Flags     uint32  // Packet flags (keyframe, etc.)\n}\n\ntype TrackInfo struct {\n    Number       uint8   // Track number\n    Type         uint8   // Track type (1=video, 2=audio, 17=subtitle)\n    CodecID      string  // Codec identifier\n    CodecPrivate []byte  // Codec-specific data\n    // ... additional fields\n}\n```\n\n### Main Functions\n\n- `NewDemuxer(io.ReadSeeker) (*Demuxer, error)` - Create demuxer for seekable streams\n- `NewStreamingDemuxer(io.Reader) (*Demuxer, error)` - Create demuxer for streaming\n- `GetNumTracks() (uint, error)` - Get number of tracks\n- `GetTrackInfo(uint) (*TrackInfo, error)` - Get track information\n- `ReadPacket() (*Packet, error)` - Read next packet\n- `GetFileInfo() (*SegmentInfo, error)` - Get file metadata\n\n## Requirements\n\n- Go 1.24 or later\n- No external dependencies\n\n## Performance\n\nThis pure Go implementation achieves 100% accuracy compared to reference implementations while maintaining high performance through:\n\n- Stream-based processing\n- Efficient EBML parsing\n- Minimal memory allocations\n- Optimized codec format conversions\n\n## License\n\nDistributed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluispater%2Fmatroska-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluispater%2Fmatroska-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluispater%2Fmatroska-go/lists"}