[vlc-commits] mux: mp4: add ttml

Francois Cartegnie git at videolan.org
Wed May 16 09:39:42 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan 26 23:36:18 2018 +0100| [7d0d9436286ba299edf72bbb001513650af087bb] | committer: Francois Cartegnie

mux: mp4: add ttml

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7d0d9436286ba299edf72bbb001513650af087bb
---

 modules/mux/mp4/libmp4mux.c | 20 +++++++++++++++++++-
 modules/mux/mp4/mp4.c       |  6 ++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index cb36653fa2..5eba714424 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -1142,6 +1142,19 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
 
         return wvtt;
     }
+    else if(p_track->fmt.i_codec == VLC_CODEC_TTML)
+    {
+        bo_t *stpp = box_new("stpp");
+        if(!stpp)
+            return NULL;
+
+        /* Sample Entry Header */
+        for (int i = 0; i < 6; i++)
+            bo_add_8(stpp, 0);        // reserved;
+        bo_add_16be(stpp, 1);         // data-reference-index
+
+        return stpp;
+    }
 
     return NULL;
 }
@@ -1640,6 +1653,8 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
             /* text/text Apple textmedia */
             if(p_stream->fmt.i_codec == VLC_CODEC_TX3G)
                 bo_add_fourcc(hdlr, (b_mov) ? "sbtl" : "text");
+            else if(p_stream->fmt.i_codec == VLC_CODEC_TTML)
+                bo_add_fourcc(hdlr, "sbtl");
             else
                 bo_add_fourcc(hdlr, "text");
         }
@@ -1839,7 +1854,6 @@ bo_t *mp4mux_GetFtyp(vlc_fourcc_t major, uint32_t minor, vlc_fourcc_t extra[], s
 bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt,
                    vlc_fourcc_t i_brand, bool b_fragmented)
 {
-    VLC_UNUSED(i_brand);
     switch(p_fmt->i_codec)
     {
     case VLC_CODEC_A52:
@@ -1879,6 +1893,10 @@ bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt,
         if(p_obj)
             msg_Warn(p_obj, "subtitle track added like in .mov (even when creating .mp4)");
         return !b_fragmented;
+    case VLC_CODEC_TTML:
+        /* Special case with smooth headers where we need to force frag TTML */
+        /* TTML currently not supported in sout, until we can keep original timestamps */
+            return i_brand == VLC_FOURCC('s', 'm', 'o', 'o');
     case VLC_CODEC_QTXT:
     case VLC_CODEC_TX3G:
     case VLC_CODEC_WEBVTT:
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index 98d7da84d9..491464b453 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -752,6 +752,12 @@ static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_s
                 p_empty->p_buffer[2] = ' ';
             }
         }
+        else if(p_stream->mux.fmt.i_codec == VLC_CODEC_TTML)
+        {
+            p_empty = block_Alloc(40);
+            if(p_empty)
+                memcpy(p_empty->p_buffer, "<tt><body><div><p></p></div></body></tt>", 40);
+        }
         else if(p_stream->mux.fmt.i_codec == VLC_CODEC_WEBVTT)
         {
             p_empty = block_Alloc(8);



More information about the vlc-commits mailing list