]> git.sesse.net Git - mlt/commitdiff
pixbuf: let begin property be passed as a query string parameter
authorDan Dennedy <dan@dennedy.org>
Sun, 4 Nov 2012 19:49:14 +0000 (11:49 -0800)
committerDan Dennedy <dan@dennedy.org>
Sun, 4 Nov 2012 19:49:14 +0000 (11:49 -0800)
src/modules/gtk2/producer_pixbuf.c
src/modules/gtk2/producer_pixbuf.yml

index 3df7217d039039a3a5563382d69aa054f0f4bd53..1e922e7713519a38de7de5db7e2b3aca546183c5 100644 (file)
@@ -22,6 +22,7 @@
 #include <framework/mlt_frame.h>
 #include <framework/mlt_cache.h>
 #include <framework/mlt_log.h>
+#include <framework/mlt_tokeniser.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "config.h"
@@ -155,7 +156,7 @@ static int load_svg( producer_pixbuf self, mlt_properties properties, const char
        return result;
 }
 
-static int load_sequence( producer_pixbuf self, mlt_properties properties, const char *filename )
+static int load_sequence_sprintf( producer_pixbuf self, mlt_properties properties, const char *filename )
 {
        int result = 0;
 
@@ -193,11 +194,12 @@ static int load_sequence( producer_pixbuf self, mlt_properties properties, const
        return result;
 }
 
-static int load_sequence2( producer_pixbuf self, mlt_properties properties, const char *filename )
+static int load_sequence_deprecated( producer_pixbuf self, mlt_properties properties, const char *filename )
 {
        int result = 0;
        const char *start;
 
+       // This approach is deprecated in favor of the begin querystring parameter.
        // Obtain filenames with pattern containing a begin value, e.g. foo%1234d.png
        if ( ( start = strchr( filename, '%' ) ) )
        {
@@ -213,13 +215,33 @@ static int load_sequence2( producer_pixbuf self, mlt_properties properties, cons
                        s = calloc( 1, strlen( filename ) );
                        strncpy( s, filename, start - filename );
                        sprintf( s + ( start - filename ), ".%d%s", n, end );
-                       result = load_sequence( self, properties, s );
+                       result = load_sequence_sprintf( self, properties, s );
                        free( s );
                }
        }
        return result;
 }
 
+static int load_sequence_querystring( producer_pixbuf self, mlt_properties properties, const char *filename )
+{
+       int result = 0;
+
+       // Obtain filenames with pattern and begin value in query string
+       if ( strchr( filename, '%' ) && strchr( filename, '?' ) && strstr( filename, "begin=" ) )
+       {
+               // Split filename into pattern and query string
+               char *s = strdup( filename );
+               char *querystring = strrchr( s, '?' );
+               *querystring++ = '\0';
+               mlt_properties_set( properties, "begin", strstr( querystring, "begin=" ) + 6 );
+               // Coerce to an int value so serialization does not have any extra query string cruft
+               mlt_properties_set_int( properties, "begin", mlt_properties_get_int( properties, "begin" ) );
+               result = load_sequence_sprintf( self, properties, s );
+               free( s );
+       }
+       return result;
+}
+
 static int load_folder( producer_pixbuf self, mlt_properties properties, const char *filename )
 {
        int result = 0;
@@ -248,8 +270,9 @@ static void load_filenames( producer_pixbuf self, mlt_properties properties )
        self->filenames = mlt_properties_new( );
 
        if (!load_svg( self, properties, filename ) &&
-               !load_sequence( self, properties, filename ) &&
-               !load_sequence2( self, properties, filename ) &&
+               !load_sequence_querystring( self, properties, filename ) &&
+               !load_sequence_sprintf( self, properties, filename ) &&
+               !load_sequence_deprecated( self, properties, filename ) &&
                !load_folder( self, properties, filename ) )
        {
                mlt_properties_set( self->filenames, "0", filename );
index b5f419d0121b5db045027de8a7ff293f14520986..b9652852f23b8d7aa8bc8054f65b834500f1a20d 100644 (file)
@@ -28,9 +28,11 @@ parameters:
         
         If "%" in filename, the filename is used with sprintf to generate a
         filename from a counter for multi-file/flipbook animation. The file 
-        sequence ends when numeric discontinuity >100. If the file sequence
-        does not begin with the count of 100, you can also embed the number
-        of the first image between the "%" and a "d", "i", or "u".
+        sequence ends when numeric discontinuity >100.
+        
+        If the file sequence does not begin within the count of 100,
+        you can pass the begin property like a query string paramter, for
+        example: anim-%04d.png?begin=1000.
         
         If filename contains "/.all.", suffix with an extension to load all 
         pictures with matching extension from a directory.