{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://small-teton.github.io/mpeg-ts-analyzer/json-schema-v2.json",
  "title": "mpeg-ts-analyzer JSON report v2",
  "description": "Schema for --format json. Objects permit additive fields and status strings permit additive lowercase values within schema version 2.",
  "type": "object",
  "required": [
    "schema_version",
    "input",
    "status",
    "programs",
    "warnings"
  ],
  "properties": {
    "schema_version": {
      "const": "2.0"
    },
    "input": {
      "$ref": "#/$defs/input"
    },
    "status": {
      "$ref": "#/$defs/status",
      "description": "Current values: complete, programs_listed, incomplete, failed."
    },
    "reason": {
      "$ref": "#/$defs/reasonCode",
      "description": "Stable machine-readable reason code."
    },
    "error": {
      "type": "string",
      "description": "Human-readable error detail; not a stable matching interface."
    },
    "acquisition": {
      "$ref": "#/$defs/acquisition",
      "description": "Evidence of a failed initial acquisition: present with status failed and reason sync_not_acquired, insufficient_data_for_sync, pat_not_observed or pat_not_acquired, and absent otherwise."
    },
    "programs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/program"
      }
    },
    "selected_program_number": {
      "$ref": "#/$defs/nonNegativeInteger"
    },
    "sync": {
      "$ref": "#/$defs/sync"
    },
    "compliance": {
      "$ref": "#/$defs/compliance"
    },
    "continuity_counter": {
      "$ref": "#/$defs/continuity"
    },
    "transport_errors": {
      "$ref": "#/$defs/affectedPackets",
      "description": "Packets with transport_error_indicator set, over every packet of the range. Present whenever the analysis ran (status complete). Only the fixed 4-byte TS header of such a packet is read, so a malformed adaptation field or a reserved adaptation_field_control does not stop the count; each pid is the one in the damaged header."
    },
    "scrambled_packets": {
      "$ref": "#/$defs/affectedPackets",
      "description": "Packets with a non-zero transport_scrambling_control, over every packet of the range. Present whenever the analysis ran (status complete)."
    },
    "psi_health": {
      "$ref": "#/$defs/psiHealth",
      "description": "Availability and repetition of the PAT and of the PMT of every program the applied PAT announces (not only the selected one), over every packet of the range. Present whenever the analysis ran (status complete)."
    },
    "pid_references": {
      "$ref": "#/$defs/pidReferences",
      "description": "Referenced, missing and unreferenced PIDs of the PSI layouts, over every packet of the range. Present whenever the analysis ran (status complete)."
    },
    "pes_headers": {
      "$ref": "#/$defs/pesHeaders",
      "description": "PES header checks of every elementary stream of the selected program. Present whenever the analysis ran (status complete)."
    },
    "pts_repetition": {
      "$ref": "#/$defs/ptsRepetition",
      "description": "Intervals between PES packets carrying a PTS on each video and audio stream of the selected program. Present whenever the analysis ran (status complete)."
    },
    "multiplexing": {
      "$ref": "#/$defs/multiplexing",
      "description": "Report-only multiplexing diagnostics: per-PID maximum packet gaps over every packet of the range, and the mux lead and A/V lead difference of every elementary stream of the selected program. They carry no verdict and never affect the exit status. Present whenever the analysis ran (status complete)."
    },
    "timestamp_anomalies": {
      "$ref": "#/$defs/timestampAnomalies"
    },
    "pcr_jitter": {
      "$ref": "#/$defs/pcrJitter"
    },
    "bitrate": {
      "$ref": "#/$defs/bitrate"
    },
    "psi_transitions": {
      "type": "array",
      "description": "PAT and PMT version changes applied during the analysis, in stream order. Absent when no change was applied. programs describes the layout at the start of the analysis.",
      "items": {
        "$ref": "#/$defs/psiTransition"
      }
    },
    "failure_policy": {
      "$ref": "#/$defs/failurePolicy",
      "description": "The selected --fail-on / --fail-on-error policy and its result. Absent when no policy is selected and when no program was analyzed (programs_listed, failed)."
    },
    "warnings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/warning"
      }
    }
  },
  "$defs": {
    "nonNegativeInteger": {
      "type": "integer",
      "minimum": 0
    },
    "status": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$"
    },
    "reasonCode": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$"
    },
    "pid": {
      "type": "string",
      "pattern": "^0x[0-9a-f]{4}$"
    },
    "streamType": {
      "type": "string",
      "pattern": "^0x[0-9a-f]{2}$"
    },
    "input": {
      "type": "object",
      "required": [
        "path",
        "offset_bytes"
      ],
      "properties": {
        "path": {
          "type": "string"
        },
        "packet_size_bytes": {
          "type": "integer",
          "enum": [188, 192, 204],
          "description": "Physical packet size: 188 (TS), 192 (M2TS: 4-byte TP_extra_header, then the TS packet) or 204 (the TS packet, then a 16-byte trailer)."
        },
        "offset_bytes": {
          "type": "integer"
        },
        "limit_bytes": {
          "type": "integer"
        }
      }
    },
    "program": {
      "type": "object",
      "required": [
        "program_number",
        "pmt_pid",
        "elementary_streams",
        "status"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pmt_pid": {
          "$ref": "#/$defs/pid"
        },
        "pcr_pid": {
          "$ref": "#/$defs/pid"
        },
        "elementary_streams": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/elementaryStream"
          }
        },
        "service": {
          "$ref": "#/$defs/service"
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: complete, incomplete."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Stable machine-readable reason code. Current value: pmt_parse_failed."
        },
        "error": {
          "type": "string",
          "description": "Human-readable error detail; not a stable matching interface."
        }
      }
    },
    "service": {
      "type": "object",
      "description": "The program's service from the SDT actual (table_id 0x42) whose service_id equals program_number; absent when the stream has no SDT or the SDT does not list the program. The fields come from the service_descriptor and are absent without one. Each name is either decoded text or, when its DVB character table is not supported, the raw bytes including the table selector as lowercase hex.",
      "properties": {
        "service_type": {
          "type": "string",
          "pattern": "^0x[0-9a-f]{2}$"
        },
        "service_type_description": {
          "type": "string"
        },
        "provider_name": {
          "type": "string"
        },
        "provider_name_hex": {
          "type": "string",
          "pattern": "^([0-9a-f]{2})+$"
        },
        "name": {
          "type": "string"
        },
        "name_hex": {
          "type": "string",
          "pattern": "^([0-9a-f]{2})+$"
        }
      }
    },
    "elementaryStream": {
      "type": "object",
      "required": [
        "pid",
        "stream_type",
        "stream_type_description"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "stream_type": {
          "$ref": "#/$defs/streamType"
        },
        "stream_type_description": {
          "type": "string"
        }
      }
    },
    "check": {
      "type": "object",
      "required": [
        "status",
        "limit_ms",
        "observations"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, ng, skipped."
        },
        "value_ms": {
          "type": "number"
        },
        "limit_ms": {
          "type": "number"
        },
        "observations": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "reason": {
          "type": "string",
          "description": "Human-readable skip explanation; not a stable matching interface."
        }
      }
    },
    "compliance": {
      "type": "object",
      "required": [
        "max_pcr_interval",
        "max_pcr_pts_dts_gap"
      ],
      "properties": {
        "max_pcr_interval": {
          "$ref": "#/$defs/check",
          "description": "Largest interval between consecutive comparable PCRs (continuous or wraparound steps) of the selected program, judged against 100 ms (ISO/IEC 13818-1, 2.7.2)."
        },
        "pcr_discontinuities": {
          "$ref": "#/$defs/pcrDiscontinuityCheck",
          "description": "Added within schema 2.0; absent from documents of an earlier 2.0 CLI."
        },
        "max_pcr_pts_dts_gap": {
          "$ref": "#/$defs/check"
        }
      }
    },
    "pcrDiscontinuityCheck": {
      "type": "object",
      "required": [
        "status",
        "pcr_count",
        "undeclared_count",
        "jump_limit_ms",
        "items"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, ng (at least one backward or forward_jump step without discontinuity_indicator), skipped (fewer than two PCRs)."
        },
        "reason": {
          "type": "string",
          "description": "Human-readable skip explanation; not a stable matching interface."
        },
        "pcr_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PCRs of the selected program in the range."
        },
        "undeclared_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Steps of kind backward or forward_jump."
        },
        "jump_limit_ms": {
          "type": "number",
          "description": "Largest forward step measured as an interval; a larger undeclared step is a forward_jump."
        },
        "items": {
          "type": "array",
          "description": "Each step kind other than continuous that occurred, in the order wraparound, declared, pcr_pid_change, backward, forward_jump.",
          "items": {
            "$ref": "#/$defs/pcrStep"
          }
        }
      }
    },
    "pcrStep": {
      "type": "object",
      "required": [
        "kind",
        "count",
        "first_offset_bytes",
        "first_jump_ms"
      ],
      "properties": {
        "kind": {
          "$ref": "#/$defs/status",
          "description": "Current values: wraparound, declared, pcr_pid_change, backward, forward_jump."
        },
        "count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "first_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Byte offset of the first PCR packet of this kind."
        },
        "first_jump_ms": {
          "type": "number",
          "description": "PCR value difference to the previous PCR at that packet; for a wraparound, the interval counted across the wrap."
        }
      }
    },
    "continuityPID": {
      "type": "object",
      "required": [
        "pid",
        "label",
        "error_count"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "label": {
          "type": "string"
        },
        "error_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        }
      }
    },
    "acquisition": {
      "type": "object",
      "description": "What the scan observed before program analysis stopped: no packet alignment or no usable PAT. The range is [range_start_offset_bytes, range_end_offset_bytes), the selected --offset/--limit range clipped to the input. Fixed size: three layouts and a set of PAT counters.",
      "required": [
        "range_start_offset_bytes",
        "range_end_offset_bytes",
        "scanned_bytes",
        "alignment"
      ],
      "properties": {
        "range_start_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "range_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Exclusive end of the scanned range."
        },
        "scanned_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "alignment": {
          "type": "object",
          "required": [
            "status",
            "aligned_packet_count",
            "layouts"
          ],
          "properties": {
            "status": {
              "$ref": "#/$defs/status",
              "description": "Current values: acquired, not_acquired (the range was long enough to show every layout), insufficient_data (the range was too short to show at least one layout)."
            },
            "packet_size_bytes": {
              "type": "integer",
              "enum": [188, 192, 204],
              "description": "Packet size of the alignment found, as the detector prefers it in the first read that holds one (possibly after a first read without alignment); present when status is acquired."
            },
            "first_aligned_offset_bytes": {
              "$ref": "#/$defs/nonNegativeInteger",
              "description": "Offset of the first aligned packet; present when at least one was found."
            },
            "aligned_packet_count": {
              "$ref": "#/$defs/nonNegativeInteger",
              "description": "Packets of packet_size_bytes that started with the sync byte inside an alignment the detector accepts; 0 unless status is acquired."
            },
            "layouts": {
              "type": "array",
              "description": "Every supported layout, in the order 188, 192, 204.",
              "items": {
                "type": "object",
                "required": [
                  "packet_size_bytes",
                  "required_sync_bytes",
                  "required_bytes",
                  "status"
                ],
                "properties": {
                  "packet_size_bytes": {
                    "type": "integer",
                    "enum": [188, 192, 204]
                  },
                  "required_sync_bytes": {
                    "$ref": "#/$defs/nonNegativeInteger",
                    "description": "Consecutive sync bytes, one packet apart, that the detector requires."
                  },
                  "required_bytes": {
                    "$ref": "#/$defs/nonNegativeInteger",
                    "description": "Shortest range that can hold them."
                  },
                  "status": {
                    "$ref": "#/$defs/status",
                    "description": "Current values: found, not_found, insufficient_data (scanned_bytes is less than required_bytes)."
                  }
                }
              }
            }
          }
        },
        "pat": {
          "type": "object",
          "description": "PID 0 in the aligned packets; present when alignment.status is acquired. Problem counts follow psi_health.tables[].",
          "required": [
            "status",
            "packet_count",
            "section_start_count",
            "complete_table_count",
            "crc_error_count",
            "malformed_section_count",
            "incomplete_count",
            "wrong_table_id_count",
            "unusable_packet_count"
          ],
          "properties": {
            "status": {
              "$ref": "#/$defs/status",
              "description": "Current values: not_observed (no packet on PID 0), not_acquired (packets on PID 0 but no usable PAT)."
            },
            "packet_count": {
              "$ref": "#/$defs/nonNegativeInteger"
            },
            "section_start_count": {
              "$ref": "#/$defs/nonNegativeInteger",
              "description": "Packets on PID 0 with payload_unit_start_indicator set."
            },
            "first_packet_offset_bytes": {
              "$ref": "#/$defs/nonNegativeInteger"
            },
            "complete_table_count": {
              "$ref": "#/$defs/nonNegativeInteger",
              "description": "Complete PATs assembled from the range that PAT discovery could not start from (for example, one in the last two packets)."
            },
            "crc_error_count": {
              "$ref": "#/$defs/nonNegativeInteger"
            },
            "malformed_section_count": {
              "$ref": "#/$defs/nonNegativeInteger"
            },
            "incomplete_count": {
              "$ref": "#/$defs/nonNegativeInteger"
            },
            "wrong_table_id_count": {
              "$ref": "#/$defs/nonNegativeInteger"
            },
            "unusable_packet_count": {
              "$ref": "#/$defs/nonNegativeInteger"
            }
          }
        }
      }
    },
    "sync": {
      "type": "object",
      "description": "TS synchronization of the analyzed packets: packet boundaries without the sync byte 0x47 and the realignment after each. Offsets are absolute byte offsets in the input.",
      "required": [
        "status",
        "required_sync_bytes",
        "max_resync_scan_bytes",
        "loss_count",
        "resync_count",
        "skipped_bytes",
        "trailing_partial_packet_bytes"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, recovered, lost. lost means the analysis stopped at an unrecovered loss (top-level status incomplete, reason sync_lost)."
        },
        "reason": {
          "type": "string",
          "description": "Present for lost: why no alignment was found. Human-readable; not a stable matching interface."
        },
        "required_sync_bytes": {
          "type": "integer",
          "minimum": 1,
          "description": "Consecutive packets, one packet size apart, that must start with the sync byte to accept a new alignment."
        },
        "max_resync_scan_bytes": {
          "type": "integer",
          "minimum": 1,
          "description": "How far after a lost boundary a new alignment may start."
        },
        "loss_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "resync_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "skipped_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Bytes skipped by the recovered losses; they were not analyzed."
        },
        "first_loss_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "first_resync_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "max_skipped_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "The largest span skipped by one recovered loss."
        },
        "max_skipped_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the loss with the largest skipped span."
        },
        "unrecovered_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "The lost boundary where the analysis stopped; present for lost."
        },
        "trailing_partial_packet_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Size of an incomplete packet at the end of the input; 0 when there is none. Not a loss of synchronization."
        },
        "trailing_partial_packet_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        }
      }
    },
    "continuity": {
      "type": "object",
      "required": [
        "status",
        "total_error_count",
        "pids"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, errors."
        },
        "total_error_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/continuityPID"
          }
        }
      }
    },
    "affectedPID": {
      "type": "object",
      "required": [
        "pid",
        "label",
        "packet_count",
        "excluded_packet_count",
        "first_offset_bytes"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "label": {
          "type": "string",
          "description": "Role of the PID in the applied layouts: PAT, PMT, PCR, video, audio, stream_type 0xNN, null for 0x1fff, or unknown."
        },
        "packet_count": {
          "type": "integer",
          "minimum": 1
        },
        "excluded_packet_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Packets of this PID whose payload or PCR the analysis would have read and left out instead."
        },
        "first_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Byte offset of the PID's first affected packet (for M2TS, of its TP_extra_header)."
        }
      }
    },
    "pidReferences": {
      "type": "object",
      "required": [
        "time_basis",
        "silence_limit_ms",
        "unreferenced_grace_ms",
        "referenced",
        "unreferenced"
      ],
      "properties": {
        "time_basis": {
          "$ref": "#/$defs/status",
          "description": "Time model of the durations. Current value: pcr_interpolated_file_position (packet positions interpolated between the PCRs of the reference program; durations are lower bounds outside the PCR-covered range and across PCR discontinuities)."
        },
        "silence_limit_ms": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "A judged referenced PID with no packet for longer than this is silent (or absent without any packet)."
        },
        "unreferenced_grace_ms": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "How long a PID may carry packets before a layout references it, or after a layout stopped referencing it."
        },
        "referenced": {
          "type": "object",
          "required": [
            "status",
            "pids"
          ],
          "properties": {
            "status": {
              "$ref": "#/$defs/status",
              "description": "The most severe row status. Current values: ok, absent, silent, insufficient_data."
            },
            "pids": {
              "type": "array",
              "description": "One row per program, role, PID and (for elementary streams) stream_type ever referenced, ordered by program_number, role (pmt, pcr, elementary_stream), PID and stream_type.",
              "items": {
                "$ref": "#/$defs/referencedPID"
              }
            }
          }
        },
        "unreferenced": {
          "type": "object",
          "required": [
            "status",
            "pids"
          ],
          "properties": {
            "status": {
              "$ref": "#/$defs/status",
              "description": "Current values: ok, unreferenced, insufficient_data, skipped."
            },
            "reason": {
              "$ref": "#/$defs/reasonCode",
              "description": "Why the result is insufficient_data or skipped. Current values: no_pcr_time_base, unreferenced_within_grace, program_layouts_unknown."
            },
            "pids": {
              "type": "array",
              "description": "PIDs that carried unreferenced packets, in numeric order.",
              "items": {
                "$ref": "#/$defs/unreferencedPID"
              }
            }
          }
        }
      }
    },
    "referencedPID": {
      "type": "object",
      "required": [
        "program_number",
        "role",
        "pid",
        "status",
        "silence_judged",
        "packet_count",
        "referenced_packet_count",
        "referenced_from_offset_bytes",
        "referenced_until_offset_bytes"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "role": {
          "$ref": "#/$defs/status",
          "description": "What the layout references the PID as. Current values: pmt, pcr, elementary_stream."
        },
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "stream_type": {
          "$ref": "#/$defs/streamType",
          "description": "stream_type of an elementary_stream row; a stream retyped by a PMT change has one row per type. Absent for the other roles."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, absent, silent, insufficient_data."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Why the row is insufficient_data. Current values: no_pcr_time_base, reference_shorter_than_limit, intermittent_stream_type."
        },
        "silence_judged": {
          "type": "boolean",
          "description": "Whether absence and silence are judged for the role: PMT, PCR and video or audio elementary streams."
        },
        "packet_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Packets of the PID in the whole range, without packets with transport_error_indicator set."
        },
        "first_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "First of those packets; absent when packet_count is 0."
        },
        "last_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Last of those packets; absent when packet_count is 0."
        },
        "referenced_packet_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Packets of the PID while this row was referenced."
        },
        "referenced_from_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the packet from which the row was first referenced."
        },
        "referenced_until_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset where its last reference ended: the packet from which a layout no longer referenced it, or the end of the scan."
        },
        "max_silence_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Longest time without a packet of the PID while referenced, including from a reference start to the first packet and from the last packet to the reference end; absent without a PCR time base."
        },
        "max_silence_exact": {
          "type": "boolean",
          "description": "Whether max_silence_ms was interpolated within one PCR timing segment; false means it is a lower bound."
        },
        "max_silence_start_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the packet, or of the reference start, before the longest silence."
        },
        "max_silence_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the packet, or of the reference end, that ended the longest silence."
        }
      }
    },
    "unreferencedPID": {
      "type": "object",
      "required": [
        "pid",
        "status",
        "packet_count",
        "first_offset_bytes",
        "last_offset_bytes",
        "longest_run_ms"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: unreferenced (a run lasted longer than the grace period), insufficient_data (a run was cut by the end of the range, or by a layout that is not fully known, before the grace period could elapse)."
        },
        "packet_count": {
          "type": "integer",
          "minimum": 1,
          "description": "Packets of the runs with this status."
        },
        "first_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "last_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "longest_run_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Longest of those runs: from its first packet to its end (a reference, or the end of the range), or to its last packet for a PID an earlier layout referenced."
        }
      }
    },
    "multiplexing": {
      "type": "object",
      "required": [
        "packet_gaps",
        "mux_lead"
      ],
      "description": "Report-only multiplexing diagnostics. They carry no verdict, never become findings and never affect the exit status.",
      "properties": {
        "packet_gaps": {
          "$ref": "#/$defs/packetGaps"
        },
        "mux_lead": {
          "$ref": "#/$defs/muxLead"
        }
      }
    },
    "packetGaps": {
      "type": "object",
      "required": [
        "time_basis",
        "pids"
      ],
      "properties": {
        "time_basis": {
          "$ref": "#/$defs/status",
          "description": "Time model of max_gap_ms. Current value: pcr_interpolated_file_position (packet positions interpolated between the PCRs of the reference program, as for pid_references)."
        },
        "pids": {
          "type": "array",
          "description": "Every PID observed in the range except the null PID 0x1FFF, in numeric order.",
          "items": {
            "$ref": "#/$defs/packetGapPID"
          }
        }
      }
    },
    "packetGapPID": {
      "type": "object",
      "required": [
        "pid",
        "references",
        "packet_count",
        "status"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "references": {
          "type": "array",
          "description": "Every program and role under which a PAT or followed PMT of the range referenced the PID, ordered by program_number, role (pmt, pcr, elementary_stream) and stream_type; empty for PSI/SI PIDs and PIDs no layout referenced.",
          "items": {
            "$ref": "#/$defs/pidReference"
          }
        },
        "packet_count": {
          "type": "integer",
          "minimum": 1,
          "description": "Packets of the PID in the whole range, without packets with transport_error_indicator set."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Not a verdict. Current values: info (a gap was measured), insufficient_data (no two consecutive packets)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Current values: no_consecutive_packets (insufficient_data: fewer than two packets in one stretch of the layout), no_pcr_time_base (info without max_gap_ms)."
        },
        "max_gap_packets": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Largest number of packets of other PIDs (null and transport-error packets included) between two consecutive packets of the PID; the endpoints are not counted. Two packets on either side of a PAT/PMT change that stops or resumes referencing the PID are not consecutive. Absent when status is insufficient_data."
        },
        "max_gap_start_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the packet that starts the largest gap. Of equal gaps the first is reported, preferring the first that starts after the first PCR of the time basis."
        },
        "max_gap_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the packet that ends the largest gap."
        },
        "max_gap_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Estimated time of the largest gap; absent without a PCR time base."
        },
        "max_gap_exact": {
          "type": "boolean",
          "description": "Whether max_gap_ms was interpolated within one PCR timing segment; false means it is a lower bound (the gap lies partly before the first or after the last PCR, or crosses a PCR discontinuity)."
        }
      }
    },
    "pidReference": {
      "type": "object",
      "required": [
        "program_number",
        "role"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "role": {
          "$ref": "#/$defs/status",
          "description": "Current values: pmt, pcr, elementary_stream."
        },
        "stream_type": {
          "$ref": "#/$defs/streamType",
          "description": "stream_type of an elementary_stream reference; absent for the other roles."
        }
      }
    },
    "affectedPackets": {
      "type": "object",
      "required": [
        "status",
        "packet_count",
        "excluded_packet_count",
        "pids"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (no affected packet), affected (affected packets, none carrying data the analysis reads), data_excluded (data of at least one affected packet was left out of the analysis)."
        },
        "packet_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "excluded_packet_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "first_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Byte offset of the first affected packet; absent when packet_count is 0."
        },
        "pids": {
          "type": "array",
          "description": "Affected PIDs in numeric order; empty when packet_count is 0.",
          "items": {
            "$ref": "#/$defs/affectedPID"
          }
        }
      }
    },
    "pesHeaderError": {
      "type": "object",
      "required": [
        "kind",
        "count",
        "first_offset_bytes"
      ],
      "properties": {
        "kind": {
          "$ref": "#/$defs/status",
          "description": "Current values: truncated, bad_start_code, bad_flags, inconsistent_length, bad_marker_bits."
        },
        "count": {
          "type": "integer",
          "minimum": 1
        },
        "first_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Byte offset of the packet that starts the first PES with this problem (for M2TS, of its TP_extra_header)."
        }
      }
    },
    "pesHeaderPID": {
      "type": "object",
      "required": [
        "program_number",
        "pid",
        "stream_type",
        "label",
        "status",
        "checked_count",
        "error_count",
        "unchecked_count",
        "errors"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "stream_type": {
          "$ref": "#/$defs/streamType",
          "description": "The last stream_type the PMT announced for the PID."
        },
        "label": {
          "type": "string",
          "description": "video, audio or stream_type 0xNN, from stream_type."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (every checked header is valid), errors (at least one header failed a check), insufficient_data (no header was checked)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data. Current values: no_pes, untrusted_payload, incomplete_headers."
        },
        "checked_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Headers checked, valid or not."
        },
        "error_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "unchecked_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PES packets whose header was not complete when the data ended (untrusted payload, a PMT change or the end of the range); not counted as errors."
        },
        "first_error_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the first malformed header; absent when error_count is 0."
        },
        "errors": {
          "type": "array",
          "description": "Header problems found, in the order of kind listed above.",
          "items": {
            "$ref": "#/$defs/pesHeaderError"
          }
        }
      }
    },
    "pesHeaders": {
      "type": "object",
      "required": [
        "status",
        "checked_count",
        "error_count",
        "unchecked_count",
        "errors",
        "pids"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (every checked header is valid), errors (at least one header failed a check), insufficient_data (no header was checked)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data. Current values: no_pes, untrusted_payload, incomplete_headers."
        },
        "checked_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Headers checked, valid or not."
        },
        "error_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "unchecked_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PES packets whose header was not complete when the data ended (untrusted payload, a PMT change or the end of the range); not counted as errors."
        },
        "first_error_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the first malformed header; absent when error_count is 0."
        },
        "errors": {
          "type": "array",
          "description": "Header problems found, in the order of kind listed above.",
          "items": {
            "$ref": "#/$defs/pesHeaderError"
          }
        },
        "pids": {
          "type": "array",
          "description": "Every elementary stream of the analyzed programs, by program_number and PID.",
          "items": {
            "$ref": "#/$defs/pesHeaderPID"
          }
        }
      }
    },
    "ptsRepetitionPID": {
      "type": "object",
      "required": [
        "program_number",
        "pid",
        "stream_type",
        "label",
        "status",
        "pts_count",
        "interval_count",
        "exceeded_count"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "stream_type": {
          "$ref": "#/$defs/streamType",
          "description": "The last stream_type the PMT announced for the PID."
        },
        "label": {
          "type": "string",
          "description": "video, audio or stream_type 0xNN, from stream_type."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (at least one interval measured, none above the limit), ng (an interval exceeded the limit), insufficient_data (nothing could be measured), skipped (the stream_type is not a video or audio type)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data or skipped. Current values: no_pes, untrusted_payload, malformed_headers, no_pcr_timing, no_pts, single_pts, not_video_or_audio; for the totals also no_video_or_audio."
        },
        "pts_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Valid PES headers carrying a PTS."
        },
        "interval_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Intervals measured between two PES packets carrying a PTS."
        },
        "max_interval_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Largest interval: measured, or a lower bound above the limit (PES packets without a PTS for that long). Absent when there is none."
        },
        "max_interval_start_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet that starts the largest interval."
        },
        "max_interval_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet that ends the largest interval."
        },
        "exceeded_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Intervals above the limit."
        },
        "first_exceeded_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet that ends the first interval above the limit; absent when exceeded_count is 0."
        }
      }
    },
    "ptsRepetition": {
      "type": "object",
      "required": [
        "limit_ms",
        "status",
        "pts_count",
        "interval_count",
        "exceeded_count",
        "pids"
      ],
      "properties": {
        "limit_ms": {
          "type": "number",
          "description": "700: ISO/IEC 13818-1 clause 2.7.4 and ETSI TR 101 290 indicator 2.5 (PTS_error)."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (at least one interval measured, none above the limit), ng (an interval exceeded the limit), insufficient_data (nothing could be measured), skipped (the stream_type is not a video or audio type)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data or skipped. Current values: no_pes, untrusted_payload, malformed_headers, no_pcr_timing, no_pts, single_pts, not_video_or_audio; for the totals also no_video_or_audio."
        },
        "pts_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Valid PES headers carrying a PTS."
        },
        "interval_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Intervals measured between two PES packets carrying a PTS."
        },
        "max_interval_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Largest interval: measured, or a lower bound above the limit (PES packets without a PTS for that long). Absent when there is none."
        },
        "max_interval_start_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet that starts the largest interval."
        },
        "max_interval_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet that ends the largest interval."
        },
        "exceeded_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Intervals above the limit."
        },
        "first_exceeded_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet that ends the first interval above the limit; absent when exceeded_count is 0."
        },
        "pids": {
          "type": "array",
          "description": "Every elementary stream of the analyzed programs, by program_number and PID.",
          "items": {
            "$ref": "#/$defs/ptsRepetitionPID"
          }
        }
      }
    },
    "muxLead": {
      "type": "object",
      "required": [
        "time_basis",
        "pids",
        "programs"
      ],
      "properties": {
        "time_basis": {
          "$ref": "#/$defs/status",
          "description": "Time model of the arrival time. Current value: pcr_interpolated_file_position (the byte position of the packet that starts the PES packet, interpolated between the program's PCRs before and after it within one PCR segment, as for the PCR-PTS/DTS gap)."
        },
        "pids": {
          "type": "array",
          "description": "Every elementary stream of the analyzed programs, by program_number and PID.",
          "items": {
            "$ref": "#/$defs/muxLeadPID"
          }
        },
        "programs": {
          "type": "array",
          "description": "Every analyzed program that had both a video and an audio stream (see av_class), by program_number.",
          "items": {
            "$ref": "#/$defs/avLeadProgram"
          }
        }
      }
    },
    "muxLeadPID": {
      "type": "object",
      "required": [
        "program_number",
        "pid",
        "stream_type",
        "label",
        "av_class",
        "status",
        "sample_count",
        "unbracketed_count",
        "dts_sample_count",
        "negative_count"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "stream_type": {
          "$ref": "#/$defs/streamType",
          "description": "The last stream_type the PMT announced for the PID."
        },
        "label": {
          "type": "string",
          "description": "video, audio or stream_type 0xNN, from stream_type (as for pes_headers)."
        },
        "av_class": {
          "$ref": "#/$defs/status",
          "description": "Class used for the A/V lead difference. Current values: video (stream_type 0x01, 0x02, 0x1B, 0x24), audio (0x03, 0x04, 0x0F, 0x11, 0x81, 0x87), other."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Not a verdict. Current values: info (at least one lead measured), insufficient_data (none)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data. Current values: no_pes, untrusted_payload, malformed_headers, no_pts, no_pcr_timing."
        },
        "sample_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PES packets with a valid header and a PTS whose lead was measured."
        },
        "unbracketed_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PES packets with a valid header and a PTS that do not lie between two PCRs of one segment (before the first or after the last PCR, across a PCR discontinuity, or without PCR); not measured."
        },
        "dts_sample_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Samples measured from their DTS; the others used the PTS."
        },
        "negative_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Samples with a negative lead (multiplexed after their DTS/PTS). An observation, not an error."
        },
        "min_lead_ms": {
          "type": "number",
          "description": "Smallest lead: DTS (PTS without DTS) minus the arrival time, modulo the PCR period and read as the signed value nearest to zero. Absent without samples."
        },
        "min_lead_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet with the smallest lead (the first of equal ones)."
        },
        "max_lead_ms": {
          "type": "number",
          "description": "Largest lead."
        },
        "max_lead_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the PES packet with the largest lead (the first of equal ones)."
        },
        "spread_ms": {
          "type": "number",
          "minimum": 0,
          "description": "max_lead_ms minus min_lead_ms."
        }
      }
    },
    "avLeadAudio": {
      "type": "object",
      "required": [
        "pid",
        "status",
        "comparison_count"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Not a verdict. Current values: info (compared at least once), insufficient_data."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data. Current value: no_comparable_leads (the audio and the program's video never had a lead in the same PCR segment at the same time)."
        },
        "comparison_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Comparisons of the audio lead with the program's video lead."
        },
        "video_pid": {
          "$ref": "#/$defs/pid",
          "description": "The program's video PID the largest difference was measured against."
        },
        "max_av_lead_difference_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Largest absolute difference between the most recent audio lead and the most recent video lead, evaluated whenever either got a new sample."
        },
        "audio_lead_ms": {
          "type": "number",
          "description": "The audio lead of that comparison."
        },
        "video_lead_ms": {
          "type": "number",
          "description": "The video lead of that comparison."
        },
        "audio_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the audio PES packet of that comparison."
        },
        "video_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the video PES packet of that comparison."
        }
      }
    },
    "avLeadProgram": {
      "type": "object",
      "required": [
        "program_number",
        "status",
        "audio"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Not a verdict. Current values: info (an audio PID was compared), insufficient_data."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "Present with insufficient_data. Current value: no_comparable_leads."
        },
        "audio_pid": {
          "$ref": "#/$defs/pid",
          "description": "The representative audio PID: the one with the largest difference (the lowest PID of equal ones). The difference fields below are its own; all are absent with insufficient_data."
        },
        "video_pid": {
          "$ref": "#/$defs/pid",
          "description": "The program's video PID the largest difference was measured against."
        },
        "max_av_lead_difference_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Largest absolute difference between the most recent audio lead and the most recent video lead, evaluated whenever either got a new sample."
        },
        "audio_lead_ms": {
          "type": "number",
          "description": "The audio lead of that comparison."
        },
        "video_lead_ms": {
          "type": "number",
          "description": "The video lead of that comparison."
        },
        "audio_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the audio PES packet of that comparison."
        },
        "video_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the video PES packet of that comparison."
        },
        "audio": {
          "type": "array",
          "description": "Every audio PID of the program, by PID, each compared with the program's video: its lowest-numbered video PID in the layout in force.",
          "items": {
            "$ref": "#/$defs/avLeadAudio"
          }
        }
      }
    },
    "psiHealth": {
      "type": "object",
      "required": [
        "status",
        "repetition_limit_ms",
        "time_base",
        "tables"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (every table ok), ng (at least one table ng), insufficient_data (no table ng, at least one without enough evidence)."
        },
        "repetition_limit_ms": {
          "type": "number",
          "description": "Longest allowed time between two tables: 500, from ETSI TR 101 290 V1.4.1 indicators 1.3.a (PAT_error_2) and 1.5.a (PMT_error_2). ISO/IEC 13818-1 sets no repetition interval."
        },
        "time_base": {
          "$ref": "#/$defs/psiTimeBase"
        },
        "tables": {
          "type": "array",
          "description": "The PAT first, then one entry per program_number announced in the range, in numeric order.",
          "items": {
            "$ref": "#/$defs/psiTableHealth"
          }
        }
      }
    },
    "psiTimeBase": {
      "type": "object",
      "required": [
        "status",
        "program_number",
        "segment_count"
      ],
      "description": "The PCR that times the intervals: the PCR_PID of the selected program, or with --output analysis of the first analyzed program that has one. Packet times are interpolated by byte position between the PCRs around them.",
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: pcr (at least two PCRs in one segment), none (no usable PCR time base)."
        },
        "program_number": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535
        },
        "pcr_pid": {
          "$ref": "#/$defs/pid",
          "description": "The last reference PCR_PID in effect, also after the reference program was removed by a later PAT; absent when the program never had one."
        },
        "segment_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PCR segments: every PCR step other than continuous and wraparound (declared, pcr_pid_change, backward, forward_jump), as for the other PCR-based results, starts a new one. No interval spans two segments."
        }
      }
    },
    "psiTableHealth": {
      "type": "object",
      "required": [
        "table",
        "pid",
        "status",
        "reasons",
        "instance_count",
        "version_change_count",
        "crc_error_count",
        "malformed_section_count",
        "incomplete_count",
        "wrong_table_id_count",
        "unusable_packet_count",
        "repetition"
      ],
      "properties": {
        "table": {
          "$ref": "#/$defs/status",
          "description": "Current values: pat, pmt."
        },
        "program_number": {
          "type": "integer",
          "minimum": 1,
          "maximum": 65535,
          "description": "For a PMT; absent for the PAT."
        },
        "pid": {
          "$ref": "#/$defs/pid",
          "description": "The table's PID; for a PMT moved by a PAT change, the latest one."
        },
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, ng (at least one reason), insufficient_data (no reason, but the repetition is not ok)."
        },
        "reasons": {
          "type": "array",
          "description": "Why the table is ng, in this order. Current values: missing, late, crc_error, malformed_section, incomplete, wrong_table_id, unusable_packets. Empty unless status is ng.",
          "items": {
            "$ref": "#/$defs/status"
          }
        },
        "announced_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "For a PMT: offset of the PAT packet that first announced the program. The PMT is read from the next packet."
        },
        "withdrawn_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "For a PMT: offset of the PAT packet from which the program is no longer listed; absent while it is listed."
        },
        "instance_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Complete current tables: every section of one version arrived valid. Counted at the packet that completes the table."
        },
        "first_instance_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Absent when instance_count is 0."
        },
        "version_change_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "crc_error_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "malformed_section_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "incomplete_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Collected sections discarded before the table completed, plus 1 when the range ends while a table that never completed is being collected."
        },
        "wrong_table_id_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Sections with a table_id other than 0x00 on PID 0x0000 (PAT only)."
        },
        "unusable_packet_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Packets of the table's PID not read because of transport_error_indicator or a scrambled payload."
        },
        "first_problem_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the earliest counted problem; absent without problem."
        },
        "repetition": {
          "$ref": "#/$defs/psiRepetition"
        }
      }
    },
    "psiRepetition": {
      "type": "object",
      "required": [
        "status",
        "interval_count",
        "late_interval_count"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok (at least one complete interval and none over the limit), late (an interval over the limit), insufficient_data (no complete interval), skipped (no PCR time base)."
        },
        "reason": {
          "$ref": "#/$defs/reasonCode",
          "description": "For insufficient_data: no_complete_interval. For skipped: no_pcr_time_base."
        },
        "interval_count": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Complete intervals: between two consecutive tables in one PCR segment."
        },
        "max_interval_ms": {
          "type": "number",
          "minimum": 0,
          "description": "Longest interval, complete or open. An open interval runs from the start of a segment (or the first PCR after the announcement) to the first table, or from the last table to the last PCR of the segment; it is a lower bound of the real interval. Absent when no interval was measured."
        },
        "max_interval_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Where the longest interval ends: the packet completing the table, or the last PCR of the segment for an open interval."
        },
        "late_interval_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "first_late_end_offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Where the first interval over the limit ends; absent without one."
        }
      }
    },
    "timestampAnomaly": {
      "type": "object",
      "required": [
        "pid",
        "kind",
        "count",
        "message"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "kind": {
          "type": "string",
          "description": "Current values: backward, wraparound, forward_gap, dts_after_pts."
        },
        "count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "timestampAnomalies": {
      "type": "object",
      "required": [
        "status",
        "items"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, anomalies."
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/timestampAnomaly"
          }
        }
      }
    },
    "pcrDiscontinuity": {
      "type": "object",
      "required": [
        "offset_bytes",
        "jump_ms",
        "from_segment",
        "to_segment"
      ],
      "properties": {
        "offset_bytes": {
          "type": "integer"
        },
        "kind": {
          "$ref": "#/$defs/status",
          "description": "Current values: declared, pcr_pid_change, backward, forward_jump. Added within schema 2.0."
        },
        "jump_ms": {
          "type": "number"
        },
        "from_segment": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "to_segment": {
          "$ref": "#/$defs/nonNegativeInteger"
        }
      }
    },
    "pcrJitter": {
      "type": "object",
      "description": "PCR jitter: an estimate, the delivery assessment that decides whether the estimate can be judged, and the resulting status.",
      "required": [
        "status",
        "estimate",
        "delivery"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, warning, ng (judged against ±500 ns / ±25 µs, only when delivery.assessment is constant), not_assessable (an estimate exists but delivery is not constant), skipped (no estimate could be made). skipped takes precedence over not_assessable."
        },
        "reason": {
          "type": "string",
          "description": "Human-readable explanation for skipped and not_assessable; not a stable matching interface."
        },
        "estimate": {
          "$ref": "#/$defs/pcrJitterEstimate"
        },
        "delivery": {
          "$ref": "#/$defs/pcrDelivery"
        }
      }
    },
    "pcrJitterEstimate": {
      "type": "object",
      "description": "The jitter estimated with one model. The value fields are present when the estimate was computed (status other than skipped).",
      "required": [
        "model",
        "pcr_pids",
        "sample_count",
        "segment_count",
        "observations",
        "discontinuities"
      ],
      "properties": {
        "model": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "Current values: byte_position (the expected PCR is interpolated from its neighbors by byte position, which assumes constant delivery)."
        },
        "pcr_pids": {
          "type": "array",
          "description": "PIDs the PCRs were taken from, in order of first appearance.",
          "items": {
            "$ref": "#/$defs/pid"
          }
        },
        "sample_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "segment_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "observations": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "PCRs with a neighbor on both sides in their segment, each giving one jitter value."
        },
        "max_abs_jitter_ns": {
          "type": "number",
          "minimum": 0,
          "description": "Largest |jitter|, the value the status is judged on."
        },
        "max_abs_jitter_offset_bytes": {
          "type": "integer"
        },
        "max_jitter_ns": {
          "type": "number"
        },
        "max_jitter_offset_bytes": {
          "type": "integer"
        },
        "min_jitter_ns": {
          "type": "number"
        },
        "min_jitter_offset_bytes": {
          "type": "integer"
        },
        "average_absolute_jitter_ns": {
          "type": "number",
          "minimum": 0
        },
        "within_500ns_percent": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "discontinuities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/pcrDiscontinuity"
          }
        }
      }
    },
    "pcrDelivery": {
      "type": "object",
      "description": "Whether the stream supports the constant-delivery premise of the byte_position model, from its multiplex rate over windows of at least window_seconds of PCR time.",
      "required": [
        "assessment",
        "reason",
        "window_seconds",
        "window_count",
        "tolerance_percent",
        "plausible_jitter_limit_ns"
      ],
      "properties": {
        "assessment": {
          "$ref": "#/$defs/status",
          "description": "Current values: constant, variable, unknown."
        },
        "reason": {
          "type": "string",
          "description": "Human-readable explanation of the assessment; not a stable matching interface."
        },
        "window_seconds": {
          "type": "integer",
          "minimum": 1
        },
        "window_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "average_rate_bps": {
          "type": "number",
          "minimum": 0,
          "description": "Multiplex rate over all windows (transport-stream bytes, all PIDs). Present when window_count > 0."
        },
        "min_window_rate_bps": {
          "type": "number",
          "minimum": 0
        },
        "max_window_rate_bps": {
          "type": "number",
          "minimum": 0
        },
        "max_deviation_percent": {
          "type": "number",
          "minimum": 0,
          "description": "Largest deviation of a window rate from average_rate_bps. Present when window_count >= 2."
        },
        "tolerance_percent": {
          "type": "number",
          "minimum": 0
        },
        "plausible_jitter_limit_ns": {
          "type": "number",
          "minimum": 0,
          "description": "A larger estimated |jitter| makes the delivery variable."
        }
      }
    },
    "bitratePID": {
      "type": "object",
      "required": [
        "pid",
        "label",
        "average_bps"
      ],
      "properties": {
        "pid": {
          "$ref": "#/$defs/pid"
        },
        "label": {
          "type": "string"
        },
        "average_bps": {
          "type": "number",
          "minimum": 0
        },
        "peak_1s_bps": {
          "type": "number",
          "minimum": 0
        }
      }
    },
    "bitrate": {
      "type": "object",
      "required": [
        "status",
        "duration_seconds",
        "segment_count",
        "pids",
        "program_average_bps"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: ok, skipped."
        },
        "reason": {
          "type": "string",
          "description": "Human-readable skip explanation; not a stable matching interface."
        },
        "duration_seconds": {
          "type": "number",
          "minimum": 0
        },
        "segment_count": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pids": {
          "type": "array",
          "description": "Selected-program PIDs included in program totals.",
          "items": {
            "$ref": "#/$defs/bitratePID"
          }
        },
        "null_pid": {
          "$ref": "#/$defs/bitratePID",
          "description": "Mux-wide NULL stuffing, excluded from program totals."
        },
        "program_average_bps": {
          "type": "number",
          "minimum": 0
        },
        "program_peak_1s_bps": {
          "type": "number",
          "minimum": 0
        }
      }
    },
    "psiTransition": {
      "type": "object",
      "description": "One applied PAT or PMT version change. The new layout applies to the packets after offset_bytes. PAT changes carry programs, programs_added, programs_removed and pmt_pid_changes; PMT changes carry program_number, previous_pcr_pid, pcr_pid, elementary_streams, elementary_streams_added, elementary_streams_removed and stream_type_changes.",
      "required": [
        "offset_bytes",
        "table",
        "pid",
        "previous_version",
        "version"
      ],
      "properties": {
        "offset_bytes": {
          "$ref": "#/$defs/nonNegativeInteger",
          "description": "Offset of the packet that completed the new table."
        },
        "table": {
          "$ref": "#/$defs/status",
          "description": "Current values: pat, pmt."
        },
        "pid": {
          "$ref": "#/$defs/pid",
          "description": "PID that carried the new table."
        },
        "previous_version": {
          "type": "integer",
          "minimum": 0,
          "maximum": 31
        },
        "version": {
          "type": "integer",
          "minimum": 0,
          "maximum": 31,
          "description": "Equal to previous_version only for the first PMT read from a PMT PID the program moved to, when its content differs."
        },
        "programs": {
          "type": "array",
          "description": "Every program of the new PAT.",
          "items": {
            "$ref": "#/$defs/patProgram"
          }
        },
        "programs_added": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/patProgram"
          }
        },
        "programs_removed": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/patProgram"
          }
        },
        "pmt_pid_changes": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "program_number",
              "previous_pmt_pid",
              "pmt_pid"
            ],
            "properties": {
              "program_number": {
                "$ref": "#/$defs/nonNegativeInteger"
              },
              "previous_pmt_pid": {
                "$ref": "#/$defs/pid"
              },
              "pmt_pid": {
                "$ref": "#/$defs/pid"
              }
            }
          }
        },
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "previous_pcr_pid": {
          "$ref": "#/$defs/pid"
        },
        "pcr_pid": {
          "$ref": "#/$defs/pid"
        },
        "elementary_streams": {
          "type": "array",
          "description": "Every elementary stream of the new PMT.",
          "items": {
            "$ref": "#/$defs/elementaryStream"
          }
        },
        "elementary_streams_added": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/elementaryStream"
          }
        },
        "elementary_streams_removed": {
          "type": "array",
          "description": "Removed streams with their previous stream_type.",
          "items": {
            "$ref": "#/$defs/elementaryStream"
          }
        },
        "stream_type_changes": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "pid",
              "previous_stream_type",
              "stream_type",
              "stream_type_description"
            ],
            "properties": {
              "pid": {
                "$ref": "#/$defs/pid"
              },
              "previous_stream_type": {
                "$ref": "#/$defs/streamType"
              },
              "stream_type": {
                "$ref": "#/$defs/streamType"
              },
              "stream_type_description": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "patProgram": {
      "type": "object",
      "required": [
        "program_number",
        "pmt_pid"
      ],
      "properties": {
        "program_number": {
          "$ref": "#/$defs/nonNegativeInteger"
        },
        "pmt_pid": {
          "$ref": "#/$defs/pid"
        }
      }
    },
    "failureCategory": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$",
      "description": "A --fail-on category. Current values, in their fixed order: timing, timestamp, pes_headers, pts_repetition, continuity, transport_errors, scrambled_packets, sync, psi_health, referenced_pids, unreferenced_pids."
    },
    "failurePolicy": {
      "type": "object",
      "required": [
        "status",
        "categories",
        "failed_categories"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/status",
          "description": "Current values: passed, failed (at least one selected category reported a finding; the command exits 2)."
        },
        "categories": {
          "type": "array",
          "description": "The selected categories, with any expanded, in their fixed order.",
          "items": {
            "$ref": "#/$defs/failureCategory"
          }
        },
        "failed_categories": {
          "type": "array",
          "description": "The selected categories that reported a finding, in their fixed order.",
          "items": {
            "$ref": "#/$defs/failureCategory"
          }
        }
      }
    },
    "warning": {
      "type": "object",
      "required": [
        "offset_bytes",
        "message"
      ],
      "properties": {
        "offset_bytes": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}
