gaspard7/wiki_gpac huggingface dataset:
Naming of PIDs

For simple filter graphs with only one input and one output, the input PID is assigned the avfilter name `in` and the output PID is assigned the avfilter name `out`  
  
When a graph has several inputs, input PID names shall be assigned by the user using the `ffid` property, and mapping must be done in the filter.  
Example
```
gpac -i video:#ffid=a -i logo:#ffid=b ffavf::f=[a][b]overlay=main_w-overlay_w-10:main_h-overlay_h-10 vout
```
  
In this example:  

- the video source is identified as `a`  
- the logo source is identified as `b`  
- the filter declaration maps `a` to its first input (in this case, main video) and `b` to its second input (in this case the overlay)  

  
When a graph has several outputs, output PIDs will be identified using the `ffid` property set to the output avfilter name.  
Example
```
gpac -i source ffavf::f=split inspect:SID=#ffid=out0 vout#SID=out1
```
  
In this example:  

- the splitter produces 2 video streams `out0` and `out1`  
- the inspector only process stream with ffid `out0`  
- the video output only displays stream with ffid `out1`  

  
The name(s) of the final output of the avfilter graph cannot be configured in GPAC. You can however name intermediate output(s) in a complex filter chain as usual.
Options  {.no-collapse}

<div markdown class="option">  
<a id="f" data-level="basic">__f__</a> (str): filter or filter chain description  
</div>  
<div markdown class="option">  
<a id="pfmt" data-level="basic">__pfmt__</a> (pfmt, default: _none_): pixel format of output. If not set, let AVFilter decide  
</div>  
<div markdown class="option">  
<a id="afmt" data-level="basic">__afmt__</a> (afmt, default: _none_): audio format of output. If not set, let AVFilter decide  
</div>  
<div markdown class="option">  
<a id="sr" data-level="basic">__sr__</a> (uint, default: _0_): sample rate of output. If not set, let AVFilter decide  
</div>  
<div markdown class="option">  
<a id="ch" data-level="basic">__ch__</a> (uint, default: _0_): number of channels of output. If not set, let AVFilter decide  
</div>  
<div markdown class="option">  
<a id="dump" data-level="basic">__dump__</a> (bool, default: _false_, updatable): dump graph as log media@info or stderr if not set  
</div>  
<div markdown class="option">  
<a id="*" data-level="basic">__*__</a> (str): any possible options defined for AVFilter and sub-classes (see `gpac -hx ffavf` and `gpac -hx ffavf:*`)  
</div>
TTML decoder

Register name used to load filter: __ttmldec__  
This filter may be automatically loaded during graph resolution.  
  
This filter decodes TTML streams into a SVG scene graph of the compositor filter.  
The scene graph creation is done through JavaScript.  
The filter options are used to override the JS global variables of the TTML renderer.  
  
In stand-alone rendering (no associated video), the filter will use:  

- `Width` and `Height` properties of input pid if any  
- otherwise, `osize` option of compositor if set  
- otherwise, [txtw](#txtw) and [txth](#txth)
Options  {.no-collapse}

<div markdown class="option">  
<a id="script">__script__</a> (str, default: _$GSHARE/scripts/ttml-renderer.js_): location of TTML SVG JS renderer  
</div>  
<div markdown class="option">  
<a id="font">__font__</a> (str, default: _SANS_, updatable): font  
</div>  
<div markdown class="option">  
<a id="fontSize">__fontSize__</a> (flt, default: _20_, updatable): font size  
</div>  
<div markdown class="option">  
<a id="color">__color__</a> (str, default: _white_, updatable): text color  
</div>  
<div markdown class="option">  
<a id="valign">__valign__</a> (enum, default: _bottom_, updatable): vertical alignment  

- bottom: align text at bottom of text area  
- center: align text at center of text area  
- top: align text at top of text area  
</div>  
  
<div markdown class="option">  
<a id="lineSpacing">__lineSpacing__</a> (flt, default: _1.0_, updatable): line spacing as scaling factor to font size  
</div>  
<div markdown class="option">  
<a id="txtw">__txtw__</a> (uint, default: _400_): default width in standalone rendering  
</div>  
<div markdown class="option">  
<a id="txth">__txth__</a> (uint, default: _200_): default height in standalone rendering  
</div>
Stream unframer

Register name used to load filter: __unframer__  
This filter is not checked during graph resolution and needs explicit loading.  
  
This filter is used to force reframing of input sources using the same internal framing as GPAC (e.g. ISOBMFF) but with broken framing or signaling.  
Example
```
gpac -i src.mp4 unframer -o dst.mp4
```
  
This will:  

- force input PIDs of unframer to be in serialized form (AnnexB, ADTS, ...)  
- trigger reframers to be instanciated after the `unframer` filter.  

Using the unframer filter avoids doing a dump to disk then re-import or other complex data piping.  
  
No options
Output size assignment

If [osize](#osize) is {0,0}, the output dimensions will be set to the input size, and input aspect ratio will be ignored.  
  
If [osize](#osize) is {0,H} (resp. {W,0}), the output width (resp. height) will be set to respect input aspect ratio. If [keepar=nosrc](#keepar=nosrc), input sample aspect ratio is ignored.
Aspect Ratio and Sample Aspect Ratio

When output sample aspect ratio is set, the output dimensions are divided by the output sample aspect ratio.  
Example
```
ffsws:osize=288x240:osar=3/2
```
  
The output dimensions will be 192x240.  
  
When aspect ratio is not kept ([keepar=off](#keepar=off)):  

- source is resampled to desired dimensions  
- if output aspect ratio is not set, output will use source sample aspect ratio  

  
When aspect ratio is partially kept ([keepar=nosrc](#keepar=nosrc)):  

- resampling is done on the input data without taking input sample aspect ratio into account  
- if output sample aspect ratio is not set ([osar=0/N](#osar=0/N)), source aspect ratio is forwarded to output.  

  
When aspect ratio is fully kept ([keepar=full](#keepar=full)), output aspect ratio is force to 1/1 if not set.  
  
When sample aspect ratio is kept, the filter will:  

- center the rescaled input frame on the output frame  
- fill extra pixels with [padclr](#padclr)
Algorithms options

- for bicubic, to tune the shape of the basis function, [p1](#p1) tunes f(1) and [p2](#p2) f´(1)  
- for gauss [p1](#p1) tunes the exponent and thus cutoff frequency  
- for lanczos [p1](#p1) tunes the width of the window function  

  
See FFmpeg documentation (https://ffmpeg.org/documentation.html) for more details
Options  {.no-collapse}

<div markdown class="option">  
<a id="osize" data-level="basic">__osize__</a> (v2di): osize of output video  
</div>  
<div markdown class="option">  
<a id="ofmt" data-level="basic">__ofmt__</a> (pfmt, default: _none_, Enum: none|yuv420|yvu420|yuv420_10|yuv422|yuv422_10|yuv444|yuv444_10|uyvy|vyuy|yuyv|yvyu|uyvl|vyul|yuyl|yvyl|nv12|nv21|nv1l|nv2l|yuva|yuvd|yuv444a|yuv444p|v308|yuv444ap|v408|v410|v210|grey|algr|gral|rgb4|rgb5|rgb6|rgba|argb|bgra|abgr|rgb|bgr|xrgb|rgbx|xbgr|bgrx|rgbd|rgbds|uncv): pixel format for output video. When not set, input format is used  
</div>  
  
<div markdown class="option">  
<a id="scale">__scale__</a> (enum, default: _bicubic_): scaling mode (see filter help) (fastbilinear|bilinear|bicubic|X|point|area|bicublin|gauss|sinc|lanzcos|spline)  
</div>  
  
<div markdown class="option">  
<a id="p1">__p1__</a> (dbl, default: _+I_): scaling algo param1  
</div>  
<div markdown class="option">  
<a id="p2">__p2__</a> (dbl, default: _+I_): scaling algo param2  
</div>  
<div markdown class="option">  
<a id="ofr">__ofr__</a> (bool, default: _false_): force output full range  
</div>  
<div markdown class="option">  
<a id="brightness">__brightness__</a> (bool, default: _0_): 16.16 fixed point brightness correction, 0 means use default  
</div>  
<div markdown class="option">  
<a id="contrast">__contrast__</a> (uint, default: _0_): 16.16 fixed point brightness correction, 0 means use default  
</div>  
<div markdown class="option">  
<a id="saturation">__saturation__</a> (uint, default: _0_): 16.16 fixed point brightness correction, 0 means use default  
</div>  
<div markdown class="option">  
<a id="otable">__otable__</a> (sintl): the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x], use default if not set  
</div>  
<div markdown class="option">  
<a id="itable">__itable__</a> (sintl): the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x], use default if not set  
</div>  
<div markdown class="option">  
<a id="keepar">__keepar__</a> (enum, default: _off_): keep aspect ratio  

- off: ignore aspect ratio  
- full: respect aspect ratio, applying input sample aspect ratio info  
- nosrc: respect aspect ratio but ignore input sample aspect ratio  
</div>  
  
<div markdown class="option">  
<a id="padclr">__padclr__</a> (str, default: _black_): clear color when aspect ration preservation is used  
</div>  
<div markdown class="option">  
<a id="osar">__osar__</a> (frac, default: _0/1_): force output pixel aspect ratio  
</div>
Options  {.no-collapse}

<div markdown class="option">  
<a id="cdur" data-level="basic">__cdur__</a> (frac, default: _1/10_): stream interleaving duration in seconds  
</div>  
<div markdown class="option">  
<a id="rcfg" data-level="basic">__rcfg__</a> (frac, default: _0/1_): stream config re-injection frequency in seconds  
</div>
Options  {.no-collapse}

<div markdown class="option">  
<a id="rcfg" data-level="basic">__rcfg__</a> (bool, default: _true_): force repeating decoder config at each I-frame  
</div>  
<div markdown class="option">  
<a id="extract">__extract__</a> (enum, default: _all_): layer extraction mode  

- all: extracts all layers  
- base: extract base layer only  
- layer: extract non-base layer(s) only  
</div>  
  
<div markdown class="option">  
<a id="delim">__delim__</a> (bool, default: _true_): insert AU Delimiter NAL  
</div>  
<div markdown class="option">  
<a id="pps_inband" data-level="basic">__pps_inband__</a> (bool, default: _false_): inject PPS at each non SAP frame, ignored if rcfg is not set  
</div>
Options  {.no-collapse}

<div markdown class="option">  
<a id="js" data-level="basic">__js__</a> (cstr): location of script source  
</div>  
<div markdown class="option">  
<a id="*" data-level="basic">__*__</a> (str): any possible options defined for the script (see `gpac -hx jsf:js=$YOURSCRIPT` or `gpac -hx $YOURSCRIPT`)  
</div>
GSF Multiplexer

Register name used to load filter: __gsfmx__  
This filter may be automatically loaded during graph resolution.  
  
This filter provides GSF (_GPAC Serialized Format_) multiplexing.  
It serializes the stream states (config/reconfig/info update/remove/eos) and packets of input PIDs. This allows either saving to file a session, or forwarding the state/data of streams to another instance of GPAC using either pipes or sockets. Upstream events are not serialized.  
  
The default behavior does not insert sequence numbers. When running over general protocols not ensuring packet order, this should be inserted.  
The serializer sends tune-in packets (global and per PID) at the requested carousel rate - if 0, no carousel. These packets are marked as redundant so that they can be discarded by output filters if needed.
Encryption

The stream format can be encrypted in AES 128 CBC mode. For all packets, the packet header (header, size, frame size/block offset and optional seq num) are in the clear and the following bytes until the last byte of the last multiple of block size (16) fitting in the payload are encrypted.  
For data packets, each fragment is encrypted individually to avoid error propagation in case of losses.  
For other packets, the entire packet is encrypted before fragmentation (fragments cannot be processed individually).  
For header/tunein packets, the first 25 bytes after the header are in the clear (signature,version,IV and pattern).  
The [IV](#IV) is constant to avoid packet overhead, randomly generated if not set and sent in the initial stream header. Pattern mode can be used (cf CENC cbcs) to encrypt K block and leave N blocks in the clear.
Filtering properties

The header/tunein packet may get quite big when all PID properties are kept. In order to help reduce its size, the [minp](#minp) option can be used: this will remove all built-in properties marked as droppable (cf property help) as well as all non built-in properties.  
The [skp](#skp) option may also be used to specify which property to drop:  
Example
```
skp="4CC1,Name2
```
  
This will remove properties of type `4CC1` and properties (built-in or not) of name `Name2`.
File mode

By default the filter only accepts framed media streams as input PID, not files. This can be changed by explicitly loading the filter with [ext](#ext) or [dst](#dst) set.  
Example
```
gpac -i source.mp4 gsfmx:dst=manifest.mpd -o dump.gsf
```
  
This will DASH the source and store every files produced as PIDs in the GSF mux.  
In order to demultiplex such a file, the `gsfdmx`filter will likely need to be explicitly loaded:  
Example
```
gpac -i mux.gsf gsfdmx -o dump/$File$:dynext
```
  
This will extract all files from the GSF mux.  
  
By default when working in file mode, the filter only accepts PIDs of type `file` as input.  
To allow a mix of files and streams, use [mixed](#mixed):  
Example
```
gpac -i source.mp4 gsfmx:dst=manifest.mpd:mixed -o dump.gsf
```
  
This will DASH the source, store the manifest file and the media streams with their packet properties in the GSF mux.
Options  {.no-collapse}

<div markdown class="option">  
<a id="sigsn" data-level="basic">__sigsn__</a> (bool, default: _false_): signal packet sequence number after header field and before size field. Sequence number is per PID, encoded on 16 bits. Header packet does not have a SN  
</div>  
<div markdown class="option">  
<a id="sigdur">__sigdur__</a> (bool, default: _true_): signal duration  
</div>  
<div markdown class="option">  
<a id="sigbo">__sigbo__</a> (bool, default: _false_): signal byte offset  
</div>  
<div markdown class="option">  
<a id="sigdts">__sigdts__</a> (bool, default: _true_): signal decoding timestamp  
</div>  
<div markdown class="option">  
<a id="dbg">__dbg__</a> (enum, default: _no_): set debug mode  

- no: disable debug  
- nodata: force packet size to 0  
- nopck: skip packet  
</div>  
  
<div markdown class="option">  
<a id="key" data-level="basic">__key__</a> (mem): encrypt packets using given key  
</div>  
<div markdown class="option">  
<a id="IV" data-level="basic">__IV__</a> (mem): set IV for encryption - a constant IV is used to keep packet overhead small (cbcs-like)  
</div>  
<div markdown class="option">  
<a id="pattern">__pattern__</a> (frac, default: _1/0_): set nb_crypt / nb_skip block pattern. default is all encrypted  
</div>  
<div markdown class="option">  
<a id="mpck">__mpck__</a> (uint, default: _0_): set max packet size. 0 means no fragmentation (each AU is sent in one packet)  
</div>  
<div markdown class="option">  
<a id="magic">__magic__</a> (str): magic string to append in setup packet  
</div>  
<div markdown class="option">  
<a id="skp">__skp__</a> (str): comma separated list of PID property names to skip  
</div>  
<div markdown class="option">  
<a id="minp">__minp__</a> (bool, default: _false_): include only the minimum set of properties required for stream processing  
</div>  
<div markdown class="option">  
<a id="crate">__crate__</a> (dbl, default: _0_): carousel period for tune-in info in seconds  
</div>  
<div markdown class="option">  
<a id="ext">__ext__</a> (str): file extension for file mode  
</div>  
<div markdown class="option">  
<a id="dst">__dst__</a> (str): target URL in file mode  
</div>  
<div markdown class="option">  
<a id="mixed">__mixed__</a> (bool, default: _false_): allow GSF to contain both files and media streams  
</div>
Options  {.no-collapse}

<div markdown class="option">  
<a id="sr" data-level="basic">__sr__</a> (uint, default: _44100_): sample rate  
</div>  
<div markdown class="option">  
<a id="safmt" data-level="basic">__safmt__</a> (afmt, default: _none_, Enum: none|u8|s16|s16b|s24|s24b|s32|s32b|flt|fltb|dbl|dblb|u8p|s16p|s24p|s32p|fltp|dblp): audio format  
</div>  
  
<div markdown class="option">  
<a id="ch" data-level="basic">__ch__</a> (uint, default: _2_): number of channels  
</div>  
<div markdown class="option">  
<a id="framelen">__framelen__</a> (uint, default: _1024_): number of samples to put in one audio frame. For planar formats, indicate plane size in samples  
</div>
Audio Video Mixer

Register name used to load filter: __avmix__  
This is a JavaScript filter. It is not checked during graph resolution and needs explicit loading.  
Author: GPAC team  
  
AVMix is an audio video mixer controlled by an updatable JSON playlist format. The filter can be used to:  

- schedule video sequence(s) over time  
- mix videos together  
- layout of multiple videos  
- overlay images, text and graphics over source videos  

  
All input streams are decoded prior to entering the mixer.  

- audio streams are mixed in software  
- video streams are composed according to the `gpu` option  
- other stream types are not yet supported  

  
OpenGL hardware acceleration can be used, but the supported feature set is currently not the same with or without GPU.  
  
In software mode, the mixer will detect whether any of the currently active video sources can be used as a base canvas for the output to save processing time.  
The default behavior is to do this detection only at the first generated frame, use `dynpfmt` to modify this.  
  
The filter can be extended through JavaScript modules. Currently only scenes and transition effects use this feature.
Live vs offline

When operating offline, the mixer will wait for video frames to be ready for 10 times `lwait`. After this timeout, the filter will abort if no input is available.  
This implies that there shall always be a media to compose, i.e. no "holes" in the timeline.  
_Note: The playlist is still refreshed in offline mode._  
  
When operating live, the mixer will initially wait for video frames to be ready for `lwait` seconds. After this initial timeout, the output frames will indicate:  

- 'No signal' if no input is available (no source frames) or no scene is defined  
- 'Signal lost' if no new input data has been received for `lwait` on a source
Overview

The main components in a playlist are:  

- Media sources and sequences: each source is described by one or more URL to the media data, and each sequence is a set of sources to be played continuously   
- Transitions: sources in a sequence can be combined using transitions  
- Scenes: a scene describes one graphical object to put on screen and if and how input video are mapped on objects  
- Groups: a group is a hierarchy of scenes and groups with positioning properties, and can also be used to create offscreen images reused by other elements  
- Timers: a timer can be used to animate scene parameters in various fashions  

  
The playlist content shall be either a single JSON object or an array of JSON objects, hereafter called root objects.  
Root objects types can be indicated through a `type` property:  

- seq: a `sequence` object  
- url: a `source` object (if used as root, a default `sequence` object will be created)  
- scene: a `scene` object  
- group: a `group` object  
- timer: a `timer` object  
- script: a `script` object  
- config: a `config` object  
- watch: a `watcher` object  
- style: a `style` object  

  
Except for `style`, the `type` property of root objects is usually not needed as the parser guesses the object types from its properties.  
  
A root object with a property `skip` set to anything but `0` or `false` is ignored.  
Within a `group` hierarchy, any `scene` or `group` object with a property `skip` set to anything but `0` or `false` is ignored.  
  
Any unrecognized property not starting with `_` will be reported as warning.
Colors

Colors are handled as strings, formatted as:  

- the DOM color name (see `gpac -h colors`)  
- HTML codes `$RRGGBB` or `#RRGGBB`  
- RGB hex vales `0xRRGGBB`  
- RGBA hex values `0xAARRGGBB`  
- the color `none` is `0x00000000`, its signification depends on the object using it.  

  
If JS code needs to manipulate colors, use sys.color_lerp and sys.color_component functions.
Sequences

### Properties for `sequence` objects:  
  

    - id (null): sequence identifier  
    - loop (0): number of loops for the sequence (0 means no loop, -1 will loop forever)  
    - start (0): sequence start time (see notes). If negative, the sequence is not active  
    - stop (0): sequence stop time (see notes). If less than `start`, the sequence will stop only when over  
    - transition (null): a `transition` object to apply between sources of the sequence  
    - seq ([]): array of one or more `source` objects  

  
### Notes  
  
Media source timing does not depend on the media being used by a scene or not, it is only governed by the `sequence` parameters.  
This means that a `sequence` not used by any active scene will not be rendered (video nor audio).  
  
The syntax for `start` and  `stop` fields is:  

- `now`: resolves to current UTC clock in `live` mode, and to 0 for non-live mode  
- date: converted to UTC date in `live` mode, and to 0 for non-live mode  
- N: converted to current utc clock (or 0 for non-live mode) plus N seconds UTC  
- "N": converted to current utc clock (or 0 for non-live mode) plus N seconds UTC  

  
In 'live' mode, if `start` is set using a UTC date, the sequence will have a start range equal to `MAX(current_UTC - start_in_UTC, 0)`. Some sources may be skipped to fulfill this condition.  
This allows different instances of the filter using the same playlist to initialize media time in the same fashion.  
  
When reloading the playlist:  

- if the sequence is active, `start` value is ignored   
- if the sequence was not started, `start` value is updated   
- if the sequence was over, `start` value is updated only of greater than previous resolved UTC start time.
Sources

### Properties for `source` objects  
  

- id (null): source identifier, used when reloading the playlist  
- src ([]): list of `sourceURL` describing the URLs to play. Multiple sources will be played in parallel  
- start (0.0): media start time in source  
- stop (0.0): media stop time in source, ignored if less than or equal to `start`  
- mix (true): if true, apply sequence transition or mix effect ratio as audio volume. Otherwise volume is not modified by transitions.  
- fade ('inout'): indicate how audio should be faded at stream start/end:  

    - in: audio fade-in when playing first frame  
    - out: audio fade-out when playing last frame  
    - inout: both fade-in and fade-out are enabled  
    - other: no audio fade  

- keep_alive (false): if using a dedicated gpac process for one or more input, relaunch process(es) at source end if exit code is greater than 2 or if not responding after `rtimeout`  
- seek (false): if true and `keep_alive` is active, adjust `start` according to the time elapsed since source start when relaunching process(es)  
- prefetch (500): prefetch duration in ms (play before start time of source), 0 for no prefetch  
- hold (false): if media duration is known and media stop time is greater than media duration, activate no signal mode until desired stop time is reached (disable transition), otherwise move to next source at end of stream