{"id":13735588,"url":"https://github.com/small-teton/mpeg-ts-analyzer","last_synced_at":"2026-04-02T15:24:45.638Z","repository":{"id":144210153,"uuid":"64757571","full_name":"small-teton/mpeg-ts-analyzer","owner":"small-teton","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-11T13:46:17.000Z","size":96,"stargazers_count":32,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-28T02:52:22.184Z","etag":null,"topics":["analyzer","go","golang","iso13818","mpeg","mpeg-ts","mpeg2ts","mpegts","parser","pmt","psi","timestamps","transport-stream"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/small-teton.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}},"created_at":"2016-08-02T13:06:38.000Z","updated_at":"2024-10-02T13:20:52.000Z","dependencies_parsed_at":"2024-01-06T11:56:46.460Z","dependency_job_id":"0dd5be4a-e414-49a0-a016-e1236c64b1d8","html_url":"https://github.com/small-teton/mpeg-ts-analyzer","commit_stats":null,"previous_names":["small-teton/mpeg-ts-analyzer"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/small-teton%2Fmpeg-ts-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/small-teton%2Fmpeg-ts-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/small-teton%2Fmpeg-ts-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/small-teton%2Fmpeg-ts-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/small-teton","download_url":"https://codeload.github.com/small-teton/mpeg-ts-analyzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224593865,"owners_count":17337185,"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":["analyzer","go","golang","iso13818","mpeg","mpeg-ts","mpeg2ts","mpegts","parser","pmt","psi","timestamps","transport-stream"],"created_at":"2024-08-03T03:01:08.578Z","updated_at":"2026-04-02T15:24:45.632Z","avatar_url":"https://github.com/small-teton.png","language":"Go","funding_links":[],"categories":["Analysis tools"],"sub_categories":[],"readme":"# mpeg-ts-analyzer\n\n![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/small-teton/9d60b1e4226ac2926940b20ce3381621/raw/coverage.json)\n\nmpeg-ts-analyzer is an analyzer for MPEG-2 Transport Stream (ISO/IEC 13818-1).\n\nIt parses TS packets and checks whether the stream conforms to the following requirements defined in the specification:\n\n- **Max PCR interval** should be no greater than 100ms (ISO/IEC 13818-1, Section 2.7.2)\n- **PCR-PTS max gap** (end-to-end delay) should be no greater than 1000ms\n\nIn addition, it can dump various MPEG-2 TS internal structures for stream investigation purposes:\n\n- TS header and payload\n- Adaptation Field (including PCR)\n- PSI tables (PAT/PMT) with CRC32 validation\n- PES header with PTS/DTS timestamps\n- continuity_counter validation\n\nBoth 188-byte TS packets and 192-byte M2TS packets (BDAV format with TP_extra_header) are supported. The packet size is auto-detected from the stream.\n\n**Note:** The correctness of the output is not guaranteed.\n\n# Why mpeg-ts-analyzer?\n\nExisting tools like ffprobe provide high-level stream information, but not the low-level detail that broadcast engineers need when debugging TS streams.\n\nmpeg-ts-analyzer gives you:\n\n- **Spec-level field dump** — Every field in TS headers, Adaptation Fields, PSI tables, and PES headers is printed exactly as defined in ISO/IEC 13818-1, making it easy to cross-reference with the specification.\n- **Compliance checks out of the box** — PCR interval (≤ 100ms) and PCR-PTS gap (≤ 1000ms) are automatically validated. No scripting required.\n\nSample TS files are included in `sample_data/` for quick testing:\n\n```bash\n# 188-byte TS\nffmpeg -f lavfi -i \"color=c=blue:s=320x240:d=5,format=yuv420p\" \\\n       -f lavfi -i \"anullsrc=r=48000:cl=stereo\" \\\n       -t 5 -c:v mpeg2video -c:a mp2 -f mpegts sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\n\n# 192-byte M2TS\nffmpeg -f lavfi -i \"color=c=red:s=320x240:d=2,format=yuv420p\" \\\n       -f lavfi -i \"anullsrc=r=48000:cl=stereo\" \\\n       -t 2 -c:v mpeg2video -c:a mp2 -f mpegts -mpegts_m2ts_mode 1 sample_data/sample_192byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\n```\n\n# Install\n\n## Homebrew (macOS / Linux)\n\n```bash\nbrew install small-teton/tap/mpeg-ts-analyzer\n```\n\n## Linux packages (deb / rpm / apk)\n\nDownload `.deb`, `.rpm`, or `.apk` packages from the [Releases](https://github.com/small-teton/mpeg-ts-analyzer/releases) page.\n\n```bash\n# Debian / Ubuntu\ncurl -LO https://github.com/small-teton/mpeg-ts-analyzer/releases/latest/download/mpeg-ts-analyzer_\u003cversion\u003e_linux_amd64.deb\nsudo dpkg -i mpeg-ts-analyzer_\u003cversion\u003e_linux_amd64.deb\n\n# RHEL / CentOS / Fedora\ncurl -LO https://github.com/small-teton/mpeg-ts-analyzer/releases/latest/download/mpeg-ts-analyzer_\u003cversion\u003e_linux_amd64.rpm\nsudo rpm -i mpeg-ts-analyzer_\u003cversion\u003e_linux_amd64.rpm\n\n# Alpine\ncurl -LO https://github.com/small-teton/mpeg-ts-analyzer/releases/latest/download/mpeg-ts-analyzer_\u003cversion\u003e_linux_amd64.apk\nsudo apk add --allow-untrusted mpeg-ts-analyzer_\u003cversion\u003e_linux_amd64.apk\n```\n\n## Pre-built binaries\n\nDownload from the [Releases](https://github.com/small-teton/mpeg-ts-analyzer/releases) page. No additional tools required.\n\n## Go install\n\nIf you have a [Go](https://go.dev/dl/) environment (1.21+):\n\n```bash\ngo install github.com/small-teton/mpeg-ts-analyzer@latest\n```\n\n# Usage\n\nBy default, it dumps all timestamps (PCR/PTS/DTS) including PCR interval and PCR-PTS gap. To dump more details, add the corresponding command-line flags.\n\n```\nUsage:\n  mpeg-ts-analyzer [input file path] [flags]\n\nFlags:\n      --dump-adaptation-field   Dump TS packet adaptation_field detail.\n      --dump-pes-header         Dump PES packet header detail.\n      --dump-psi                Dump PSI(PAT/PMT) detail.\n      --dump-timestamp          Dump PCR/PTS/DTS timestamps.\n      --dump-ts-header          Dump TS packet header.\n      --dump-ts-payload         Dump TS packet payload binary.\n  -h, --help                    help for mpeg-ts-analyzer\n      --limit int               Stop reading after this many bytes (0 = no limit).\n      --offset int              Start reading from this byte offset.\n      --version                 show mpeg-ts-analyzer version.\n```\n\n**Tip:** For large files, dump options can produce a huge amount of output. Use `--limit` to restrict the byte range, or redirect output to a file to avoid losing the beginning of the output in your terminal scrollback:\n\n```bash\nmpeg-ts-analyzer large.ts --dump-ts-header --limit 1000000 \u003e dump.txt\n```\n\n# Result Examples\n\n## No option\n\n```\n$ ./mpeg-ts-analyzer sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\nInput file:  sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\nDetected PAT: PMT pid = 0x1000\nDetected PMT\nPMT : Program Info : elementary_PID     : 0x100, stream_type : 0x02 (13818-2 video or 11172-2 constrained parameter video stream)\nPMT : Program Info : elementary_PID     : 0x101, stream_type : 0x03 (11172 audio)\n```\n\n## Dump TS header\n\n```\n$ ./mpeg-ts-analyzer sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts --dump-ts-header\nInput file:  sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\n===============================================================\n TS Header\n===============================================================\ntransport_error_indicator       : 0\npayload_unit_start_indicator    : 1\ntransport_priority              : 0\npid                             : 0x0\ntransport_scrambling_control    : 0\nadaptation_field_control        : 1\ncontinuity_counter              : 0\n===============================================================\n TS Header\n===============================================================\ntransport_error_indicator       : 0\npayload_unit_start_indicator    : 1\ntransport_priority              : 0\npid                             : 0x1000\ntransport_scrambling_control    : 0\nadaptation_field_control        : 1\ncontinuity_counter              : 0\n===============================================================\n TS Header\n===============================================================\ntransport_error_indicator       : 0\npayload_unit_start_indicator    : 1\ntransport_priority              : 0\npid                             : 0x100\ntransport_scrambling_control    : 0\nadaptation_field_control        : 3\ncontinuity_counter              : 0\n```\n\n## Dump PSI\n\n```\n$ ./mpeg-ts-analyzer sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts --dump-psi\nInput file:  sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\nDetected PAT: PMT pid = 0x1000\n\n===========================================\n PAT\n===========================================\nPAT : table_id                          : 0x0\nPAT : section_syntax_indicator          : 1\nPAT : section_length                    : 13\nPAT : transport_stream_id               : 1\nPAT : version_number                    : 0\nPAT : current_next_indicator            : 1\nPAT : section_number                    : 0\nPAT : last_section_number               : 0\nPAT : program_number                    : 1\nPAT : program_map_PID                   : 0x1000\nPAT : CRC_32                            : 2ab104b2\nDetected PMT\n\n===========================================\n PMT\n===========================================\nPMT : table_id                          : 0x2\nPMT : section_syntax_indicator          : 1\nPMT : section_length                    : 23\nPMT : program_number                    : 1\nPMT : version_number                    : 0\nPMT : current_next_indicator            : 1\nPMT : section_number                    : 0\nPMT : last_section_number               : 0\nPMT : PCR_PID                           : 0x100\nPMT : program_info_length               : 0\nPMT : Program Info : elementary_PID     : 0x100, stream_type : 0x02 (13818-2 video or 11172-2 constrained parameter video stream)\nPMT : Program Info : elementary_PID     : 0x101, stream_type : 0x03 (11172 audio)\nPMT : CRC_32                            : f64a0355\n```\n\n## Dump timestamp\n\n```\n$ ./mpeg-ts-analyzer sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts --dump-timestamp\nInput file:  sample_data/sample_188byte_video_mpeg2_320x240_25fps_audio_mp2_48000Hz.ts\nDetected PAT: PMT pid = 0x1000\nDetected PMT\nPMT : Program Info : elementary_PID     : 0x100, stream_type : 0x02 (13818-2 video or 11172-2 constrained parameter video stream)\nPMT : Program Info : elementary_PID     : 0x101, stream_type : 0x03 (11172 audio)\n0x000034e0 PCR: 0x018344a0[00940.000000ms]\n0x000034e0 DTS: 0x00024090[01640.000000ms] (pid:0x100) (delay:700.000000ms)\n0x0000359c PTS: 0x00023a3a[01621.977778ms] (pid:0x101) (delay:668.922222ms)\n0x00004970 PCR: 0x01a43a20[01020.000000ms] (Interval:00080.000000ms)\n0x00003f28 DTS: 0x00024ea0[01680.000000ms] (pid:0x100) (delay:557.222222ms)\n0x00004970 DTS: 0x00025cb0[01720.000000ms] (pid:0x100) (delay:700.000000ms)\n0x00003fe4 PTS: 0x00024b1a[01669.977778ms] (pid:0x101) (delay:534.144444ms)\n0x000055ec PCR: 0x01c52fa0[01100.000000ms] (Interval:00080.000000ms)\n0x00004ba4 DTS: 0x00026ac0[01760.000000ms] (pid:0x100) (delay:709.400000ms)\n0x00004c60 PTS: 0x00025bfa[01717.977778ms] (pid:0x101) (delay:657.177778ms)\n\n(snip)\n\n0x0004a66c PCR: 0x091bd920[05660.000000ms] (Interval:00080.000000ms)\n0x00049c24 DTS: 0x0008ade0[06320.000000ms] (pid:0x100) (delay:729.563591ms)\n0x00049ce0 PTS: 0x00089f1a[06277.977778ms] (pid:0x101) (delay:684.062566ms)\n0x0004a728 PTS: 0x0008affa[06325.977778ms] (pid:0x101) (delay:662.486106ms)\n0x0004b0b4 PTS: 0x0008c0da[06373.977778ms] (pid:0x101) (delay:665.094372ms)\n-----------------------------\nMax PCR interval: 80.000000ms\nPCR-PTS max gap: 729.563591ms\n```\n\n# Development\n\n## Test \u0026 Coverage\n\n```bash\nmake setup      # configure git hooks (run once after clone)\nmake build      # build binary\nmake test       # run all tests\nmake coverage   # run tests with coverage report\nmake install    # install to $GOPATH/bin\nmake uninstall  # remove from $GOPATH/bin\nmake clean      # remove build/coverage artifacts\n```\n\nThe version string is managed in the `VERSION` file and injected at build time.\n\nCoverage is measured for `bitbuffer` and `tsparser` packages only. CLI entrypoint (`cmd`, `main.go`) is excluded from coverage targets. Both packages should maintain 100% coverage.\n\nA pre-push hook (`make setup` to enable) runs build, test, and coverage checks before every push. Push is rejected if coverage drops below 100%.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmall-teton%2Fmpeg-ts-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmall-teton%2Fmpeg-ts-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmall-teton%2Fmpeg-ts-analyzer/lists"}