mbox series

[FFmpeg-devel,v5,0/4] Initial implementation of TTML encoding/muxing

Message ID 20210222131914.21335-1-jeebjp@gmail.com
Headers show
Series Initial implementation of TTML encoding/muxing | expand

Message

Jan Ekström Feb. 22, 2021, 1:19 p.m. UTC
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 fourth version:
  - Switched from separate escaping modes back to a single AV_ESCAPE_MODE_XML,
    with additional flags for single and double quote escaping for attributes
    (Anton noted that the AV_ESCAPE_FLAG_XML prefix makes it all long enough,
    so ATTR was left away from these).
  - Added the libavutil minor bump, which was forgotten so far.
  - ff_ass_split_override_codes calls are now checked for errors and a warning
    or error is logged depending on whether it was an invalid input error,
    and if AV_EF_EXPLODE was set. In case of invalid input and AV_EF_EXPLODE,
    a malformed ASS dialog will cause the encoder to fail. By default it will
    not, which matches the current behavior of all other subtitle encoders,
    which do not test the return value of ff_ass_split_override_codes at all,
    and thus just skip malformed parts of an ASS dialog.

    Thank you to Anton for giving the idea of the AV_EF_EXPLODE usage.
  - Documented that AV_EF_EXPLODE is now usable for subtitle encoders.
  - FF_CODEC_CAP_INIT_CLEANUP was added to ttmlenc, simplifying clean-up.
  - The extradata added by ttmlenc was made more specific, and a shared header
    containing the value and its length was added to reduce duplication.
  - A case which would be only due to internal error was made to return
    AVERROR_BUG and the relevant log line was made to note that this is an
    internal error.
  - Missing includes for "libavutil/internal.h" were added.

Jan

Jan Ekström (3):
  ffprobe: switch to av_bprint_escape for XML escaping
  avcodec: enable usage of AV_EF_EXPLODE for subtitle encoders
  {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          |  32 ++----
 libavcodec/Makefile        |   1 +
 libavcodec/allcodecs.c     |   1 +
 libavcodec/avcodec.h       |   5 +-
 libavcodec/options_table.h |   4 +-
 libavcodec/ttmlenc.c       | 210 +++++++++++++++++++++++++++++++++++++
 libavcodec/ttmlenc.h       |  28 +++++
 libavcodec/version.h       |   2 +-
 libavformat/Makefile       |   1 +
 libavformat/allformats.c   |   1 +
 libavformat/ttmlenc.c      | 174 ++++++++++++++++++++++++++++++
 libavutil/avstring.h       |  14 +++
 libavutil/bprint.c         |  29 +++++
 libavutil/version.h        |   2 +-
 tests/fate/subtitles.mak   |   3 +
 tests/ref/fate/ffprobe_xml |   2 +-
 tests/ref/fate/sub-ttmlenc | 122 +++++++++++++++++++++
 tools/ffescape.c           |   7 +-
 20 files changed, 611 insertions(+), 29 deletions(-)
 create mode 100644 libavcodec/ttmlenc.c
 create mode 100644 libavcodec/ttmlenc.h
 create mode 100644 libavformat/ttmlenc.c
 create mode 100644 tests/ref/fate/sub-ttmlenc

Comments

Jan Ekström Feb. 22, 2021, 1:32 p.m. UTC | #1
On Mon, Feb 22, 2021 at 3:19 PM Jan Ekström <jeebjp@gmail.com> wrote:
>
> 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 fourth version:
>   - Switched from separate escaping modes back to a single AV_ESCAPE_MODE_XML,
>     with additional flags for single and double quote escaping for attributes
>     (Anton noted that the AV_ESCAPE_FLAG_XML prefix makes it all long enough,
>     so ATTR was left away from these).
>   - Added the libavutil minor bump, which was forgotten so far.
>   - ff_ass_split_override_codes calls are now checked for errors and a warning
>     or error is logged depending on whether it was an invalid input error,
>     and if AV_EF_EXPLODE was set. In case of invalid input and AV_EF_EXPLODE,
>     a malformed ASS dialog will cause the encoder to fail. By default it will
>     not, which matches the current behavior of all other subtitle encoders,
>     which do not test the return value of ff_ass_split_override_codes at all,
>     and thus just skip malformed parts of an ASS dialog.
>
>     Thank you to Anton for giving the idea of the AV_EF_EXPLODE usage.
>   - Documented that AV_EF_EXPLODE is now usable for subtitle encoders.

For the record, if this seems unacceptable I can switch it to a
specifically named AVOption in the subtitle encoder.

Either way is fine by me, the explode flag was just what was noted as
an alternative first.

Jan
Jan Ekström Feb. 26, 2021, 7:24 a.m. UTC | #2
On Mon, Feb 22, 2021, 15:32 Jan Ekström <jeebjp@gmail.com> wrote:

> On Mon, Feb 22, 2021 at 3:19 PM Jan Ekström <jeebjp@gmail.com> wrote:
> >
> > 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 fourth version:
> >   - Switched from separate escaping modes back to a single
> AV_ESCAPE_MODE_XML,
> >     with additional flags for single and double quote escaping for
> attributes
> >     (Anton noted that the AV_ESCAPE_FLAG_XML prefix makes it all long
> enough,
> >     so ATTR was left away from these).
> >   - Added the libavutil minor bump, which was forgotten so far.
> >   - ff_ass_split_override_codes calls are now checked for errors and a
> warning
> >     or error is logged depending on whether it was an invalid input
> error,
> >     and if AV_EF_EXPLODE was set. In case of invalid input and
> AV_EF_EXPLODE,
> >     a malformed ASS dialog will cause the encoder to fail. By default it
> will
> >     not, which matches the current behavior of all other subtitle
> encoders,
> >     which do not test the return value of ff_ass_split_override_codes at
> all,
> >     and thus just skip malformed parts of an ASS dialog.
> >
> >     Thank you to Anton for giving the idea of the AV_EF_EXPLODE usage.
> >   - Documented that AV_EF_EXPLODE is now usable for subtitle encoders.
>
> For the record, if this seems unacceptable I can switch it to a
> specifically named AVOption in the subtitle encoder.
>
> Either way is fine by me, the explode flag was just what was noted as
> an alternative first.
>
> Jan
>


Ping for this set.

Jan

>