]> git.sesse.net Git - mlt/commitdiff
qimage: let begin property be passed as a query string parameter
authorDan Dennedy <dan@dennedy.org>
Tue, 6 Nov 2012 04:51:46 +0000 (20:51 -0800)
committerDan Dennedy <dan@dennedy.org>
Tue, 6 Nov 2012 04:51:46 +0000 (20:51 -0800)
src/modules/qimage/producer_qimage.c
src/modules/qimage/producer_qimage.yml

index e9a9a7165abdf0e98e929c6e66a3be85b5057521..98d6f472fc54e7041dd6f29dd2b8cacdb02e3cf6 100644 (file)
@@ -102,7 +102,7 @@ static int load_svg( producer_qimage self, mlt_properties properties, const char
        return result;
 }
 
-static int load_sequence( producer_qimage self, mlt_properties properties, const char *filename )
+static int load_sequence_sprintf( producer_qimage self, mlt_properties properties, const char *filename )
 {
        int result = 0;
 
@@ -140,7 +140,7 @@ static int load_sequence( producer_qimage self, mlt_properties properties, const
        return result;
 }
 
-static int load_sequence2( producer_qimage self, mlt_properties properties, const char *filename )
+static int load_sequence_deprecated( producer_qimage self, mlt_properties properties, const char *filename )
 {
        int result = 0;
        const char *start;
@@ -160,13 +160,36 @@ static int load_sequence2( producer_qimage 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_qimage 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, '?' ) )
+       {
+               // Split filename into pattern and query string
+               char *s = strdup( filename );
+               char *querystring = strrchr( s, '?' );
+               *querystring++ = '\0';
+               if ( strstr( filename, "begin=" ) )
+                       mlt_properties_set( properties, "begin", strstr( querystring, "begin=" ) + 6 );
+               else if ( strstr( filename, "begin:" ) )
+                       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_qimage self, mlt_properties properties, const char *filename )
 {
        int result = 0;
@@ -195,8 +218,9 @@ static void load_filenames( producer_qimage 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 f496b41ce0c0580fe02d03f8dcdf928e7498a920..eaf20b27d8415f9ca0ae671feff44ac1aeffd393 100644 (file)
@@ -25,9 +25,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 exceeds 100.
+
+        If the file sequence does not begin within the count of 100 you
+        can pass the begin property like a query string parameter, 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.