]> git.sesse.net Git - mlt/commitdiff
Read metadata from avformat and vorbis producers, using basic structure like:
authorj-b-m <j-b-m@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 31 Dec 2006 16:06:35 +0000 (16:06 +0000)
committerj-b-m <j-b-m@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 31 Dec 2006 16:06:35 +0000 (16:06 +0000)
meta.attr.metadata_name.markup=metadata_value

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@943 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/avformat/producer_avformat.c
src/modules/vorbis/producer_vorbis.c

index a800708a1c220135aebfc30109b7395e59577cb3..78c0d4849403376b3c04c63395d072ada361fb31 100644 (file)
@@ -299,6 +299,22 @@ static int producer_open( mlt_producer this, char *file )
                                mlt_properties_set_int( properties, "height", codec_context->height );
                                mlt_properties_set_double( properties, "aspect_ratio", av_q2d( codec_context->sample_aspect_ratio ) );
                        }
+
+                       // Read Metadata
+                       if (context->title != NULL) 
+                               mlt_properties_set(properties, "meta.attr.title.markup", context->title );
+                       if (context->author != NULL) 
+                               mlt_properties_set(properties, "meta.attr.author.markup", context->author );
+                       if (context->copyright != NULL) 
+                               mlt_properties_set(properties, "meta.attr.copyright.markup", context->copyright );
+                       if (context->comment != NULL) 
+                               mlt_properties_set(properties, "meta.attr.comment.markup", context->comment );
+                       if (context->album != NULL) 
+                               mlt_properties_set(properties, "meta.attr.album.markup", context->album );
+                       if (context->year != 0) 
+                               mlt_properties_set_int(properties, "meta.attr.year.markup", context->year );
+                       if (context->track != 0) 
+                               mlt_properties_set_int(properties, "meta.attr.track.markup", context->track );
                        
                        // We're going to cheat here - for a/v files, we will have two contexts (reasoning will be clear later)
                        if ( av == 0 && !av_bypass && audio_index != -1 && video_index != -1 )
index d69fc82a75501870267bd6c4bb087ad9c466c58e..3e2218cd977b1aecceaef8f9565ea442cc518113 100644 (file)
 static int producer_open( mlt_producer this, char *file );
 static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index );
 
+/** Structure for metadata reading 
+*/
+
+typedef struct _sw_metadata sw_metadata;
+
+struct _sw_metadata {
+       char * name;
+       char * content;
+};
+
+static sw_metadata *vorbis_metadata_from_str (char * str)
+{
+       sw_metadata * meta = NULL;
+       int i;
+
+       for (i = 0; str[i]; i++) {
+               str[i] = tolower(str[i]);
+               if (str[i] == '=') {
+                       str[i] = '\0';
+                       meta = malloc (sizeof (sw_metadata));
+                       meta->name = malloc( strlen(str) + 18 );
+                       sprintf(meta->name, "meta.attr.%s.markup", str);
+                       meta->content = strdup (&str[i+1]);
+                       break;
+               }
+       }
+       return meta;
+}
+
 /** Constructor for libvorbis.
 */
 
@@ -118,6 +147,16 @@ static int producer_open( mlt_producer this, char *file )
                        // Assign the ov structure
                        mlt_properties_set_data( properties, "ogg_vorbis_file", ov, 0, producer_file_close, NULL );
 
+                       // Read metadata
+                       sw_metadata * metadata = NULL;
+                       char **ptr = ov_comment(ov, -1)->user_comments;
+                       while(*ptr) {
+                               metadata = vorbis_metadata_from_str (*ptr);
+                               if (metadata != NULL)
+                                       mlt_properties_set(properties, metadata->name, metadata->content);
+                               ++ptr;
+                       }
+
                        if ( ov_seekable( ov ) )
                        {
                                // Get the length of the file