Annotation of multiplexer/iso13818ts.1, revision 1.7

1.1       oskar       1: .\" Man page for iso13818ts
                      2: .\"
                      3: .\" Copyright (C) 2001, Convergence Integrated Media GmbH
                      4: .\" Author: Oskar Schirmer
                      5: .\"
                      6: .TH iso13818ts 1 "April 30th, 2001" "0.0.2" "Multiplexer"
                      7: .SH NAME
                      8: iso13818ts \- multiplexer for ISO 13818 transport streams
                      9: .SH SYNOPSIS
                     10: iso13818ts [COMMAND...]
                     11: .SH DESCRIPTION
                     12: Generates an ISO 13818-1 conforming transport stream from multiple
                     13: input streams.
                     14: The result is sent to \fIstdout\fR,
                     15: the input streams are read from explicitely opened files.
                     16: All of the following commands may also be fed to \fIstdin\fR during
                     17: operation by omitting the leading hyphen (e.g. \fBQ\fR) or
                     18: double-hyphen (e.g. \fBquit\fR).
                     19: .TP
                     20: \fB\-\-help\fR
                     21: Display this help.
                     22: .TP
                     23: \fB\-V\fR, \fB\-\-version\fR
                     24: Output version information.
                     25: .TP
                     26: \fB\-Q\fR, \fB\-\-quit\fR
                     27: Quit this program.
                     28: .TP
                     29: \fB\-v\fR, \fB\-\-verbose\fR [\fIlevel\fR]
                     30: Verbose mode, \fIlevel\fR = 0..6, default is 2 (providing warnings
                     31: concerning data errors), initial verbosity is 1 (providing only
                     32: program errors).
                     33: .TP
                     34: \fB\-p\fR, \fB\-\-pes\fR \fIfile\fR \fItarget_program\fR
                     35: Open a PES input \fIfile\fR,
                     36: output the contained stream as \fItarget_program\fR (range 0x0001..0xFFFF).
                     37: .TP
                     38: \fB\-p\fR, \fB\-\-pes\fR \fIfile\fR \fItarget_program\fR \fItarget_stream_id\fR
                     39: Open a PES input \fIfile\fR,
                     40: output the contained stream in \fItarget_program\fR (range 0x0001..0xFFFF)
                     41: with \fItarget_stream_id\fR (recommended range 0xBD..0xFE).
                     42: The \fIfile\fR may be specified as \fB=\fR to denote
                     43: the last previously mentioned file.
                     44: .TP
                     45: \fB\-P\fR, \fB\-\-ps\fR \fIfile\fR \fItarget_program\fR
                     46: Open a PS input \fIfile\fR,
                     47: output the contained program as \fItarget_program\fR (range 0x0001..0xFFFF).
                     48: .TP
                     49: \fB\-P\fR, \fB\-\-ps\fR \fIfile\fR \fItarget_program\fR \fIsource_stream_id\fR [\fItarget_stream_id\fR]
                     50: Open a PS input \fIfile\fR,
                     51: extract the stream with \fIsource_stream_id\fR (range 0x00..0xFF)
                     52: and output that stream in \fItarget_program\fR (range 0x0001..0xFFFF)
                     53: with \fItarget_stream_id\fR (recommended range 0xBD..0xFE).
                     54: If no \fItarget_stream_id\fR is given, \fIsource_stream_id\fR is used instead.
                     55: The \fIfile\fR may be specified as \fB=\fR to denote
                     56: the last previously mentioned file.
                     57: .TP
                     58: \fB\-T\fR, \fB\-\-ts\fR \fIfile\fR
                     59: Open a TS input \fIfile\fR,
                     60: extract all programs from it and output them.
                     61: Note, that additional SI data is not propagated,
                     62: see command \fB\-\-si\fR for further information.
                     63: .TP
                     64: \fB\-T\fR, \fB\-\-ts\fR \fIfile\fR \fIsource_program\fR [\fItarget_program\fR]
                     65: Open a TS input \fIfile\fR,
                     66: extract the program \fIsource_program\fR (range 0x0001..0xFFFF)
                     67: and output that program as \fItarget_program\fR (range 0x0001..0xFFFF).
                     68: If no \fItarget_program\fR is given,
                     69: don't change the \fIsource_program\fR number.
                     70: The \fIfile\fR may be specified as \fB=\fR to denote
                     71: the last previously mentioned file.
                     72: .TP
                     73: \fB\-T\fR, \fB\-\-ts\fR \fIfile\fR \fIsource_program\fR \fItarget_program\fR \fIsource_stream_id\fR [\fItarget_stream_id\fR]
                     74: Open a TS input \fIfile\fR,
                     75: extract the stream with \fIsource_stream_id\fR (range 0x00..0xFF)
                     76: from the program \fIsource_program\fR (range 0x0001..0xFFFF)
                     77: and output that stream as \fItarget_stream_id\fR (recommended range 0xBD..0xFE)
                     78: in program \fItarget_program\fR (range 0x0001..0xFFFF).
                     79: If no \fItarget_stream_id\fR is given, use \fIsource_stream_id\fR instead.
                     80: The \fIfile\fR may be specified as \fB=\fR to denote
                     81: the last previously mentioned file.
                     82: .TP
                     83: \fB\-c\fR, \fB\-\-close\fR \fIfile\fR
                     84: Close input \fIfile\fR, as if eof is reached.
                     85: In combination with \fB\-\-repeat\fR this causes the next repeatition
                     86: to start immediately.
                     87: Note, that the input data file is cut of as is, i.e. no attempt
                     88: is made to close the file on a clean audio or video frame border.
                     89: .TP
                     90: \fB\-a\fR, \fB\-\-append\fR \fIfile1\fR \fIfile2\fR [\fInum\fR]
                     91: Earmark another \fIfile2\fR to be opened as soon as \fIfile1\fR
                     92: comes to its end.
                     93: The appended \fIfile2\fR is foreseen to be repeated \fInum\fR
                     94: times, default is 1 (see \fB\-\-repeat\fR).
                     95: Both files must contain the same type of data,
                     96: as the data of both files is chained without considering clean
                     97: transition of audio or video sequences.
                     98: The \fIfile1\fR may be specified as \fB=\fR to denote
                     99: the last previously mentioned file.
                    100: .TP
                    101: \fB\-f\fR, \fB\-\-file\fR \fIreference_number\fR \fIfile_name\fR
                    102: The positive \fIreference_number\fR is associated with a \fIfile_name\fR.
                    103: For all following commands, the \fIreference_number\fR may be
                    104: used instead of the \fIfile_name\fR. This allows better control
                    105: over file handles, as the same file may be addressed via different
                    106: \fIreference_number\fRs.
                    107: .TP
                    108: \fB\-x\fR, \fB\-\-crop\fR \fItarget_program\fR [\fItarget_stream_id\fR]
                    109: Delete a stream given by \fItarget_stream_id\fR,
                    110: or a complete program given by \fItarget_program\fR
                    111: from the output.
                    112: The corresponding input file will be closed, if not needed otherwise.
                    113: .TP
                    114: \fB\-r\fR, \fB\-\-repeat\fR \fIfile\fR \fInum\fR
                    115: Set the repeatition counter for \fIfile\fR to \fInum\fR
                    116: (or to infinite if \fInum\fR=0).
                    117: The file will be reset as soon as eof is reached
                    118: (or it is closed by the command \fB\-\-close\fR).
                    119: Note, that the file will be reset without considering clean transition
                    120: of audio or video sequences at the restart point.
                    121: The \fIfile\fR may be specified as \fB=\fR to denote
                    122: the last previously mentioned file.
                    123: .TP
                    124: \fB\-R\fR, \fB\-\-reopen\fR
                    125: This command shall precede one of the commands that open a new file
                    126: (i.e. \fB\-\-pes\fR, \fB\-\-ps\fR or \fB\-\-ts\fR must follow
                    127: \fIon the same line\fR).
                    128: The next file will be opened with a new file handle,
                    129: regardless of whether the same file is yet open or not.
                    130: .TP
                    131: \fB\-\-si\fR \fIfile\fR [\fIlower_bound\fR \fIupper_bound\fR]
                    132: In a TS \fIfile\fR, all TS pakets with PID in the range
                    133: from \fIlower_bound\fR to \fIupper_bound\fR
                    134: (possible range 0x0000..0x1FFE, recommended range 0x10..0x1F)
                    135: inclusive are handled as SI pakets (according to ETSI EN 300 468).
                    136: These pakets are bypassed and promoted to the output without further handling.
                    137: If no further data from the \fIfile\fR is in use,
                    138: the SI pakets are promoted \fIgreedy\fR, i.e. without any timing or delay. 
                    139: If \fIlower_bound\fR and \fIupper_bound\fR are omitted,
                    140: the special handling of SI pakets is turned off for the given \fIfile\fR.
1.5       oskar     141: \fBNOTE, that the \fIfile\fB must be opened with \-\-ts before!\fR
1.1       oskar     142: The \fIfile\fR may be specified as \fB=\fR to denote
                    143: the last previously mentioned file.
                    144: .TP
                    145: \fB\-I\fR, \fB\-\-ident\fR \fItransport_stream_id\fR
                    146: Set the output \fItransport_stream_id\fR (range 0x0000..0xFFFF).
                    147: .TP
                    148: \fB\-B\fR, \fB\-\-busy\fR [\fInum\fR]
                    149: Set the busy flag to \fInum\fR (range 0..1, default is 1).
                    150: Whenever the program has no more data to handle and
                    151: the busy flag is not set, it stops.
                    152: .TP
                    153: \fB\-\-timed\fR
                    154: Force delay timing, even if solely disk files are in use.
                    155: If not so, if delay is to be awaited while processing regular files,
                    156: the delay is skipped instead and timing information in the resulting
                    157: file is adjusted accordingly.
                    158: .TP
                    159: \fB\-F\fR, \fB\-\-fpsi\fR \fItime\fR
                    160: Set the PSI table frequency to \fItime\fR msec
                    161: (or to infinite if \fItime\fR=0, initial value is infinite).
                    162: The PAT and PMT will be generated at more or less the given
                    163: frequency, even if the tables did not change.
                    164: In any case, the next tables will be generated immediately.
                    165: .TP
1.7     ! oskar     166: \fB\-\-trigin\fR \fItime\fR
        !           167: Set the input buffer trigger timing to \fItime\fR.
        !           168: For any input stream, that is newly opened
        !           169: (or has to be retriggered, e.g. due to intermediate emptiness),
        !           170: the buffer is triggered for promotion to the splice unit
        !           171: with a delay of \fItime\fR msec compared to the time
        !           172: of data entrance into the buffer.
        !           173: For any stream yet triggered the timing is not changed
        !           174: unless retriggering takes place.
        !           175: Not affected by this value are the other trigger conditions,
        !           176: mainly a certain buffer fullness
        !           177: and cotriggering with a corresponding stream that is triggered.
        !           178: .TP
        !           179: \fB\-\-trigout\fR \fItime\fR
        !           180: Set the output buffer trigger timing to \fItime\fR.
        !           181: As the output buffer is triggered for promotion to \fIstdout\fR,
        !           182: this is done with a delay of \fItime\fR msec compared to the time
        !           183: of data entrance into the buffer.
        !           184: The new timing is only valid if set before the first triggering
        !           185: of the output buffer,
        !           186: or if retriggering takes place, e.g. due to intermediate emptiness.
        !           187: Not affected by this value is the trigger condition
        !           188: of a certain buffer fullness.
        !           189: .TP
1.4       oskar     190: \fB\-C\fR, \fB\-\-config\fR \fInum\fR
                    191: Order output configuration of target stream with \fInum\fR=1,
                    192: switch off with \fInum\fR=0.
                    193: When switched on, the configuration is printed each time it changes.
                    194: First, the number of programs is printed,
                    195: then for each program one line of description and
                    196: for each stream within that program another line is printed.
                    197: The following values are compiled:
                    198: .RS
                    199: .TP
                    200: \fIprogs\fR
                    201: Number of programs in target stream.
                    202: .TP
                    203: \fIprog\fR
                    204: Program number within target stream.
                    205: .TP
                    206: \fIpmt\fR
                    207: PMT PID for the program.
                    208: .TP
                    209: \fIpcr\fR
                    210: PCR PID for the program.
                    211: .TP
                    212: \fIstreams\fR
                    213: Number of streams in the program.
                    214: .TP
                    215: \fIstream\fR
                    216: Stream PID.
                    217: .TP
                    218: \fIsid\fR
                    219: PES stream ID.
                    220: .TP
                    221: \fItype\fR
                    222: Stream type (according to ISO 13818-1 table 2-29).
                    223: .TP
                    224: \fIfile\fR
                    225: Source file contents type (PES=0, PS=1, TS=2).
                    226: .TP
                    227: \fIsource\fR
                    228: Stream index in source file (SID for PS, PID for TS).
                    229: .TP
                    230: \fInum\fR
                    231: Source file reference number (-1 if none).
                    232: .TP
                    233: \fIname\fR
                    234: Source file name.
                    235: .RE
                    236: .TP
1.2       oskar     237: \fB\-S\fR, \fB\-\-statistics\fR \fItime\fR
                    238: Order output load statistics to be generated about every
                    239: \fItime\fR msec.
1.4       oskar     240: Switch off with \fItime\fR=0.
                    241: The statistics are written to \fIstderr\fR linewise,
                    242: the following values are calculated:
1.2       oskar     243: .RS
                    244: .TP
                    245: \fInow\fR
                    246: Internal clock in msec.
                    247: .TP
                    248: \fIout\fR
1.7     ! oskar     249: Number of bytes written to stdout since last statistics,
        !           250: and number of write operations needed.
1.2       oskar     251: .TP
                    252: \fIbuf\fR
1.7     ! oskar     253: Number of bytes in the output buffers (lower and upper bound).
1.2       oskar     254: .TP
                    255: \fItime\fR
1.7     ! oskar     256: Time in msec, for how long the contents of the
        !           257: output buffers should suffice (lower and upper bound).
        !           258: .TP
        !           259: \fIburst\fR
        !           260: Size of write burst, i.e. number of bytes prepared to
        !           261: be written in a single write operation (lower and upper bound).
1.2       oskar     262: .RE
                    263: .TP
1.1       oskar     264: \fB\-\-badtiming\fR
                    265: In conjunction with a program stream originating from a DVB-s
                    266: digital TV receiver card, You might want to automatically
                    267: correct some of the PCR values produced by that card, to
                    268: prevent discontinuities in the output.
                    269: .SH OVERVIEW
                    270: The multiplexer is designed to run uninterrupted and
                    271: be controlled via \fIstdin\fR and \fIstderr\fR.
                    272: It may be invoked interactively with the streams to
                    273: process given as command line options or with
                    274: the commands to be processed typed into \fIstdin\fR
                    275: during operation.
                    276: The latter type of usage is also designed for use
                    277: with an user interface front-end, that may
                    278: translate some GUI input to iso13818ts commands
                    279: and filter its responses to be presented to the user
                    280: as appropriate.
                    281: .P
                    282: Three different types of input are supported:
                    283: Paketized elementary streams (PES),
                    284: Program streams (PS),
                    285: Transport streams (TS).
                    286: .P
                    287: Numeric parameters may be given in decimal (e.g. 31)
                    288: or in hex (e.g. 0x1F).
                    289: .SH DETAILS
                    290: The output file or device does not change throughout the
                    291: time the program runs. The input files, however, may vary.
                    292: Also the contents of an input file may vary, but not its
                    293: type. E.g., a file opened as program stream must contain
                    294: valid program stream data up to its end (and including
                    295: any files that are appended to this file with \fB\-\-append\fR).
                    296: .P
                    297: All basic PSI is evaluated contiguously, and changes in
                    298: the configuration (changing PID, etc.) are taken into
1.3       frankro   299: account and tracked. Thus a stream should not get lost
1.1       oskar     300: simply because its PID is changed in the middle of the
                    301: broadcast.
                    302: .P
                    303: When remultiplexing a transport stream, the user cannot
                    304: rely on the original PIDs to be the same in the output stream.
                    305: Usually output PIDs are different from input PIDs.
                    306: This is because all basic PSI is composed from scratch for the
                    307: output stream, with exception of the descriptors.
                    308: These are not evaluated but only copied and reused
                    309: as appropriate.
                    310: .P
                    311: For each output program one stream within this program
                    312: must contain PCR time stamps. The strategy in selecting
                    313: which stream shall carry the PCR is, first see if there
                    314: is one input stream that contains PCR, if none is found,
                    315: use the stream for which data packets are found first.
                    316: Note, that for a simple mono TV program this is not
                    317: necessarily the video stream.
                    318: .SH EXAMPLES
                    319: To convert a program stream file x.PS to a transport stream file x.TS,
                    320: with program number 42, transport stream id 23
                    321: and PAT and PMT generated about every half second:
                    322: .IP
                    323: $ iso13818ts --fpsi 500 --ident 23 --ps x.PS 42 > x.TS
                    324: .PP
                    325: If the program stream doesn't contain correct PSI,
                    326: the single streams may be extracted one by one. Assuming
                    327: one video stream (0xE0) and mono audio (0xC0):
                    328: .IP
1.7     ! oskar     329: $ iso13818ts --fpsi 500 --ident 23 --ps x.PS 42 0xE0 --ps = 42 0xC0 > x.TS
1.1       oskar     330: .PP
                    331: To bundle two streams originating from video devices and
                    332: send them out to a streaming device, e.g.:
                    333: .IP
                    334: $ iso13818ts -F 500 -P /dev/video0 0x7300 -P /dev/video1 0x7301 > /dev/xdvb0
                    335: .PP
                    336: To remultiplex a transport stream containing two TV programs
                    337: with program numbers 4711 and 4712, with the audio streams (0xC0)
                    338: of the TV programs exchanged:
                    339: .IP
                    340: $ iso13818ts -F 500 --file 1 /dev/rdvb0 --ts 1 4711 4711 0xE0 --ts 1 4712 4712 0xE0 --ts 1 4711 4712 0xC0 --ts 1 4712 4711 0xC0 > /dev/xdvb0
                    341: .PP
                    342: To invoke the multiplexer for interactive use, it must
                    343: be put in all-time-busy-mode. Subsequently, commands can
                    344: be fed to \fIstdin\fR, e.g. to do the same as with the
                    345: first example:
                    346: .IP
                    347: $ iso13818ts --busy > x.TS
                    348: .br
                    349: fpsi 500 ident 23
                    350: .br
                    351: ps x.PS 42
                    352: .PP
                    353: This instance of the multiplexer will not cease when the
                    354: end of file in x.PS is reached. To stop the multiplexer,
                    355: either \fBquit\fR or \fBbusy 0\fR may be typed to \fIstdin\fR.
                    356: .P
                    357: To output a movie repeatedly (e.g. seven times):
                    358: .IP
                    359: $ iso13818ts -F 500 --ps thepurpleroseofcairo.PS 777 --repeat = 7 > /dev/xdvb0
                    360: .PP
                    361: Note, that if during the movie is processed, the command
                    362: .IP
                    363: close thepurpleroseofcairo.PS
                    364: .PP
                    365: is issued, and supposed it is not yet processed the seventh time,
                    366: it is not closed, but restarted immediately.
                    367: .P
                    368: To concatenate two movies and output them in sequence:
                    369: .IP
                    370: $ iso13818ts -F 500 --ps rambo1.PS 789 --append = rambo2.PS > /dev/xdvb0
                    371: .PP
                    372: Note, that a file can only be appended to a file, that is
                    373: yet in use (i.e. being processed). Thus, it is not possible
                    374: to append a third movie (rambo3.PS) from within the command
                    375: line. Instead, the processing of the second movie must be
                    376: awaited, and then the following command can be fed to \fIstdin\fR:
                    377: .IP
                    378: append rambo2.PS rambo3.PS
                    379: .PP
                    380: To add data from a DSMCC carousel to the output, a DSMCC
                    381: carousel generator must be started seperately. The carousel
                    382: must generate the DSMCC data as a series of transport
                    383: stream packets that contain private sections. The PIDs used by
1.7     ! oskar     384: the carousel must be known (e.g. 0x10..0x1F). Supposed use of
        !           385: the DSMCC carousel data provider \fIrepeatts\fR:
1.1       oskar     386: .IP
                    387: $ mkfifo dsmcc_pipe
                    388: .br
1.7     ! oskar     389: $ repeatts 8000 2000 dsmcc_data.TS > dsmcc_pipe &
1.1       oskar     390: .br
                    391: $ iso13818ts -F 500 --busy --ts dsmcc_pipe --si = 0x10 0x1F > /dev/xdvb0
                    392: .br
                    393: ps x.PS 42
                    394: .br
                    395: ps y.PS 43
                    396: .br
                    397: \&...
                    398: .PP
                    399: .SH "KNOWN PROBLEMS"
                    400: The program might not work in conjunction with device drivers
                    401: that do not deliver or accept data unless a first read or write
                    402: is done on the device. E.g., for a MPEG video data source, that
                    403: does not produce output without being triggered by being read
                    404: from, this program will await the readability of the first
                    405: data infinitely. On the other hand it is obvious that the driver
                    406: should not encode data as long as there is no application that
                    407: will read this data.
                    408: One possibly solution to this dilemma is to patch such a driver
                    409: to interpret the \fIpoll\fR command as an order for data, thus
                    410: triggering the read mechanisms. Analogous considerations hold
                    411: for polling the output device and writing to it.
                    412: .P
                    413: Paketized elementary streams do not necessarily contain
                    414: usable time stamps, so when multiplexing raw PES, streams
                    415: belonging together may be out of sync. This is especially
                    416: noteworthy in case streams shall be demultiplexed and then
                    417: again multiplexed in some way. Results will always be better
                    418: when this remultiplexing takes place entirely within the
1.3       frankro   419: multiplexer, because that way timing information won't get lost.
1.1       oskar     420: .SH BUGS
                    421: Non-ISO_13818-1 descriptors (private descriptors) in
                    422: ISO_13818-1 PSI sections are not promoted.
                    423: .SH "SEE ALSO"
1.6       oskar     424: .BR repeatts (1),
                    425: .BR iso13818ps (1),
1.1       oskar     426: .BR ISO\ 13818-1 ,
                    427: .BR ETSI\ EN\ 300\ 468 .
                    428: .SH AUTHOR
                    429: Oskar Schirmer (oskar@convergence.de).

LinuxTV legacy CVS <linuxtv.org/cvs>