[vlc-devel] [PATCH v2 1/2] avformat: mux: handle subtitle metadata
Alexandre Janniaux
ajanni at videolabs.io
Fri Feb 7 22:52:43 CET 2020
Some information are added through the metadata dictionary attached
to the stream object. In these information, the following keys are
used by the avformat Matroska muxer:
+ title: correspond to the TrackName, we're putting it in
psz_description field in the Matroska parser module.
+ language: correspond to the TrackLanguage, we're putting it in
the psz_language field in the Matroska parser module.
Replicate the behaviour so that these metadata are not lost after
remuxing.
---
modules/demux/avformat/mux.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index b9d9c378c8..a02206efbf 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -263,6 +263,18 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
}
break;
+ case SPU_ES:
+ codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ /* psz_description and psz_language are expected to be compliant with
+ * the muxing format. It should be the case when muxing a compliant
+ * source to the same muxing format, but we have no general guarantee
+ * at this point in the code. */
+ if (fmt->psz_description != NULL && *fmt->psz_description != '\0')
+ av_dict_set( &stream->metadata, "title", fmt->psz_description, 0 );
+ if (fmt->psz_language != NULL && *fmt->psz_language != '\0')
+ av_dict_set( &stream->metadata, "language", fmt->psz_language, 0 );
+ break;
+
case VIDEO_ES:
if( !fmt->video.i_frame_rate || !fmt->video.i_frame_rate_base ) {
msg_Warn( p_mux, "Missing frame rate, assuming 25fps" );
--
2.25.0
More information about the vlc-devel
mailing list