[FFmpeg-devel] [PATCH v2 0/3] Initial implementation of TTML encoding/muxing

Jan Ekström jeebjp at gmail.com
Mon Jan 11 16:20:17 EET 2021


I've intentionally kept this initial version simple (no styling etc) to focus
on the basics. As this goes through review, additional features can be added
(I had initial PoC for styling implemented some time around previous VDD), and
there is another patch set in my queue which would then add support for muxing
TTML into MP4.

Changes from the initial version:
  - Switched to the initial idea posted on IRC that by having *any* extradata
    the muxing mode is switched to document based as opposed to paragraph
    based in the muxer.

    Additionally, the muxer now blocks writing of multiple documents into a
    single output.

    My alternative idea would have been to attach side data specifying that
    this is a TTML paragraph (as opposed to a full XML document that would come
    out of demuxing) to the returned AVPacket, but it seems like I keep
    forgetting that subtitle encoding currently does not return AVPackets,
    but buffers.
  - Improved error codes (AVERROR_BUFFER_TOO_SMALL, EINVAL instead of ENOSYS,
    error handling in ttml_encode_init)
  - Switched to av_strlcpy in order to properly null-terminate the output
    buffers from the TTML encoder.
  - Renamed AVStream called s to st as it indeed was confusing.
  - Switched to utilizing avio_w8 when writing a single byte in the muxer.

Jan

Jan Ekström (2):
  ffprobe: switch to av_bprint_escape for XML escaping
  {avcodec,avformat}: add TTML encoder and muxer

Stefano Sabatini (1):
  avutil/{avstring,bprint}: add XML escaping from ffprobe to avutil

 Changelog                  |   1 +
 doc/general_contents.texi  |   1 +
 fftools/ffprobe.c          |  29 ++----
 libavcodec/Makefile        |   1 +
 libavcodec/allcodecs.c     |   1 +
 libavcodec/ttmlenc.c       | 178 +++++++++++++++++++++++++++++++++++++
 libavcodec/version.h       |   4 +-
 libavformat/Makefile       |   1 +
 libavformat/allformats.c   |   1 +
 libavformat/ttmlenc.c      | 166 ++++++++++++++++++++++++++++++++++
 libavformat/version.h      |   4 +-
 libavutil/avstring.h       |   1 +
 libavutil/bprint.c         |  14 +++
 tests/fate/subtitles.mak   |   3 +
 tests/ref/fate/sub-ttmlenc | 122 +++++++++++++++++++++++++
 tools/ffescape.c           |   1 +
 16 files changed, 503 insertions(+), 25 deletions(-)
 create mode 100644 libavcodec/ttmlenc.c
 create mode 100644 libavformat/ttmlenc.c
 create mode 100644 tests/ref/fate/sub-ttmlenc

-- 
2.29.2



More information about the ffmpeg-devel mailing list