|
libclosedcaption 1.0.3
ISDB-Tb/SBTVD (Brazilian DTV) closed caption extraction from MPEG-TS
|
🇺🇸 English · 🇧🇷 Português (pt_BR)
C library to extract closed captions from the subtitle PES packets of an MPEG-TS, following the Brazilian digital TV standard (ISDB-Tb / SBTVD, ARIB STD-B24 and ABNT NBR 15606-1).
It was used, and is still in use, in several TVs sold in Brazil that follow the Brazilian digital TV standard (DTV ISDB-Tb).
Heads up: this is a personal project made for the Brazilian DTV world. It targets ISDB-Tb captions (Brazilian Portuguese, ISO-8859-15 text), not the Japanese ISDB-T charsets, and not ATSC/DVB. The code, the comments and the sample stream started in pt_BR (the internal
src/comments still are) and the English docs are a translation, so some terms come straight from the Brazilian specs (SBTVD, ABNT...). Everything is also available in pt_BR.
The lib doesn't demux the TS for you: you give it the caption PES and it hands back the text (UTF-8) and the control commands through callbacks. example/main.c shows how to do the demux and use the API.
It installs the .so (soname libclosedcaption.so.1), the .a, the headers in $PREFIX/include/closedcaption (use #include <closedcaption/caption.h>) and the libclosedcaption.pc, so you can build like this:
There is also a container image on GitHub Packages: docker run --rm -v "$PWD:/d" ghcr.io/jpereira/libclosedcaption /d/video.ts.
Runtime version with closedcaption_version() (and CLOSEDCAPTION_VERSION_* in the header).
On macOS the Makefile passes the SDK (xcrun --show-sdk-path) to the compiler, so it also works with compilers outside Xcode, like Homebrew's LLVM.
Build the example:
Run it without a PID to list the PIDs in the file. The caption PID is found through the PMT and marked with <- legenda:
(The example program output is in pt_BR on purpose, the tests compare against it.)
Run it again passing the PID to show the captions:
To also see the DRCS, bitmap, geometric, sound and superimpose data units, add --units:
Time is relative to the first caption. Captions go to stdout and messages go to stderr, so > captions.txt saves only the text.
The example takes 188 byte packets (TS), 192 (M2TS) and 204 (TS with Reed-Solomon, common in ISDB-T captures).
If you already have your own demux you can use just caption_screen_push_pes(), or the low level functions with the hooks from caption-hooking.h. The full docs are generated with make docs and published at https://jpereira.github.io/libclosedcaption/ (English, default) and https://jpereira.github.io/libclosedcaption/pt_BR/ (pt_BR).
Install Doxygen and Graphviz and run:
Open build/docs/html/index.html (English) or build/docs/html/pt_BR/index.html (pt_BR) to browse the site locally, with the usage guide and the API reference.
The pt_BR API docs are built from a copy of the headers in docs/pt_BR/. If you change a declaration, make check-i18n tells you when the copy drifted from include/.
CI runs all of it on Linux (gcc/clang) and macOS on every push. See CONTRIBUTING.
tests/sintetico-unidades.ts), the real captures I found do not have them.Version in the VERSION file (SemVer), history in the CHANGELOG. ./bump.sh closes the current version (commit + tag) and opens the next one; the tag fires the release with the tarball and the container image.
LGPL-3.0, see [LICENSE](LICENSE). Found a security bug? See SECURITY.