]> git.sesse.net Git - mlt/commitdiff
Merge branch 'master' of xtremedia:git/mltframework.org/mlt
authorDan Dennedy <dan@dennedy.org>
Mon, 4 Apr 2011 23:48:14 +0000 (16:48 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 4 Apr 2011 23:48:14 +0000 (16:48 -0700)
docs/melt.1
docs/melt.txt
src/framework/mlt_profile.c
src/framework/mlt_profile.h
src/melt/melt.c

index 1a8827cf5e430ef56d1040df7dfed9a74f1b01cf..664041295d6395c4604efbd90543cc598eb6393b 100644 (file)
@@ -78,6 +78,18 @@ List producers or show info about one
 \fB\-query\fR "transitions" | "transition"=id
 List transitions, show info about one
 .TP
+\fB\-query\fR "profiles" | "profile"=id
+List profiles, show info about one
+.TP
+\fB\-query\fR "formats"
+List audio/video formats
+.TP
+\fB\-query\fR "audio_codecs"
+List audio codecs
+.TP
+\fB\-query\fR "video_codecs"
+List video codecs
+.TP
 \fB\-serialise\fR [filename]
 Write the commands to a text file
 .TP
index 84d505bb9787fd3ae0882baee4e40748fdec399b..cf20610e41f92e51d38037ede8ed1ab73cabc575 100644 (file)
@@ -2,7 +2,8 @@ Melt Documentation
 
 Copyright (C) 2004-2009 Ushodaya Enterprised Limited
 Author: Charles Yates <charles.yates@pandora.be>
-Last Revision: 2009-05-08
+Author: Dan Dennedy <dan@dennedy.org>
+Last Revision: 2011-04-03
 
 
 MELT
@@ -46,6 +47,10 @@ Usage:
       -query "filters" | "filter"=id           List filters or show info about one
       -query "producers" | "producer"=id       List producers or show info about one
       -query "transitions" | "transition"=id   List transitions or show info about one
+      -query "profiles" | "profile"=id         List profiles or show info about one
+      -query "formats"                         List audio/video formats
+      -query "audio_codecs"                    List audio codecs
+      -query "video_codecs"                    List video codecs
       -serialise [filename]                    Write the commands to a text file
       -silent                                  Do not display position/transport help
       -split relative-frame                    Split the last cut into two cuts
index 06083894fbd8067fa660a253163229743689d319..e2ccc56c5a02b06d51b96c86904f33c7c91bdb9f 100644 (file)
@@ -334,3 +334,48 @@ mlt_profile mlt_profile_clone( mlt_profile profile )
        }
        return clone;
 }
+
+
+/** Get the list of profiles.
+ *
+ * The caller MUST free the returned properties object!
+ * Each entry in the list is keyed on its name, and its value is another
+ * properties object that contains the attributes of the profile.
+ * \public \memberof mlt_profile_s
+ * \return a list of profiles
+ */
+
+mlt_properties mlt_profile_list( )
+{
+       const char *prefix = getenv( "MLT_PROFILES_PATH" );
+       mlt_properties properties = mlt_properties_new();
+       mlt_properties dir = mlt_properties_new();
+       int sort = 1;
+       const char *wildcard = NULL;
+       int i;
+
+       // Load from $prefix/share/mlt/profiles if no env var
+       if ( prefix == NULL )
+               prefix = PREFIX;
+
+       mlt_properties_dir_list( dir, prefix, wildcard, sort );
+
+       for ( i = 0; i < mlt_properties_count( dir ); i++ )
+       {
+               char *filename = mlt_properties_get_value( dir, i );
+               char *profile_name = basename( filename );
+               if ( profile_name[0] != '.' && strcmp( profile_name, "Makefile" ) &&
+                    profile_name[ strlen( profile_name ) - 1 ] != '~' )
+               {
+                       mlt_properties profile = mlt_properties_load( filename );
+                       if ( profile )
+                       {
+                               mlt_properties_set_data( properties, profile_name, profile, 0,
+                                       (mlt_destructor) mlt_properties_close, NULL );
+                       }
+               }
+       }
+       mlt_properties_close( dir );
+
+       return properties;
+}
index 91e27d9ab8ef57f681fd90f3532f05c0867404ee..02638e54a7ec2eed3fa7c7ab64f096e502729684 100644 (file)
@@ -55,4 +55,5 @@ extern double mlt_profile_sar( mlt_profile profile );
 extern double mlt_profile_dar( mlt_profile profile );
 extern void mlt_profile_close( mlt_profile profile );
 extern mlt_profile mlt_profile_clone( mlt_profile profile );
+extern mlt_properties mlt_profile_list( );
 #endif
index 4d610aa8d4769de87aed373b6f3e520d30fd5171..91e66c5c8d443e6a9a0989fffb4a31c22b02d263 100644 (file)
@@ -323,6 +323,10 @@ static void show_usage( char *program_name )
 "  -query \"filters\" | \"filter\"=id           List filters or show info about one\n"
 "  -query \"producers\" | \"producer\"=id       List producers or show info about one\n"
 "  -query \"transitions\" | \"transition\"=id   List transitions, show info about one\n"
+"  -query \"profiles\" | \"profile\"=id         List profiles, show info about one\n"
+"  -query \"formats\"                         List audio/video formats\n"
+"  -query \"audio_codecs\"                    List audio codecs\n"
+"  -query \"video_codecs\"                    List video codecs\n"
 "  -serialise [filename]                    Write the commands to a text file\n"
 "  -silent                                  Do not display position/transport\n"
 "  -split relative-frame                    Split the last cut into two cuts\n"
@@ -432,6 +436,82 @@ static void query_services( mlt_repository repo, mlt_service_type type )
        fprintf( stderr, "...\n" );
 }
 
+static void query_profiles()
+{
+       mlt_properties profiles = mlt_profile_list();
+       fprintf( stderr, "---\nprofiles:\n" );
+       if ( profiles )
+       {
+               int j;
+               for ( j = 0; j < mlt_properties_count( profiles ); j++ )
+                       fprintf( stderr, "  - %s\n", mlt_properties_get_name( profiles, j ) );
+       }
+       fprintf( stderr, "...\n" );
+       mlt_properties_close( profiles );
+}
+
+static void query_profile( const char *id )
+{
+       mlt_properties profiles = mlt_profile_list();
+       mlt_properties profile = mlt_properties_get_data( profiles, id, NULL );
+       if ( profile )
+       {
+               char *s = mlt_properties_serialise_yaml( profile );
+               fprintf( stderr, "%s", s );
+               free( s );
+       }
+       else
+       {
+               fprintf( stderr, "# No metadata for profile \"%s\"\n", id );
+       }
+       mlt_properties_close( profiles );
+}
+
+static void query_formats( )
+{
+       mlt_consumer consumer = mlt_factory_consumer( NULL, "avformat", NULL );
+       if ( consumer )
+       {
+               mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "f", "list" );
+               mlt_consumer_start( consumer );
+               mlt_consumer_close( consumer );
+       }
+       else
+       {
+               fprintf( stderr, "# No formats - failed to load avformat consumer\n" );
+       }
+}
+
+static void query_acodecs( )
+{
+       mlt_consumer consumer = mlt_factory_consumer( NULL, "avformat", NULL );
+       if ( consumer )
+       {
+               mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "acodec", "list" );
+               mlt_consumer_start( consumer );
+               mlt_consumer_close( consumer );
+       }
+       else
+       {
+               fprintf( stderr, "# No audio codecs - failed to load avformat consumer\n" );
+       }
+}
+
+static void query_vcodecs( )
+{
+       mlt_consumer consumer = mlt_factory_consumer( NULL, "avformat", NULL );
+       if ( consumer )
+       {
+               mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "vcodec", "list" );
+               mlt_consumer_start( consumer );
+               mlt_consumer_close( consumer );
+       }
+       else
+       {
+               fprintf( stderr, "# No video codecs - failed to load avformat consumer\n" );
+       }
+}
+
 static void on_fatal_error( mlt_properties owner, mlt_consumer consumer )
 {
        mlt_consumer_stop( consumer );
@@ -497,7 +577,15 @@ int main( int argc, char **argv )
                                        query_services( repo, producer_type );
                                else if ( !strcmp( pname, "transitions" ) || !strcmp( pname, "transition" ) )
                                        query_services( repo, transition_type );
-                               
+                               else if ( !strcmp( pname, "profiles" ) || !strcmp( pname, "profile" ) )
+                                       query_profiles();
+                               else if ( !strncmp( pname, "format", 6 ) )
+                                       query_formats();
+                               else if ( !strncmp( pname, "acodec", 6 ) || !strcmp( pname, "audio_codecs" ) )
+                                       query_acodecs();
+                               else if ( !strncmp( pname, "vcodec", 6 ) || !strcmp( pname, "video_codecs" ) )
+                                       query_vcodecs();
+
                                else if ( !strncmp( pname, "consumer=", 9 ) )
                                        query_metadata( repo, consumer_type, "consumer", strchr( pname, '=' ) + 1 );
                                else if ( !strncmp( pname, "filter=", 7 ) )
@@ -506,6 +594,8 @@ int main( int argc, char **argv )
                                        query_metadata( repo, producer_type, "producer", strchr( pname, '=' ) + 1 );
                                else if ( !strncmp( pname, "transition=", 11 ) )
                                        query_metadata( repo, transition_type, "transition", strchr( pname, '=' ) + 1 );
+                               else if ( !strncmp( pname, "profile=", 8 ) )
+                                       query_profile( strchr( pname, '=' ) + 1 );
                                else
                                        goto query_all;
                        }