[vlc-devel] [PATCH] mux: avi: add metadata.
Francois Cartegnie
fcvlcdev at free.fr
Wed Sep 4 11:24:18 CEST 2013
Just need a comment about automatically adding VLC Media player & version
in transcoded avi files.
Implements MS Tombstone data in INFO chunk.
See OpenDML spec.
---
modules/mux/avi.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/modules/mux/avi.c b/modules/mux/avi.c
index cb7877a..74549c7 100644
--- a/modules/mux/avi.c
+++ b/modules/mux/avi.c
@@ -43,12 +43,37 @@
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
+#define SOUT_CFG_PREFIX "sout-avi-"
+
+#define CFG_ARTIST_TEXT N_("Artist")
+#define CFG_DATE_TEXT N_("Date")
+#define CFG_GENRE_TEXT N_("Genre")
+#define CFG_COPYRIGHT_TEXT N_("Copyright")
+#define CFG_COMMENT_TEXT N_("Comment")
+#define CFG_NAME_TEXT N_("Name")
+#define CFG_SUBJECT_TEXT N_("Subject")
+#define CFG_ENCODER_TEXT N_("Encoder")
+#define CFG_KEYWORDS_TEXT N_("Keywords")
+
vlc_module_begin ()
set_description( N_("AVI muxer") )
set_category( CAT_SOUT )
set_subcategory( SUBCAT_SOUT_MUX )
set_capability( "sout mux", 5 )
add_shortcut( "avi" )
+
+ add_string( SOUT_CFG_PREFIX "artist", NULL, CFG_ARTIST_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "date", NULL, CFG_DATE_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "genre", NULL, CFG_GENRE_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "copyright", NULL, CFG_COPYRIGHT_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "comment", NULL, CFG_COMMENT_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "name", NULL, CFG_NAME_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "subject", NULL, CFG_SUBJECT_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "encoder",
+ "VLC Media Player - " VERSION_MESSAGE,
+ CFG_ENCODER_TEXT, NULL, true )
+ add_string( SOUT_CFG_PREFIX "keywords", NULL, CFG_KEYWORDS_TEXT, NULL, true )
+
set_callbacks( Open, Close )
vlc_module_end ()
@@ -839,6 +864,46 @@ static int avi_HeaderAdd_strl( buffer_out_t *p_bo, avi_stream_t *p_stream )
AVI_BOX_EXIT( 0 );
}
+static int avi_HeaderAdd_meta( buffer_out_t *p_bo, const char psz_meta[4],
+ const char *psz_data )
+{
+ if ( psz_data == NULL ) return 1;
+ const char *psz = psz_data;
+ AVI_BOX_ENTER( psz_meta );
+ while (*psz) bo_AddByte( p_bo, *psz++ );
+ AVI_BOX_EXIT( 0 );
+}
+
+static int avi_HeaderAdd_INFO( sout_mux_t *p_mux, buffer_out_t *p_bo )
+{
+ char *psz;
+
+#define APPLY_META(var, fourcc) \
+ psz = var_InheritString( p_mux, SOUT_CFG_PREFIX var );\
+ if ( psz )\
+ {\
+ avi_HeaderAdd_meta( p_bo, fourcc, psz );\
+ free( psz );\
+ }
+
+ AVI_BOX_ENTER_LIST( "INFO" );
+
+ APPLY_META( "artist", "IART")
+ APPLY_META( "comment", "ICMT")
+ APPLY_META( "copyright","ICOP")
+ APPLY_META( "date", "ICRD")
+ APPLY_META( "genre", "IGNR")
+ APPLY_META( "name", "INAM")
+ APPLY_META( "keywords", "IKEY")
+ APPLY_META( "subject", "ISBJ")
+ APPLY_META( "encoder", "ISFT")
+ /* Some are missing, but are they really useful ?? */
+
+#undef APPLY_META
+
+ AVI_BOX_EXIT( 0 );
+}
+
static block_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
@@ -871,6 +936,8 @@ static block_t *avi_HeaderCreateRIFF( sout_mux_t *p_mux )
avi_HeaderAdd_strl( &bo, &p_sys->stream[i_stream] );
}
+ avi_HeaderAdd_INFO( p_mux, &bo );
+
i_junk = HDR_SIZE - bo.i_buffer - 8 - 12;
bo_AddFCC( &bo, "JUNK" );
bo_AddDWordLE( &bo, i_junk );
@@ -909,4 +976,3 @@ static block_t * avi_HeaderCreateidx1( sout_mux_t *p_mux )
return( p_idx1 );
}
-
--
1.8.1.4
More information about the vlc-devel
mailing list