Skip to content
Romain Bouqueau edited this page Mar 5, 2024 · 39 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.

Subtitle loader

Register name used to load filter: txtin
This filter may be automatically loaded during graph resolution.

This filter reads subtitle data from input PID to produce subtitle frames on a single PID.
The filter supports the following formats:

Input files must be in UTF-8 or UTF-16 format, with or without BOM. The internal frame format is:

  • WebVTT (and srt if desired): ISO/IEC 14496-30 VTT cues
  • TTML: ISO/IEC 14496-30 XML subtitles
  • Others: 3GPP/QT Timed Text

TTML Support

If ttml_split option is set, the TTML document is split in independent time segments by inspecting all overlapping subtitles in the body.
Empty periods in TTML will result in empty TTML documents or will be skipped if no_empty option is set.

The first sample has a CTS assigned as indicated by ttml_cts:

  • a numerator of -2 indicates the first CTS is 0
  • a numerator of -1 indicates the first CTS is the first active time in document
  • a numerator >= 0 indicates the CTS to use for first sample

When TTML splitting is disabled, the duration of the TTML sample is given by ttml_dur if not 0, or set to the document duration

By default, media resources are kept as declared in TTML2 documents.

ttml_embed can be used to embed inside the TTML sample the resources in <head> or <body>:

  • for <source>, <image>, <audio>, <font>, local URIs indicated in src will be loaded and src rewritten.
  • for <data> with base64 coding, the data will be decoded, <data> element removed and parent <source> rewritten with src attribute inserted.

The embedded data is added as a subsample to the TTML frame, and the referring elements will use src=urn:mpeg:14496-30:N with N the index of the subsample.

A subtitle zero may be specified using ttml_zero. This will remove all subtitles before the given time T0, and rewrite each subtitle begin/end T to T-T0 using millisecond accuracy.

Warning: Original time formatting (tick, frames/subframe ...) will be lost when this option is used, converted to HH:MM:SS.ms.

The subtitle zero time must be prefixed with T when the option is not set as a global argument:
Example

gpac -i test.ttml:ttml_zero=T10:00:00 [...]  
MP4Box -add test.ttml:sopt:ttml_zero=T10:00:00 [...]  
gpac -i test.ttml --ttml_zero=10:00:00 [...]  
gpac -i test.ttml --ttml_zero=T10:00:00 [...]  
MP4Box -add test.ttml --ttml_zero=10:00:00 [...]

Simple Text Support

The text loader can convert input files in simple text streams of a single packet, by forcing the codec type on the input:EX gpac -i test.txt:#CodecID=stxt [...]
Example

gpac fin:pck="Text Data":#CodecID=stxt  [...]

The content of the source file will be the payload of the text sample. The stxtmod option allows specifying WebVTT, TX3G or simple text mode for output format.
In this mode, the stxtdur option is used to control the duration of the generated subtitle:

  • a positive value always forces the duration
  • a negative value forces the duration if input packet duration is not known

Options

webvtt (bool, default: false): force WebVTT import of SRT files
nodefbox (bool, default: false): skip default text box
noflush (bool, default: false): skip final sample flush for srt
fontname (str): default font
fontsize (uint, default: 18): default font size
lang (str): default language
width (uint, default: 0): default width of text area
height (uint, default: 0): default height of text area
txtx (uint, default: 0): default horizontal offset of text area: -1 (left), 0 (center) or 1 (right)
txty (uint, default: 0): default vertical offset of text area: -1 (bottom), 0 (center) or 1 (top)
zorder (sint, default: 0): default z-order of the PID
timescale (uint, default: 1000): default timescale of the PID
ttml_split (bool, default: true): split ttml doc in non-overlapping samples
ttml_cts (lfrac, default: -1/1): first sample cts - see filter help
ttml_dur (frac, default: 0/1): sample duration when not spliting split - see filter help
ttml_embed (bool, default: false): force embedding TTML resources
ttml_zero (str): set subtitle zero time for TTML
no_empty (bool, default: false): do not send empty samples
stxtdur (frac, default: 1): duration for simple text
stxtmod (enum, default: none): simple text stream mode- none: declares output PID as simple text stream

  • tx3g: declares output PID as TX3G/Apple stream
  • vtt: declares output PID as WebVTT stream

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