//----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2025, Thierry Lelegard
// BSD-2-Clause license, see LICENSE.txt file or https://tsduck.io/license
//
//----------------------------------------------------------------------------

<<<
=== continuity

[.cmd-header]
Check continuity counters

This plugin checks the continuity counters on TS packets, PID per PID.

[.usage]
Usage

[source,shell]
----
$ tsp -P continuity [options]
----

[.usage]
Options

[.opt]
*-f* +
*--fix*

[.optdoc]
Fix incorrect continuity counters.
By default, only display discontinuities.

[.optdoc]
*Warning*: Make sure that "fixing" the continuity counters is really what you want to do.
If the input file is corrupted with missing packets, this plugin cannot restore the content of the missing packets.
Non-contiguous continuity counters are here to inform the video player that TS packets are missing and the PES content is probably corrupted.
If you use `--fix`, the continuity counters will become continuous again but the PES content remains corrupted
because some binary data are still missing.
The difference is that the media player will not be informed that the PES content is corrupted.
Make sure that this is what you want to do.

[.opt]
**--json-line**__[='prefix']__

[.optdoc]
Report the continuity information as one single line in JSON format.

[.optdoc]
The optional string parameter specifies a prefix to prepend on the log line before the JSON text
to facilitate the filtering of the appropriate line in the logs.

[.opt]
*--no-replicate-duplicated*

[.optdoc]
Two successive packets in the same PID are considered as duplicated
if they have the same continuity counter and same content (except PCR, if any).

[.optdoc]
By default, with `--fix`, duplicated input packets are replicated as duplicated on output
(the corresponding output packets have the same continuity counters).

[.optdoc]
When this option is specified, the input packets are not considered as duplicated
and the output packets receive individually incremented countinuity counters.

[.opt]
*-p* _pid1[-pid2]_ +
*--pid* _pid1[-pid2]_

[.optdoc]
Check or fix continuity counters only in packets with these PID values.

[.optdoc]
Several `--pid` options may be specified.
By default, all PID's are checked or fixed.

[.opt]
*-t* _"string"_ +
*--tag* _"string"_

[.optdoc]
Message tag to be displayed when packets are missing.
Useful when the plugin is used several times in the same command line.

include::{docdir}/opt/group-common-plugins.adoc[tags=!*]
