Skip to content

gpac_general

Romain Bouqueau edited this page Mar 5, 2024 · 109 revisions

Warning

GPAC's wiki has moved to wiki.gpac.io.

This github wiki will no longer be updated.

You can contribute to GPAC's documentation here.

General Usage of gpac

Usage: gpac [options] FILTER [LINK] FILTER [...]
gpac is GPAC's command line tool for setting up and running filter chains.

FILTER: a single filter declaration (e.g., -i file, -o dump, inspect, ...), see gpac -h doc.
[LINK]: a link instruction (e.g., @, @2, @2#StreamType=Visual, ...), see gpac -h doc.
[options]: one or more option strings, each starting with a - character.

  • an option using a single - indicates an option of gpac (see gpac -hx) or of libgpac (see gpac -hx core)
  • an option using -- indicates a global filter or meta-filter (e.g. FFMPEG) option, e.g. --block_size=1000 or --profile=Baseline (see gpac -h doc)

Filter declaration order may impact the link resolver which will try linking in declaration order. Most of the time for simple graphs, this has no impact. However, for complex graphs with no link declarations, this can lead to different results.
Options do not require any specific order, and may be present anywhere, including between link statements or filter declarations.
Boolean values do not need any value specified. Other types shall be formatted as opt=val, except -i, -src, -o, -dst and -h options.

The session can be interrupted at any time using ctrl+c, which can also be used to toggle global reporting.

The possible options for gpac are:

-mem-track: enable memory tracker
-mem-track-stack: enable memory tracker with stack dumping
-ltf: load test-unit filters (used for for unit tests only)
-sloop (int): loop execution of session, creating a session at each loop, mainly used for testing. If no value is given, loops forever
-runfor (int): run for the given amount of milliseconds, exit with full session flush
-runforf (int): run for the given amount of milliseconds, exit with fast session flush
-runforx (int): run for the given amount of milliseconds and exit with no cleanup
-runfors (int): run for the given amount of milliseconds and exit with segfault (tests)
-runforl (int): run for the given amount of milliseconds and wait forever at end (tests)
-stats: print stats after execution
-graph: print graph after execution
-qe: enable quick exit (no mem cleanup)
-k: enable keyboard interaction from command line
-r (string): enable reporting

  • r: runtime reporting
  • r=FA[,FB]: runtime reporting but only print given filters, e.g. r=mp4mx for ISOBMFF multiplexer only
  • r=: only print final report

-seps (string, default: :=#,!@): set the default character sets used to separate various arguments

  • the first char is used to separate argument names
  • the second char, if present, is used to separate names and values
  • the third char, if present, is used to separate fragments for PID sources
  • the fourth char, if present, is used for list separators (sourceIDs, gfreg, ...)
  • the fifth char, if present, is used for boolean negation
  • the sixth char, if present, is used for LINK directives (see filters help (-h doc))

-i,-src (string): specify an input file - see filters help (-h doc)

-o,-dst (string): specify an output file - see filters help (-h doc)

-ib (string): specify an input file to wrap as GF_FileIO object (testing of GF_FileIO)
-ibx (string): specify an input file to wrap as GF_FileIO object without caching (testing of GF_FileIO)
-ob (string): specify an output file to wrap as GF_FileIO object (testing of GF_FileIO)
-cl: force complete mode when no link directive are set - see filters help (-h doc)

-step: test step mode in non-blocking session
-h,-help,-ha,-hx,-hh (string): print help. Use -help or -h for basic options, -ha for advanced options, -hx for expert options and -hh for all.
Note: The @ character can be used in place of the * character. String parameter can be:

  • empty: print command line options help
  • doc: print the general filter info
  • alias: print the gpac alias syntax
  • log: print the log system help
  • core: print the supported libgpac core options. Use -ha/-hx/-hh for advanced/expert options
  • cfg: print the GPAC configuration help
  • net: print network interfaces
  • prompt: print the GPAC prompt help when running in interactive mode (see -k )
  • modules: print available modules
  • module NAME: print info and options of module NAME
  • creds: print credential help
  • filters: print name of all available filters
  • filters:*: print name of all available filters, including meta filters
  • codecs: print the supported builtin codecs - use -hx to include unmapped codecs (ffmpeg, ...)
  • formats: print the supported formats (-ha: print filter names, -hx: include meta filters (ffmpeg,...), -hh: print mime types)
  • protocols: print the supported protocol schemes (-ha: print filter names, -hx: include meta filters (ffmpeg,...), -hh: print all)
  • props: print the supported builtin PID and packet properties
  • props PNAME: print the supported builtin PID and packet properties mentioning PNAME
  • colors: print the builtin color names and their values
  • layouts: print the builtin CICP audio channel layout names and their values
  • links: print possible connections between each supported filters (use -hx to view src->dst cap bundle detail)
  • links FNAME: print sources and sinks for filter FNAME (either builtin or JS filter)
  • FNAME: print filter FNAME info (multiple FNAME can be given)
    • For meta-filters, use FNAME:INST, e.g. ffavin:avfoundation
    • Use * to print info on all filters (big output!), *:* to print info on all filters including meta filter instances (really big output!)
    • By default only basic filter options and description are shown. Use -ha to show advanced options capabilities, -hx for expert options, -hh for all options and filter capabilities including on filters disabled in this build
  • FNAME.OPT: print option OPT in filter FNAME
  • OPT: look in filter names and options for OPT and suggest possible matches if none found. Use -hx to look for keyword in all option descriptions

-p (string): use indicated profile for the global GPAC config. If not found, config file is created. If a file path is indicated, this will load profile from that file. Otherwise, this will create a directory of the specified name and store new config there. The following reserved names create a temporary profile (not stored on disk):

  • 0: full profile
  • n: null profile disabling shared modules/filters and system paths in config (may break GUI and other filters)
    Appending :reload to the profile name will force recreating a new configuration file

-alias (string): assign a new alias or remove an alias. Can be specified several times. See alias usage (-h alias)
-aliasdoc (string): assign documentation for a given alias (optional). Can be specified several times
-uncache: revert all items in GPAC cache directory to their original name and server path
-js (string): specify javascript file to use as controller of filter session
-wc: write all core options in the config file unless already set
-we: write all file extensions in the config file unless already set (useful to change some default file extensions)
-wf: write all filter options in the config file unless already set
-wfx: write all filter options and all meta filter arguments in the config file unless already set (large config file !)
-xopt: unrecognized options and filters declaration following this option are ignored - used to pass arguments to GUI

-creds (string): setup credentials as used by servers

The following libgpac core options allow customizing the filter session:

-dbg-edges: log edges status in filter graph before dijkstra resolution (for debug). Edges are logged as edge_source(status, weight, src_cap_idx, dst_cap_idx)
-full-link: throw error if any PID in the filter graph cannot be linked
-no-dynf: disable dynamically loaded filters
-no-block (Enum, default: no): disable blocking mode of filters

  • no: enable blocking mode
  • fanout: disable blocking on fan-out, unblocking the PID as soon as one of its destinations requires a packet
  • all: disable blocking

-no-reg: disable regulation (no sleep) in session
-no-reassign: disable source filter reassignment in PID graph resolution
-sched (Enum, default: free): set scheduler mode

  • free: lock-free queues except for task list (default)
  • lock: mutexes for queues when several threads
  • freex: lock-free queues including for task lists (experimental)
  • flock: mutexes for queues even when no thread (debug mode)
  • direct: no threads and direct dispatch of tasks whenever possible (debug mode)

-max-chain (int, default: 6): set maximum chain length when resolving filter links. Default value covers for [ in -> ] dmx -> reframe -> decode -> encode -> reframe -> mx [ -> out]. Filter chains loaded for adaptation (e.g. pixel format change) are loaded after the link resolution. Setting the value to 0 disables dynamic link resolution. You will have to specify the entire chain manually
-max-sleep (int, default: 50): set maximum sleep time slot in milliseconds when regulation is enabled
-threads (int): set N extra thread for the session. -1 means use all available cores
-no-probe: disable data probing on sources and relies on extension (faster load but more error-prone)
-no-argchk: disable tracking of argument usage (all arguments will be considered as used)
-blacklist (string): blacklist the filters listed in the given string (comma-separated list). If first character is '-', this is a whitelist, i.e. only filters listed in the given string will be allowed
-no-graph-cache: disable internal caching of filter graph connections. If disabled, the graph will be recomputed at each link resolution (lower memory usage but slower)
-no-reservoir: disable memory recycling for packets and properties. This uses much less memory but stresses the system memory allocator much more
-buffer-gen (int, default: 1000): default buffer size in microseconds for generic pids
-buffer-dec (int, default: 1000000): default buffer size in microseconds for decoder input pids
-buffer-units (int, default: 1): default buffer size in frames when timing is not available

Using Aliases

The gpac command line can become quite complex when many sources or filters are used. In order to simplify this, an alias system is provided.

To assign an alias, use the syntax gpac -alias="NAME VALUE".

  • NAME: shall be a single string, with no space.
  • VALUE: the list of argument this alias replaces. If not set, the alias is destroyed

When parsing arguments, the alias will be replace by its value.
Example

gpac -alias="output aout vout"

This allows later audio and video playback using gpac -i src.mp4 output

Aliases can use arguments from the command line. The allowed syntaxes are:

  • @{a}: replaced by the value of the argument with index a after the alias
  • @{a,b}: replaced by the value of the arguments with index a and b
  • @{a:b}: replaced by the value of the arguments between index a and b
  • @{-a,b}: replaced by the value of the arguments with index a and b, inserting a list separator (comma by default) between them
  • @{-a:b}: replaced by the value of the arguments between index a and b, inserting a list separator (comma by default) between them
  • @{+a,b}: clones the parent word in the alias for a and b, replacing this pattern in each clone by the corresponding argument
  • @{+a:b}: clones the parent word in the alias for each argument between index a and b, replacing this pattern in each clone by the corresponding argument

The specified index can be:

  • forward index: a strictly positive integer, 1 being the first argument after the alias
  • backward index: the value 'n' (or 'N') to indicate the last argument on the command line. This can be followed by -x to rewind arguments (e.g. @{n-1} is the before last argument)

Before solving aliases, all option arguments are moved at the beginning of the command line. This implies that alias arguments cannot be options.
Arguments not used by any aliases are kept on the command line, other ones are removed

Example

-alias="foo src=@{N} dst=test.mp4"

The command gpac foo f1 f2 expands to gpac src=f2 dst=test.mp4 f1
Example

-alias="list: inspect src=@{+:N}"

The command gpac list f1 f2 f3 expands to gpac inspect src=f1 src=f2 src=f3
Example

-alias="list inspect src=@{+2:N}"

The command gpac list f1 f2 f3 expands to gpac inspect src=f2 src=f3 f1
Example

-alias="plist aout vout flist:srcs=@{-,N}"

The command gpac plist f1 f2 f3 expands to gpac aout vout flist:srcs="f1,f2,f3"

Alias documentation can be set using gpac -aliasdoc="NAME VALUE", with NAME the alias name and VALUE the documentation.
Alias documentation will then appear in gpac help.

User Credentials

Some servers in GPAC can use user-based and group-based authentication.
The information is stored by default in the file users.cfg located in the GPAC profile directory.
The file can be overwritten using the -users option.

By default, this file does not exist until at least one user has been configured.

The creds option allows inspecting or modifying the users and groups information. The syntax for the option value is:

  • show or no value: prints the users.cfg file
  • reset: deletes the users.cfg file (i.e. deletes all users and groups)
  • NAME: show information of user NAME
  • +NAME: adds user NAME
  • +NAME:I1=V1[,I2=V2]: sets info I1 with value V1 to user NAME. The info name password resets password without prompt.
  • -NAME: removes user NAME
  • _NAME: force password change of user NAME
  • @NAME: show information of group NAME
  • @+NAME[:u1[,u2]]: adds group NAME if not existing and adds specified users to group
  • @-NAME:u1[,u2]: removes specified users from group NAME
  • @-NAME: removes group NAME

By default all added users are members of the group users.
Passwords are not stored, only a SHA256 hash is stored.

Servers using authentication rules can use a configuration file instead of a directory name.
This configuration file is organized in sections, each section name describing a directory.
Example

[somedir]  
ru=foo  
rg=bar

The following keys are defined per directory, but may be ignored by the server depending on its operation mode:

  • ru: comma-separated list of user names with read access to the directory
  • rg: comma-separated list of group names with read access to the directory
  • wu: comma-separated list of user names with write access to the directory
  • wg: comma-separated list of group names with write access to the directory
  • mcast: comma-separated list of user names with multicast creation rights (RTSP server only)
  • filters: comma-separated list of filter names for which the directory is valid. If not found or all, applies to all filters

Rights can be configured on sub-directories by adding sections for the desired directories.
Example

[d1]  
rg=bar  
[d1/d2]  
ru=foo

With this configuration:

  • the directory d1 will be readable by all members of group bar
  • the directory d1/d2 will be readable by user foo only

Servers in GPAC currently only support the Basic HTTP authentication scheme, and should preferably be run over TLS.

HOME » Filters

Filters Overview

General Filters Concepts
gpac General Usage
Built-in Properties

GPAC Configuration

Configuration File
Global Options
Logging

Filters Help

Inspect packets (inspect)
Probe source (probe)
Compositor (compositor)
ISOBMFF/QT demultiplexer (mp4dmx)
MPEG-4 BIFS decoder (bifsdec)
MPEG-4 OD decoder (odfdec)
File input (fin)
BT/XMT/X3D loader (btplay)
HTTP input (httpin)
SVG loader (svgplay)
JPG/J2K/PNG/BMP reframer (rfimg)
PNG/JPG decoder (imgdec)
ADTS reframer (rfadts)
LATM reframer (rflatm)
MP3 reframer (rfmp3)
FAAD decoder (faad)
MAD decoder (maddec)
OpenJPEG2000 decoder (j2kdec)
AC3 reframer (rfac3)
A52 decoder (a52dec)
AMR/EVRC reframer (rfamr)
OGG demultiplexer (oggdmx)
Vorbis decoder (vorbisdec)
Theora decoder (theoradec)
MPEG-2 TS demultiplexer (m2tsdmx)
UDP/TCP input (sockin)
DVB for Linux (dvbin)
OpenSVC decoder (osvcdec)
VideoToolBox decoder (vtbdec)
MediaCodec decoder (mcdec)
MPEG-4 LASeR decoder (lsrdec)
SAF demultiplexer (safdmx)
MPEG-DASH and HLS client (dashin)
CENC decryptor (cdcrypt)
CENC encryptor (cecrypt)
ISOBMFF/QT multiplexer (mp4mx)
QCP reframer (rfqcp)
H263 reframer (rfh263)
M1V/M2V/M4V reframer (rfmpgvid)
NHNT reader (nhntr)
NHML reader (nhmlr)
AVC/HEVC reframer (rfnalu)
MPEG PS demultiplexer (m2psdmx)
AVI demultiplexer (avidmx)
Subtitle loader (txtin)
TTXT/TX3G decoder (ttxtdec)
WebVTT decoder (vttdec)
TTML decoder (ttmldec)
RTP/RTSP/SDP input (rtpin)
File output (fout)
Raw AAC to LATM writer (uflatm)
ADTS writer (ufadts)
MHAS writer (ufmhas)
Media Reframer (reframer)
Stream to file (writegen)
AVC/HEVC to AnnexB writer (ufnalu)
QCP writer (writeqcp)
WebVTT unframer (ufvtt)
NHNT writer (nhntw)
NHML writer (nhmlw)
VobSub parser (vobsubdmx)
AVI multiplexer (avimx)
Audio output (aout)
M4V writer (ufm4v)
VC1 writer (ufvc1)
Audio resampler (resample)
Video output (vout)
Video crop (vcrop)
Video flip (vflip)
RAW video reframer (rfrawvid)
PCM reframer (rfpcm)
JPG encoder (jpgenc)
PNG encoder (pngenc)
Audio/Video rewinder (rewind)
Sources concatenator (flist)
MPEG-2 TS multiplexer (m2tsmx)
DASH and HLS segmenter (dasher)
HEVC tile aggregator (tileagg)
HEVC tile bitstream splitter (tilesplit)
pipe input (pin)
pipe output (pout)
GSF Multiplexer (gsfmx)
GSF demultiplexer (gsfdmx)
UDP/TCP output (sockout)
AV1/IVF/VP9 reframer (rfav1)
IVF/OBU/annexB writer (ufobu)
NVidia decoder (nvdec)
ROUTE input (routein)
RTP Streamer (rtpout)
RTSP Server (rtspout)
HTTP Server (httpout)
HEVC tile splitter (hevcsplit)
HEVC Tile merger (hevcmerge)
FLAC reframer (rfflac)
MPEH-H Audio Stream reframer (rfmhas)
ProRes reframer (rfprores)
MPEG Transport Stream splitter (tssplit)
Compressed bitstream rewriter (bsrw)
Compressed layered bitstream splitter (bssplit)
Compressed layered bitstream aggregator (bsagg)
TX3G unframer (ufttxt)
TX3G to SRT (tx3g2srt)
TX3G to WebVTT (tx3g2vtt)
TX3G to TTML (tx3g2ttml)
WebVTT to TX3G (vtt2tx3g)
SRT reframer (rfsrt)
TTML to WebVTT (ttml2vtt)
TTML to SRT (ttml2srt)
MPEG-H Audio decoder (mpeghdec)
FFMPEG demultiplexer (ffdmx)
FFMPEG decoder (ffdec)
FFMPEG AV Capture (ffavin)
FFMPEG video rescaler (ffsws)
FFMPEG encoder (ffenc)
FFMPEG multiplexer (ffmx)
FFMPEG AVFilter (ffavf)
FFMPEG BitStream filter (ffbsf)
JavaScript filter (jsf)
ROUTE output (routeout)
TrueHD reframer (rftruehd)
CryptFile input (cryptin)
CryptFile output (cryptout)
Packet timestamp rewriter (restamp)
OGG multiplexer (oggmx)
Stream unframer (unframer)
Stream to unframed format (writeuf)
UNCV decoder (uncvdec)
GHI demultiplexer (ghidmx)
EVG video rescaler (evgs)
Closed-Caption decoder (ccdec)
DekTec SDIOut (dtout)
OpenHEVC decoder (ohevcdec)
Uncompressed Video File Format Generator Utility (uncvg)
GPU texture uploader (glpush)
Thumbnail collection generator (thumbs)
Audio Video Mixer (avmix)
AV Counter Generator (avgen)

Clone this wiki locally