[vlc-devel] [PATCH 2/2] avformat: enable SPU_ES muxing for text subtitles

Alexandre Janniaux ajanni at videolabs.io
Wed Dec 11 16:23:14 CET 2019


Allows SPU_ES to be muxed as long as they carry text subtitles. It
releases a little bit the constraint on muxing capabilities of avformat
but in particular allows muxing subrip within matroska files.
---
 modules/demux/avformat/mux.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 723974cd89..4674c8784c 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -220,12 +220,23 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         i_codec_id = AV_CODEC_ID_MP3;
     }
 
-    if( fmt->i_cat != VIDEO_ES && fmt->i_cat != AUDIO_ES)
+    if( fmt->i_cat != VIDEO_ES
+     && fmt->i_cat != AUDIO_ES
+     && fmt->i_cat != SPU_ES )
     {
         msg_Warn( p_mux, "Unhandled ES category" );
         return VLC_EGENERIC;
     }
 
+    /* Only allow VLC_CODEC_SUBT for now, as other formats have not been
+     * tested yet. */
+    if( fmt->i_cat == SPU_ES && fmt->i_codec != VLC_CODEC_SUBT )
+    {
+        msg_Warn( p_mux, "Unhandled SPU format `%4.4s'",
+                  (const char*)&fmt->i_codec );
+        return VLC_EGENERIC;
+    }
+
     /* */
     p_input->p_sys = malloc( sizeof( int ) );
     if( unlikely(p_input->p_sys == NULL) )
-- 
2.24.1



More information about the vlc-devel mailing list