[vlc-commits] mux: mp4: add support for webvtt

Francois Cartegnie git at videolan.org
Thu Jan 25 14:36:01 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan 22 21:00:14 2018 +0100| [86f5f48cfbc21b4c585a55dde8c60e267ab37a64] | committer: Francois Cartegnie

mux: mp4: add support for webvtt

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

 modules/mux/mp4/libmp4mux.c | 24 ++++++++++++++++++++----
 modules/mux/mp4/mp4.c       | 12 +++++++++---
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index ecb7313f60..578a9d2276 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -1126,6 +1126,22 @@ static bo_t *GetTextBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
 
         return tx3g;
     }
+    else if(p_track->fmt.i_codec == VLC_CODEC_WEBVTT)
+    {
+        bo_t *wvtt = box_new("wvtt");
+        if(!wvtt)
+            return NULL;
+
+        /* Sample Entry Header */
+        for (int i = 0; i < 6; i++)
+            bo_add_8(wvtt, 0);        // reserved;
+        bo_add_16be(wvtt, 1);         // data-reference-index
+
+        bo_t *ftab = box_new("vttc");
+        box_gather(wvtt, ftab);
+
+        return wvtt;
+    }
 
     return NULL;
 }
@@ -1622,11 +1638,10 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
             /* text/tx3g 3GPP */
             /* sbtl/tx3g Apple subs */
             /* text/text Apple textmedia */
-            if(p_stream->fmt.i_codec == VLC_CODEC_SUBT||
-               p_stream->fmt.i_codec == VLC_CODEC_QTXT)
-                bo_add_fourcc(hdlr, "text");
-            else if(p_stream->fmt.i_codec == VLC_CODEC_TX3G)
+            if(p_stream->fmt.i_codec == VLC_CODEC_TX3G)
                 bo_add_fourcc(hdlr, (b_mov) ? "sbtl" : "text");
+            else
+                bo_add_fourcc(hdlr, "text");
         }
 
         bo_add_32be(hdlr, 0);         // reserved
@@ -1866,6 +1881,7 @@ bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt,
         return !b_fragmented;
     case VLC_CODEC_QTXT:
     case VLC_CODEC_TX3G:
+    case VLC_CODEC_WEBVTT:
         return !b_fragmented;
     default:
         return false;
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index d08db288cd..c0e5d66eec 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -735,15 +735,21 @@ static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_s
             p_empty = block_Alloc(3);
             if(p_empty)
             {
-                /* point to start of our empty */
-                p_stream->i_last_dts += e->i_length;
-
                 /* Write a " " */
                 p_empty->p_buffer[0] = 0;
                 p_empty->p_buffer[1] = 1;
                 p_empty->p_buffer[2] = ' ';
             }
         }
+        else if(p_stream->mux.fmt.i_codec == VLC_CODEC_WEBVTT)
+        {
+            p_empty = block_Alloc(8);
+            if(p_empty)
+                memcpy(p_empty->p_buffer, "\x00\x00\x00\x08vtte", 8);
+        }
+
+        /* point to start of our empty */
+        p_stream->i_last_dts += e->i_length;
 
         if(p_empty)
         {



More information about the vlc-commits mailing list