]> git.sesse.net Git - mlt/commitdiff
incomplete next/prev clip behaviour
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 2 Jan 2004 15:09:29 +0000 (15:09 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 2 Jan 2004 15:09:29 +0000 (15:09 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@34 d19143bc-622f-0410-bfdd-b5b2a6649095

38 files changed:
docs/services.txt
mlt/docs/services.txt
mlt/src/framework/mlt_multitrack.c
mlt/src/framework/mlt_multitrack.h
mlt/src/framework/mlt_playlist.c
mlt/src/framework/mlt_playlist.h
mlt/src/framework/mlt_producer.c
mlt/src/framework/mlt_properties.c
mlt/src/framework/mlt_properties.h
mlt/src/framework/mlt_types.h
mlt/src/inigo/inigo.c
mlt/src/modules/dv/producer_libdv.c
mlt/src/modules/ffmpeg/Makefile
mlt/src/modules/ffmpeg/configure
mlt/src/modules/ffmpeg/consumer_ffmpeg.c [new file with mode: 0644]
mlt/src/modules/ffmpeg/consumer_ffmpeg.h [new file with mode: 0644]
mlt/src/modules/ffmpeg/factory.c
mlt/src/modules/ffmpeg/producer_ffmpeg.c
mlt/src/modules/gtk2/producer_pixbuf.c
mlt/src/modules/sdl/consumer_sdl.c
src/framework/mlt_multitrack.c
src/framework/mlt_multitrack.h
src/framework/mlt_playlist.c
src/framework/mlt_playlist.h
src/framework/mlt_producer.c
src/framework/mlt_properties.c
src/framework/mlt_properties.h
src/framework/mlt_types.h
src/inigo/inigo.c
src/modules/dv/producer_libdv.c
src/modules/ffmpeg/Makefile
src/modules/ffmpeg/configure
src/modules/ffmpeg/consumer_ffmpeg.c [new file with mode: 0644]
src/modules/ffmpeg/consumer_ffmpeg.h [new file with mode: 0644]
src/modules/ffmpeg/factory.c
src/modules/ffmpeg/producer_ffmpeg.c
src/modules/gtk2/producer_pixbuf.c
src/modules/sdl/consumer_sdl.c

index 358861080508282e3037dc3e7aca2ae5efbdc6dd..d56ef2c6e535445abc9104d996488334b08b7b34 100644 (file)
@@ -27,6 +27,7 @@ Producers
                        timecode in - in point
                        timecode out - out point
                        double fps - output frames per second (default: 25)
+                       double aspect_ratio - aspect ratio of video
 
                Read Only Properties
 
@@ -61,6 +62,7 @@ Producers
                Read Only Properties
 
                        double fps - output frames per second 
+                       double aspect_ratio - aspect ratio of video
 
                Dependencies
 
@@ -71,7 +73,63 @@ Producers
                        'file' is not populated on properties?
 
        mcdv
+
+               Description:
+
+                       Mainconcept based dv decoder for video and audio.
+
+               Constructor argument:
+
+                       'file'  - produce a/v from file
+
+               Initialisation Properties
+
+                       string file - file location
+                       timecode in - in point
+                       timecode out - out point
+
+               Read Only Properties
+
+                       double fps - output frames per second 
+                       double aspect_ratio - aspect ratio of video
+
+               Dependencies
+
+                       mainconcept dv sdk and libdv.
+
+               Known Bugs
+
+                       'file' is not populated on properties?
+
        mcmpeg
+
+               Description:
+
+                       Mainconcept based mpeg decoder for video and audio.
+
+               Constructor argument:
+
+                       'file'  - produce a/v from file
+
+               Initialisation Properties
+
+                       string file - file location
+                       timecode in - in point
+                       timecode out - out point
+
+               Read Only Properties
+
+                       double fps - output frames per second 
+                       double aspect_ratio - aspect ratio of video
+
+               Dependencies
+
+                       mainconcept mpeg sdk.
+
+               Known Bugs
+
+                       'file' is not populated on properties?
+
        pango
        pixbuf
        ppm
@@ -95,5 +153,6 @@ Consumers
 ---------
 
        bluefish
+       ffmpeg
        sdl
 
index 358861080508282e3037dc3e7aca2ae5efbdc6dd..d56ef2c6e535445abc9104d996488334b08b7b34 100644 (file)
@@ -27,6 +27,7 @@ Producers
                        timecode in - in point
                        timecode out - out point
                        double fps - output frames per second (default: 25)
+                       double aspect_ratio - aspect ratio of video
 
                Read Only Properties
 
@@ -61,6 +62,7 @@ Producers
                Read Only Properties
 
                        double fps - output frames per second 
+                       double aspect_ratio - aspect ratio of video
 
                Dependencies
 
@@ -71,7 +73,63 @@ Producers
                        'file' is not populated on properties?
 
        mcdv
+
+               Description:
+
+                       Mainconcept based dv decoder for video and audio.
+
+               Constructor argument:
+
+                       'file'  - produce a/v from file
+
+               Initialisation Properties
+
+                       string file - file location
+                       timecode in - in point
+                       timecode out - out point
+
+               Read Only Properties
+
+                       double fps - output frames per second 
+                       double aspect_ratio - aspect ratio of video
+
+               Dependencies
+
+                       mainconcept dv sdk and libdv.
+
+               Known Bugs
+
+                       'file' is not populated on properties?
+
        mcmpeg
+
+               Description:
+
+                       Mainconcept based mpeg decoder for video and audio.
+
+               Constructor argument:
+
+                       'file'  - produce a/v from file
+
+               Initialisation Properties
+
+                       string file - file location
+                       timecode in - in point
+                       timecode out - out point
+
+               Read Only Properties
+
+                       double fps - output frames per second 
+                       double aspect_ratio - aspect ratio of video
+
+               Dependencies
+
+                       mainconcept mpeg sdk.
+
+               Known Bugs
+
+                       'file' is not populated on properties?
+
        pango
        pixbuf
        ppm
@@ -95,5 +153,6 @@ Consumers
 ---------
 
        bluefish
+       ffmpeg
        sdl
 
index 96169b00084d7c141bd50f2c2e5019cdac56249d..d3496de9ce0c524fb4659c7caa2636490718d52d 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 
 #include "mlt_multitrack.h"
+#include "mlt_playlist.h"
 #include "mlt_frame.h"
 
 #include <stdio.h>
@@ -56,7 +57,9 @@ mlt_multitrack mlt_multitrack_init( )
                mlt_producer producer = &this->parent;
                if ( mlt_producer_init( producer, this ) == 0 )
                {
+                       mlt_properties properties = mlt_multitrack_properties( this );
                        producer->get_frame = producer_get_frame;
+                       mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL );
                }
                else
                {
@@ -140,7 +143,6 @@ void mlt_multitrack_refresh( mlt_multitrack this )
        // Update multitrack properties now - we'll not destroy the in point here
        mlt_properties_set_timecode( properties, "length", length );
        mlt_properties_set_timecode( properties, "out", length );
-       mlt_properties_set_timecode( properties, "playtime", length - mlt_properties_get_timecode( properties, "in" ) );
        mlt_properties_set_double( properties, "fps", fps );
 }
 
@@ -251,6 +253,56 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind
        return 0;
 }
 
+/** Determine the clip point.
+*/
+
+mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index )
+{
+       int first = 1;
+       mlt_timecode position = 0;
+       int i = 0;
+
+       for ( i = 0; i < this->count; i ++ )
+       {
+               // Get the producer
+               mlt_producer producer = this->list[ i ];
+
+               if ( producer != NULL )
+               {
+                       // Get the properties of this producer
+                       mlt_properties properties = mlt_producer_properties( producer );
+
+                       // Determine if it's a playlist
+                       mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
+
+                       // We only consider playlists
+                       if ( playlist != NULL )
+                       {
+                               // Locate the smallest timecode
+                               if ( first )
+                               {
+                                       // First position found
+                                       position = mlt_playlist_clip( playlist, whence, index );
+       
+                                       // We're no longer first
+                                       first = 0;
+                               }
+                               else
+                               {
+                                       // Obtain the clip position in this playlist
+                                       mlt_timecode position2 = mlt_playlist_clip( playlist, whence, index );
+
+                                       // If this position is prior to the first, then use it
+                                       if ( position2 < position )
+                                               position = position2;
+                               }
+                       }
+               }
+       }
+
+       return position;
+}
+
 /** Close this instance.
 */
 
index 9f85fc1ab96e2783eda141e32056703027c57735..83f34dd71cb8036ee9622a0a22c513f6779c17e9 100644 (file)
@@ -29,7 +29,9 @@
 extern mlt_multitrack mlt_multitrack_init( );
 extern mlt_producer mlt_multitrack_producer( mlt_multitrack this );
 extern mlt_service mlt_multitrack_service( mlt_multitrack this );
+extern mlt_properties mlt_multitrack_properties( mlt_multitrack this );
 extern int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track );
+extern mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index );
 extern void mlt_multitrack_close( mlt_multitrack this );
 
 #endif
index c1bf716e179c85665eaaa6e38e0bc279be883cbb..ed33da96c00e7925bb5501d9531d1fc91c2f9a05 100644 (file)
@@ -73,6 +73,9 @@ mlt_playlist mlt_playlist_init( )
 
                // Initialise blank
                mlt_producer_init( &this->blank, NULL );
+
+               // Indicate that this producer is a playlist
+               mlt_properties_set_data( mlt_playlist_properties( this ), "playlist", this, 0, NULL, NULL );
        }
        
        return this;
@@ -221,6 +224,69 @@ static mlt_producer mlt_playlist_virtual_set_out( mlt_playlist this )
        return producer;
 }
 
+static int mlt_playlist_current_clip( mlt_playlist this )
+{
+       // Map playlist position to real producer in virtual playlist
+       mlt_timecode position = mlt_producer_position( &this->parent );
+
+       // Loop through the virtual playlist
+       int i = 0;
+
+       for ( i = 0; i < this->count; i ++ )
+       {
+               if ( position < this->list[ i ]->playtime )
+               {
+                       // Found it, now break
+                       break;
+               }
+               else
+               {
+                       // Decrement position by length of this entry
+                       position -= this->list[ i ]->playtime;
+               }
+       }
+
+       return i;
+}
+
+/** Get the timecode which corresponds to the start of the next clip.
+*/
+
+mlt_timecode mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index )
+{
+       mlt_timecode position = 0;
+       int absolute_clip = index;
+       int i = 0;
+
+       // Determine the absolute clip
+       switch ( whence )
+       {
+               case mlt_whence_relative_start:
+                       absolute_clip = index;
+                       break;
+
+               case mlt_whence_relative_current:
+                       absolute_clip = mlt_playlist_current_clip( this ) + index;
+                       break;
+
+               case mlt_whence_relative_end:
+                       absolute_clip = this->count - index;
+                       break;
+       }
+
+       // Check that we're in a valid range
+       if ( absolute_clip < 0 )
+               absolute_clip = 0;
+       else if ( absolute_clip > this->count )
+               absolute_clip = this->count;
+
+       // Now determine the timecode
+       for ( i = 0; i < absolute_clip; i ++ )
+               position += this->list[ i ]->playtime;
+
+       return position;
+}
+
 /** Append a producer to the playlist.
 */
 
index d63c930dc0c169495e3cf4d7d95730ee52b53f97..c6013860e73f32944614e60dfe42b3506ac59cca 100644 (file)
 extern mlt_playlist mlt_playlist_init( );
 extern mlt_producer mlt_playlist_producer( mlt_playlist this );
 extern mlt_service mlt_playlist_service( mlt_playlist this );
+extern mlt_properties mlt_playlist_properties( mlt_playlist this );
 extern int mlt_playlist_append( mlt_playlist this, mlt_producer producer );
 extern int mlt_playlist_blank( mlt_playlist this, mlt_timecode length );
+extern mlt_timecode mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index );
 extern void mlt_playlist_close( mlt_playlist this );
 
 #endif
index 991c698767f9328c41dd7dea13226a60dbcb93e3..164ed59e5895d1b2d39feaf8f35c15c27e709f4d 100644 (file)
@@ -54,13 +54,12 @@ int mlt_producer_init( mlt_producer this, void *child )
                // Set the default properties
                mlt_properties_set( properties, "mlt_type", "mlt_producer" );
                mlt_properties_set_timecode( properties, "position", 0.0 );
-               mlt_properties_set_double( properties, "frame", 1 );
+               mlt_properties_set_double( properties, "frame", 0 );
                mlt_properties_set_double( properties, "fps", 25.0 );
                mlt_properties_set_double( properties, "speed", 1.0 );
                mlt_properties_set_timecode( properties, "in", 0.0 );
-               mlt_properties_set_timecode( properties, "out", 36000.0 );
-               mlt_properties_set_timecode( properties, "playtime", 36000.0 );
-               mlt_properties_set_timecode( properties, "length", 36000.0 );
+               mlt_properties_set_timecode( properties, "out", 3600.0 );
+               mlt_properties_set_timecode( properties, "length", 3600.0 );
                mlt_properties_set_int( properties, "known_length", 1 );
                mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
 
@@ -205,7 +204,6 @@ int mlt_producer_set_in_and_out( mlt_producer this, mlt_timecode in, mlt_timecod
        // Set the values
        mlt_properties_set_timecode( mlt_producer_properties( this ), "in", in );
        mlt_properties_set_timecode( mlt_producer_properties( this ), "out", out );
-       mlt_properties_set_timecode( mlt_producer_properties( this ), "playtime", out - in );
 
        // Seek to the in point
        mlt_producer_seek( this, 0 );
@@ -234,7 +232,7 @@ mlt_timecode mlt_producer_get_out( mlt_producer this )
 
 mlt_timecode mlt_producer_get_playtime( mlt_producer this )
 {
-       return mlt_properties_get_timecode( mlt_producer_properties( this ), "playtime" );
+       return mlt_producer_get_out( this ) - mlt_producer_get_in( this );
 }
 
 /** Get the total length of the producer.
index 233e8aced35de29e58700d0ecf6cf9301f7e00f5..eb571ad110715a4a8c9ed77da7b296f03c4bf277 100644 (file)
@@ -57,6 +57,39 @@ int mlt_properties_init( mlt_properties this, void *child )
        return this->private == NULL;
 }
 
+/** Constructor for stand alone object.
+*/
+
+mlt_properties mlt_properties_new( )
+{
+       // Construct a standalone properties object
+       mlt_properties this = calloc( sizeof( struct mlt_properties_s ), 1 );
+
+       // Initialise this
+       mlt_properties_init( this, NULL );
+
+       // Return the pointer
+       return this;
+}
+
+/** Inherit all serialisable properties from that into this.
+*/
+
+int mlt_properties_inherit( mlt_properties this, mlt_properties that )
+{
+       int count = mlt_properties_count( that );
+       while ( count -- )
+       {
+               char *value = mlt_properties_get_value( that, count );
+               if ( value != NULL )
+               {
+                       char *name = mlt_properties_get_name( that, count );
+                       mlt_properties_set( this, name, value );
+               }
+       }
+       return 0;
+}
+
 /** Locate a property by name
 */
 
@@ -320,5 +353,9 @@ void mlt_properties_close( mlt_properties this )
        free( list->name );
        free( list->value );
        free( list );
+
+       // Free this now if this has no child
+       if ( this->child == NULL )
+               free( this );
 }
 
index b64753bc9781a3fc60733256f681e63a7ec9c8d9..540b7aec540a500486921e1905c18b1926367219 100644 (file)
@@ -37,6 +37,8 @@ struct mlt_properties_s
 */
 
 extern int mlt_properties_init( mlt_properties, void *child );
+extern mlt_properties mlt_properties_new( );
+extern int mlt_properties_inherit( mlt_properties this, mlt_properties that );
 extern int mlt_properties_set( mlt_properties this, char *name, char *value );
 extern int mlt_properties_parse( mlt_properties this, char *namevalue );
 extern char *mlt_properties_get( mlt_properties this, char *name );
index baf1b9925b000e2ceb8565a2894674586d0ad546..b100f18f40fd289cee13d533a055eb35c229fc06 100644 (file)
 
 #include <stdint.h>
 
+typedef enum
+{
+       mlt_whence_relative_start,
+       mlt_whence_relative_current,
+       mlt_whence_relative_end
+}
+mlt_whence;
+
 typedef double mlt_timecode;
 typedef struct mlt_frame_s *mlt_frame, **mlt_frame_ptr;
 typedef struct mlt_properties_s *mlt_properties;
index ce642328d04884e7f4de7a995ea1a97c31ef8687..42145f503c3a521a4ee00f2d4c45b6d0bc22ec82 100644 (file)
@@ -44,43 +44,71 @@ mlt_producer create_producer( char *file )
 void transport_action( mlt_producer producer, char *value )
 {
        mlt_properties properties = mlt_producer_properties( producer );
+       mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL );
 
-       switch( value[ 0 ] )
+       if ( strlen( value ) == 1 )
        {
-               case 'q':
-                       mlt_properties_set_int( properties, "done", 1 );
-                       break;
-               case '0':
-                       mlt_producer_set_speed( producer, 1 );
-                       mlt_producer_seek( producer, 0 );
-                       break;
-               case '1':
-                       mlt_producer_set_speed( producer, -10 );
-                       break;
-               case '2':
-                       mlt_producer_set_speed( producer, -2.5 );
-                       break;
-               case '3':
-                       mlt_producer_set_speed( producer, -1 );
-                       break;
-               case '4':
-                       mlt_producer_set_speed( producer, -0.5 );
-                       break;
-               case '5':
-                       mlt_producer_set_speed( producer, 0 );
-                       break;
-               case '6':
-                       mlt_producer_set_speed( producer, 0.5 );
-                       break;
-               case '7':
-                       mlt_producer_set_speed( producer, 1 );
-                       break;
-               case '8':
-                       mlt_producer_set_speed( producer, 2.5 );
-                       break;
-               case '9':
-                       mlt_producer_set_speed( producer, 10 );
-                       break;
+               switch( value[ 0 ] )
+               {
+                       case 'q':
+                               mlt_properties_set_int( properties, "done", 1 );
+                               break;
+                       case '0':
+                               mlt_producer_set_speed( producer, 1 );
+                               mlt_producer_seek( producer, 0 );
+                               break;
+                       case '1':
+                               mlt_producer_set_speed( producer, -10 );
+                               break;
+                       case '2':
+                               mlt_producer_set_speed( producer, -5 );
+                               break;
+                       case '3':
+                               mlt_producer_set_speed( producer, -2 );
+                               break;
+                       case '4':
+                               mlt_producer_set_speed( producer, -1 );
+                               break;
+                       case '5':
+                               mlt_producer_set_speed( producer, 0 );
+                               break;
+                       case '6':
+                               mlt_producer_set_speed( producer, 1 );
+                               break;
+                       case '7':
+                               mlt_producer_set_speed( producer, 2 );
+                               break;
+                       case '8':
+                               mlt_producer_set_speed( producer, 5 );
+                               break;
+                       case '9':
+                               mlt_producer_set_speed( producer, 10 );
+                               break;
+                       case 'j':
+                               if ( multitrack != NULL )
+                               {
+                                       mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, -1 );
+                                       mlt_producer_seek( producer, time );
+                                       mlt_producer_prepare_next( producer );
+                               }
+                               break;
+                       case 'k':
+                               if ( multitrack != NULL )
+                               {
+                                       mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 0 );
+                                       mlt_producer_seek( producer, time );
+                                       mlt_producer_prepare_next( producer );
+                               }
+                               break;
+                       case 'l':
+                               if ( multitrack != NULL )
+                               {
+                                       mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 );
+                                       mlt_producer_seek( producer, time );
+                                       mlt_producer_prepare_next( producer );
+                               }
+                               break;
+               }
        }
 }
 
@@ -122,9 +150,8 @@ mlt_filter create_filter( mlt_field field, char *id, int track )
        return filter;
 }
 
-void set_properties( mlt_service service, char *namevalue )
+void set_properties( mlt_properties properties, char *namevalue )
 {
-       mlt_properties properties = mlt_service_properties( service );
        mlt_properties_parse( properties, namevalue );
 }
 
@@ -133,7 +160,16 @@ void transport( mlt_producer producer )
        mlt_properties properties = mlt_producer_properties( producer );
 
        term_init( );
-       fprintf( stderr, "Press 'q' to continue\n" );
+
+       fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
+       fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|\n" );
+       fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
+
+       fprintf( stderr, "+---------------------------------------------------------------------+\n" );
+       fprintf( stderr, "|             j = previous, k = restart current, l = next             |\n" );
+       fprintf( stderr, "|                       0 = restart, q = quit                         |\n" );
+       fprintf( stderr, "+---------------------------------------------------------------------+\n" );
+
        while( mlt_properties_get_int( properties, "done" ) == 0 )
        {
                int value = term_read( );
@@ -145,12 +181,13 @@ void transport( mlt_producer producer )
 int main( int argc, char **argv )
 {
        int i;
-       mlt_service  service = NULL;
        mlt_consumer consumer = NULL;
        mlt_multitrack multitrack = NULL;
        mlt_producer producer = NULL;
        mlt_playlist playlist = NULL;
        mlt_field field = NULL;
+       mlt_properties group = mlt_properties_new( );
+       mlt_properties properties = group;
 
        // Construct the factory
        mlt_factory_init( getenv( "MLT_REPOSITORY" ) );
@@ -162,8 +199,8 @@ int main( int argc, char **argv )
        field = mlt_field_init( );
 
        // We need to track the number of registered filters
-       mlt_properties properties = mlt_field_properties( field );
-       mlt_properties_set_int( properties, "registered", 0 );
+       mlt_properties field_properties = mlt_field_properties( field );
+       mlt_properties_set_int( field_properties, "registered", 0 );
 
        // Get the multitrack from the field
        multitrack = mlt_field_multitrack( field );
@@ -175,13 +212,29 @@ int main( int argc, char **argv )
                {
                        consumer = create_consumer( argv[ ++ i ], mlt_multitrack_producer( multitrack ) );
                        if ( consumer != NULL )
-                               service = mlt_consumer_service( consumer );
+                       {
+                               properties = mlt_consumer_properties( consumer );
+                               mlt_properties_inherit( properties, group );
+                       }
+               }
+               else if ( !strcmp( argv[ i ], "-group" ) )
+               {
+                       if ( mlt_properties_count( group ) != 0 )
+                       {
+                               mlt_properties_close( group );
+                               group = mlt_properties_new( );
+                       }
+                       if ( group != NULL )
+                               properties = group;
                }
                else if ( !strcmp( argv[ i ], "-filter" ) )
                {
                        mlt_filter filter = create_filter( field, argv[ ++ i ], 0 );
                        if ( filter != NULL )
-                               service = mlt_filter_service( filter );
+                       {
+                               properties = mlt_filter_properties( filter );
+                               mlt_properties_inherit( properties, group );
+                       }
                }
                else if ( !strstr( argv[ i ], "=" ) )
                {
@@ -189,23 +242,33 @@ int main( int argc, char **argv )
                                mlt_playlist_append( playlist, producer );
                        producer = create_producer( argv[ i ] );
                        if ( producer != NULL )
-                               service = mlt_producer_service( producer );
+                       {
+                               properties = mlt_producer_properties( producer );
+                               mlt_properties_inherit( properties, group );
+                       }
                }
                else
                {
-                       set_properties( service, argv[ i ] );
+                       set_properties( properties, argv[ i ] );
                }
        }
 
        // We must have a producer at this point
        if ( producer != NULL )
        {
-               // Connect producer to playlist
-               mlt_playlist_append( playlist, producer );
-
                // If we have no consumer, default to sdl
                if ( consumer == NULL )
+               {
                        consumer = create_consumer( "sdl", mlt_multitrack_producer( multitrack ) );
+                       if ( consumer != NULL )
+                       {
+                               properties = mlt_consumer_properties( consumer );
+                               mlt_properties_inherit( properties, group );
+                       }
+               }
+
+               // Connect producer to playlist
+               mlt_playlist_append( playlist, producer );
 
                // Connect multitrack to producer
                mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), 0 );
@@ -222,7 +285,8 @@ int main( int argc, char **argv )
        }
        else
        {
-               fprintf( stderr, "Usage: inigo [ -consumer id[:arg] [ name=value ]* ]\n"
+               fprintf( stderr, "Usage: inigo [ -group [ name=value ]* ]\n"
+                                                "             [ -consumer id[:arg] [ name=value ]* ]\n"
                                         "             [ -filter id[:arg] [ name=value ] * ]\n"
                                         "             [ producer [ name=value ] * ]+\n" );
        }
@@ -230,6 +294,9 @@ int main( int argc, char **argv )
        // Close the field
        mlt_field_close( field );
 
+       // Close the group
+       mlt_properties_close( group );
+
        // Close the factory
        mlt_factory_close( );
 
index 2972d8a0de9f4298e3f57d84bad18c34592b2d58..34a73f76a73e7ca69fd6981f1c41ac8a0f622926 100644 (file)
@@ -131,7 +131,6 @@ static int producer_collect_info( producer_libdv this )
                        double fps = this->is_pal ? 25 : 30000 / 1001;
                        mlt_timecode length = ( mlt_timecode )( this->frames_in_file ) / fps;
                        mlt_properties_set_double( properties, "fps", fps );
-                       mlt_properties_set_timecode( properties, "playtime", length );
                        mlt_properties_set_timecode( properties, "length", length );
                        mlt_properties_set_timecode( properties, "in", 0.0 );
                        mlt_properties_set_timecode( properties, "out", length );
index a2fede0cbc826c206578c202ba3721c4b0b53cf3..52c407b1b111a5b7a5b33c9ce1fc19e44e232343 100644 (file)
@@ -3,7 +3,8 @@ TARGET = ../libmltffmpeg.so
 
 OBJS = factory.o \
           producer_ffmpeg.o \
-          filter_ffmpeg_dub.o
+          filter_ffmpeg_dub.o \
+          consumer_ffmpeg.o
 
 CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
index 9219312686a1aa5fcbd602988e13f44c46ffced7..539ac5bd96909aaf339a9794746511f93b8072ba 100755 (executable)
@@ -11,5 +11,9 @@ cat << EOF >> ../filters.dat
 ffmpeg_dub             libmltffmpeg.so
 EOF
 
+cat << EOF >> ../consumers.dat
+ffmpeg                 libmltffmpeg.so
+EOF
+
 fi
 
diff --git a/mlt/src/modules/ffmpeg/consumer_ffmpeg.c b/mlt/src/modules/ffmpeg/consumer_ffmpeg.c
new file mode 100644 (file)
index 0000000..11f72b7
--- /dev/null
@@ -0,0 +1,279 @@
+/*
+ * consumer_ffmpeg.c -- an ffmpeg consumer
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "consumer_ffmpeg.h"
+#include <framework/mlt_frame.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+
+/** This classes definition.
+*/
+
+typedef struct consumer_ffmpeg_s *consumer_ffmpeg;
+
+struct consumer_ffmpeg_s
+{
+       struct mlt_consumer_s parent;
+       mlt_properties properties;
+       int format;
+       int video;
+       pthread_t thread;
+       int running;
+       uint8_t audio_buffer[ 4096 * 3 ];
+       int audio_avail;
+       pthread_mutex_t audio_mutex;
+       pthread_cond_t audio_cond;
+       int window_width;
+       int window_height;
+       float aspect_ratio;
+       int width;
+       int height;
+       int playing;
+       mlt_frame *queue;
+       int size;
+       int count;
+       uint8_t *buffer;
+};
+
+/** Forward references to static functions.
+*/
+
+static void consumer_close( mlt_consumer parent );
+static void *consumer_thread( void * );
+
+/** This is what will be called by the factory - anything can be passed in
+       via the argument, but keep it simple.
+*/
+
+mlt_consumer consumer_ffmpeg_init( char *arg )
+{
+       // Create the consumer object
+       consumer_ffmpeg this = calloc( sizeof( struct consumer_ffmpeg_s ), 1 );
+
+       // If no malloc'd and consumer init ok
+       if ( this != NULL && mlt_consumer_init( &this->parent, this ) == 0 )
+       {
+               // Get the parent consumer object
+               mlt_consumer parent = &this->parent;
+
+               // We have stuff to clean up, so override the close method
+               parent->close = consumer_close;
+
+               // get a handle on properties
+               mlt_service service = mlt_consumer_service( parent );
+               this->properties = mlt_service_properties( service );
+
+               // This is the initialisation of the consumer
+               this->running = 1;
+               pthread_mutex_init( &this->audio_mutex, NULL );
+               pthread_cond_init( &this->audio_cond, NULL);
+               
+               // process actual param
+               if ( arg == NULL || !strcmp( arg, "-" ) )
+               {
+                       mlt_properties_set( this->properties, "video_file", "-" );
+                       mlt_properties_set( this->properties, "video_format", "dv" );
+               }
+               else
+               {
+                       mlt_properties_set( this->properties, "video_file", arg );
+                       mlt_properties_set( this->properties, "video_format", "" );
+               }
+
+               // Create the the thread
+               pthread_create( &this->thread, NULL, consumer_thread, this );
+
+               // Return the consumer produced
+               return parent;
+       }
+
+       // malloc or consumer init failed
+       free( this );
+
+       // Indicate failure
+       return NULL;
+}
+
+static void sdl_fill_audio( void *udata, uint8_t *stream, int len )
+{
+       consumer_ffmpeg this = udata;
+
+       pthread_mutex_lock( &this->audio_mutex );
+
+       // Block until audio received
+       while ( this->running && len > this->audio_avail )
+               pthread_cond_wait( &this->audio_cond, &this->audio_mutex );
+
+       if ( this->audio_avail >= len )
+       {
+               // Remove len from the audio available
+               this->audio_avail -= len;
+
+               // Remove the samples
+               memmove( this->audio_buffer, this->audio_buffer + len, this->audio_avail );
+       }
+       else
+       {
+               // Just to be safe, wipe the stream first
+               memset( stream, 0, len );
+
+               // Copy what we have into the stream
+               memcpy( stream, this->audio_buffer, this->audio_avail );
+
+               // No audio left
+               this->audio_avail = 0;
+       }
+
+       pthread_cond_broadcast( &this->audio_cond );
+       pthread_mutex_unlock( &this->audio_mutex );
+}
+
+static int consumer_play_audio( consumer_ffmpeg this, mlt_frame frame, int init_audio )
+{
+       // Get the properties of this consumer
+       mlt_properties properties = this->properties;
+       mlt_audio_format afmt = mlt_audio_pcm;
+       int channels;
+       int samples;
+       int frequency;
+       int16_t *pcm;
+       int bytes;
+
+       mlt_frame_get_audio( frame, &pcm, &afmt, &frequency, &channels, &samples );
+
+       if ( mlt_properties_get_int( properties, "audio_off" ) )
+               return init_audio;
+
+       if ( init_audio == 0 )
+       {
+               bytes = ( samples * channels * 2 );
+               pthread_mutex_lock( &this->audio_mutex );
+               while ( bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) )
+                       pthread_cond_wait( &this->audio_cond, &this->audio_mutex );
+               mlt_properties properties = mlt_frame_properties( frame );
+               if ( mlt_properties_get_double( properties, "speed" ) == 1 )
+                       memcpy( &this->audio_buffer[ this->audio_avail ], pcm, bytes );
+               else
+                       memset( &this->audio_buffer[ this->audio_avail ], 0, bytes );
+               this->audio_avail += bytes;
+               pthread_cond_broadcast( &this->audio_cond );
+               pthread_mutex_unlock( &this->audio_mutex );
+       }
+       else
+       {
+               this->playing = 1;
+       }
+
+       return init_audio;
+}
+
+static int consumer_play_video( consumer_ffmpeg this, mlt_frame frame )
+{
+       // Get the properties of this consumer
+       mlt_properties properties = this->properties;
+
+       if ( mlt_properties_get_int( properties, "video_off" ) )
+       {
+               mlt_frame_close( frame );
+               return 0;
+       }
+
+       if ( this->count == this->size )
+       {
+               this->size += 25;
+               this->queue = realloc( this->queue, sizeof( mlt_frame ) * this->size );
+       }
+       this->queue[ this->count ++ ] = frame;
+
+       // We're working on the oldest frame now
+       frame = this->queue[ 0 ];
+
+       // Shunt the frames in the queue down
+       int i = 0;
+       for ( i = 1; i < this->count; i ++ )
+               this->queue[ i - 1 ] = this->queue[ i ];
+       this->count --;
+
+       return 0;
+}
+
+/** Threaded wrapper for pipe.
+*/
+
+static void *consumer_thread( void *arg )
+{
+       // Identify the arg
+       consumer_ffmpeg this = arg;
+
+       // Get the consumer
+       mlt_consumer consumer = &this->parent;
+
+       // Get the service assoicated to the consumer
+       mlt_service service = mlt_consumer_service( consumer );
+
+       // Define a frame pointer
+       mlt_frame frame;
+
+       // internal intialization
+       int init_audio = 1;
+
+       // Loop until told not to
+       while( this->running )
+       {
+               // Get a frame from the service (should never return anything other than 0)
+               if ( mlt_service_get_frame( service, &frame, 0 ) == 0 )
+               {
+                       init_audio = consumer_play_audio( this, frame, init_audio );
+                       consumer_play_video( this, frame );
+               }
+       }
+
+       return NULL;
+}
+
+/** Callback to allow override of the close method.
+*/
+
+static void consumer_close( mlt_consumer parent )
+{
+       // Get the actual object
+       consumer_ffmpeg this = parent->child;
+
+       // Kill the thread and clean up
+       this->running = 0;
+
+       pthread_mutex_lock( &this->audio_mutex );
+       pthread_cond_broadcast( &this->audio_cond );
+       pthread_mutex_unlock( &this->audio_mutex );
+
+       pthread_join( this->thread, NULL );
+       pthread_mutex_destroy( &this->audio_mutex );
+       pthread_cond_destroy( &this->audio_cond );
+               
+       // Now clean up the rest (the close = NULL is a bit nasty but needed for now)
+       parent->close = NULL;
+       mlt_consumer_close( parent );
+
+       // Finally clean up this
+       free( this );
+}
+
diff --git a/mlt/src/modules/ffmpeg/consumer_ffmpeg.h b/mlt/src/modules/ffmpeg/consumer_ffmpeg.h
new file mode 100644 (file)
index 0000000..dc2fc79
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * consumer_ffmpeg.h -- simple ffmpeg test case
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _CONSUMER_FFMPEG_H_
+#define _CONSUMER_FFMPEG_H_
+
+#include <framework/mlt_consumer.h>
+
+extern mlt_consumer consumer_ffmpeg_init( char *file );
+
+#endif
index ab8240619d67cb3057d594a5c2d714d4586ecc6f..7bf697ac796bb7462329ab48c7426fb847b5c084 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "producer_ffmpeg.h"
 #include "filter_ffmpeg_dub.h"
+#include "consumer_ffmpeg.h"
 
 void *mlt_create_producer( char *id, void *arg )
 {
@@ -44,6 +45,8 @@ void *mlt_create_transition( char *id, void *arg )
 
 void *mlt_create_consumer( char *id, void *arg )
 {
+       if ( !strcmp( id, "ffmpeg" ) )
+               return consumer_ffmpeg_init( arg );
        return NULL;
 }
 
index 95763dfff4790267ce75e8d0474bb65e458c6a2f..3f9c8df2c162b51030db12d6462bf039c5d8a74e 100644 (file)
@@ -142,7 +142,7 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this )
                        char command[ 1024 ] = "";
                        float position = mlt_producer_position( &this->parent );
 
-                       if ( video_loop ) position = 0;
+                       if ( video_loop || position < 0 ) position = 0;
 
                        sprintf( command, "%s/ffmpeg/video.sh \"%s\" \"%s\" \"%s\" %f %f 2>/dev/null",
                                                          mlt_prefix,
@@ -181,7 +181,7 @@ FILE *producer_ffmpeg_run_audio( producer_ffmpeg this )
                        char command[ 1024 ] = "";
                        float position = mlt_producer_position( &this->parent );
 
-                       if ( audio_loop ) position = 0;
+                       if ( audio_loop || position < 0 ) position = 0;
 
                        sprintf( command, "%s/ffmpeg/audio.sh \"%s\" \"%s\" %f %d %d %d 2>/dev/null",
                                                          mlt_prefix,
@@ -242,11 +242,7 @@ static int sample_calculator( float fps, int frequency, int64_t position )
 {
        int samples = 0;
 
-       if ( fps == 25 )
-       {
-               samples = frequency / 25;
-       }
-       else if ( fps >= 29.97 && fps < 29.98 )
+       if ( fps > 29 && fps <= 30 )
        {
                samples = frequency / 30;
 
@@ -280,10 +276,9 @@ static int sample_calculator( float fps, int frequency, int64_t position )
                                samples = 0;
                }
        }
-       else
+       else if ( fps != 0 )
        {
-               if ( fps != 0 )
-                       samples = frequency / fps;
+               samples = frequency / fps;
        }
 
        return samples;
@@ -456,9 +451,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
        mlt_properties_set_double( properties, "speed", speed );
 
        // Set the out point on the producer
-       if ( !this->end_of_video || !this->end_of_audio )
-               mlt_producer_set_in_and_out( &this->parent, mlt_producer_get_in( &this->parent ), mlt_producer_position( &this->parent ) + 1 );
-       else
+       if ( this->end_of_video && this->end_of_audio )
                mlt_producer_set_in_and_out( &this->parent, mlt_producer_get_in( &this->parent ), mlt_producer_position( &this->parent ) );
 
        // Update timecode on the frame we're creating
index 06b32c652d76c132d1bb50a781d29c1eea4b62d9..7114979ae3538a7633a2d1aa03bf8776e7f60e10 100644 (file)
@@ -90,7 +90,6 @@ mlt_producer producer_pixbuf_init( const char *filename )
                                }
                        } 
                        mlt_properties_set_timecode( properties, "out", this->count );
-                       mlt_properties_set_timecode( properties, "playtime", this->count );
                }
                else if ( strstr( filename, "/.all." ) != NULL )
                {
@@ -118,7 +117,6 @@ mlt_producer producer_pixbuf_init( const char *filename )
                        }
 
                        mlt_properties_set_timecode( properties, "out", this->count );
-                       mlt_properties_set_timecode( properties, "playtime", this->count );
                        free( de );
                        free( dir_name );
                }
@@ -127,7 +125,6 @@ mlt_producer producer_pixbuf_init( const char *filename )
                        this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) );
                        this->filenames[ this->count ++ ] = strdup( filename );
                        mlt_properties_set_timecode( properties, "out", 1 );
-                       mlt_properties_set_timecode( properties, "playtime", 1 );
                }
 
                // Initialise gobject types
index 7ad3414321cd90f3533c9fd5a40fcf24e0315053..714fc66f5a6351512192b8b14b781d74601415ac 100644 (file)
@@ -148,7 +148,7 @@ static void sdl_unlock_display( )
                SDL_UnlockSurface( screen );
 }
 
-void sdl_fill_audio( void *udata, uint8_t *stream, int len )
+static void sdl_fill_audio( void *udata, uint8_t *stream, int len )
 {
        consumer_sdl this = udata;
 
index 96169b00084d7c141bd50f2c2e5019cdac56249d..d3496de9ce0c524fb4659c7caa2636490718d52d 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 
 #include "mlt_multitrack.h"
+#include "mlt_playlist.h"
 #include "mlt_frame.h"
 
 #include <stdio.h>
@@ -56,7 +57,9 @@ mlt_multitrack mlt_multitrack_init( )
                mlt_producer producer = &this->parent;
                if ( mlt_producer_init( producer, this ) == 0 )
                {
+                       mlt_properties properties = mlt_multitrack_properties( this );
                        producer->get_frame = producer_get_frame;
+                       mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL );
                }
                else
                {
@@ -140,7 +143,6 @@ void mlt_multitrack_refresh( mlt_multitrack this )
        // Update multitrack properties now - we'll not destroy the in point here
        mlt_properties_set_timecode( properties, "length", length );
        mlt_properties_set_timecode( properties, "out", length );
-       mlt_properties_set_timecode( properties, "playtime", length - mlt_properties_get_timecode( properties, "in" ) );
        mlt_properties_set_double( properties, "fps", fps );
 }
 
@@ -251,6 +253,56 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind
        return 0;
 }
 
+/** Determine the clip point.
+*/
+
+mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index )
+{
+       int first = 1;
+       mlt_timecode position = 0;
+       int i = 0;
+
+       for ( i = 0; i < this->count; i ++ )
+       {
+               // Get the producer
+               mlt_producer producer = this->list[ i ];
+
+               if ( producer != NULL )
+               {
+                       // Get the properties of this producer
+                       mlt_properties properties = mlt_producer_properties( producer );
+
+                       // Determine if it's a playlist
+                       mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
+
+                       // We only consider playlists
+                       if ( playlist != NULL )
+                       {
+                               // Locate the smallest timecode
+                               if ( first )
+                               {
+                                       // First position found
+                                       position = mlt_playlist_clip( playlist, whence, index );
+       
+                                       // We're no longer first
+                                       first = 0;
+                               }
+                               else
+                               {
+                                       // Obtain the clip position in this playlist
+                                       mlt_timecode position2 = mlt_playlist_clip( playlist, whence, index );
+
+                                       // If this position is prior to the first, then use it
+                                       if ( position2 < position )
+                                               position = position2;
+                               }
+                       }
+               }
+       }
+
+       return position;
+}
+
 /** Close this instance.
 */
 
index 9f85fc1ab96e2783eda141e32056703027c57735..83f34dd71cb8036ee9622a0a22c513f6779c17e9 100644 (file)
@@ -29,7 +29,9 @@
 extern mlt_multitrack mlt_multitrack_init( );
 extern mlt_producer mlt_multitrack_producer( mlt_multitrack this );
 extern mlt_service mlt_multitrack_service( mlt_multitrack this );
+extern mlt_properties mlt_multitrack_properties( mlt_multitrack this );
 extern int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track );
+extern mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index );
 extern void mlt_multitrack_close( mlt_multitrack this );
 
 #endif
index c1bf716e179c85665eaaa6e38e0bc279be883cbb..ed33da96c00e7925bb5501d9531d1fc91c2f9a05 100644 (file)
@@ -73,6 +73,9 @@ mlt_playlist mlt_playlist_init( )
 
                // Initialise blank
                mlt_producer_init( &this->blank, NULL );
+
+               // Indicate that this producer is a playlist
+               mlt_properties_set_data( mlt_playlist_properties( this ), "playlist", this, 0, NULL, NULL );
        }
        
        return this;
@@ -221,6 +224,69 @@ static mlt_producer mlt_playlist_virtual_set_out( mlt_playlist this )
        return producer;
 }
 
+static int mlt_playlist_current_clip( mlt_playlist this )
+{
+       // Map playlist position to real producer in virtual playlist
+       mlt_timecode position = mlt_producer_position( &this->parent );
+
+       // Loop through the virtual playlist
+       int i = 0;
+
+       for ( i = 0; i < this->count; i ++ )
+       {
+               if ( position < this->list[ i ]->playtime )
+               {
+                       // Found it, now break
+                       break;
+               }
+               else
+               {
+                       // Decrement position by length of this entry
+                       position -= this->list[ i ]->playtime;
+               }
+       }
+
+       return i;
+}
+
+/** Get the timecode which corresponds to the start of the next clip.
+*/
+
+mlt_timecode mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index )
+{
+       mlt_timecode position = 0;
+       int absolute_clip = index;
+       int i = 0;
+
+       // Determine the absolute clip
+       switch ( whence )
+       {
+               case mlt_whence_relative_start:
+                       absolute_clip = index;
+                       break;
+
+               case mlt_whence_relative_current:
+                       absolute_clip = mlt_playlist_current_clip( this ) + index;
+                       break;
+
+               case mlt_whence_relative_end:
+                       absolute_clip = this->count - index;
+                       break;
+       }
+
+       // Check that we're in a valid range
+       if ( absolute_clip < 0 )
+               absolute_clip = 0;
+       else if ( absolute_clip > this->count )
+               absolute_clip = this->count;
+
+       // Now determine the timecode
+       for ( i = 0; i < absolute_clip; i ++ )
+               position += this->list[ i ]->playtime;
+
+       return position;
+}
+
 /** Append a producer to the playlist.
 */
 
index d63c930dc0c169495e3cf4d7d95730ee52b53f97..c6013860e73f32944614e60dfe42b3506ac59cca 100644 (file)
 extern mlt_playlist mlt_playlist_init( );
 extern mlt_producer mlt_playlist_producer( mlt_playlist this );
 extern mlt_service mlt_playlist_service( mlt_playlist this );
+extern mlt_properties mlt_playlist_properties( mlt_playlist this );
 extern int mlt_playlist_append( mlt_playlist this, mlt_producer producer );
 extern int mlt_playlist_blank( mlt_playlist this, mlt_timecode length );
+extern mlt_timecode mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index );
 extern void mlt_playlist_close( mlt_playlist this );
 
 #endif
index 991c698767f9328c41dd7dea13226a60dbcb93e3..164ed59e5895d1b2d39feaf8f35c15c27e709f4d 100644 (file)
@@ -54,13 +54,12 @@ int mlt_producer_init( mlt_producer this, void *child )
                // Set the default properties
                mlt_properties_set( properties, "mlt_type", "mlt_producer" );
                mlt_properties_set_timecode( properties, "position", 0.0 );
-               mlt_properties_set_double( properties, "frame", 1 );
+               mlt_properties_set_double( properties, "frame", 0 );
                mlt_properties_set_double( properties, "fps", 25.0 );
                mlt_properties_set_double( properties, "speed", 1.0 );
                mlt_properties_set_timecode( properties, "in", 0.0 );
-               mlt_properties_set_timecode( properties, "out", 36000.0 );
-               mlt_properties_set_timecode( properties, "playtime", 36000.0 );
-               mlt_properties_set_timecode( properties, "length", 36000.0 );
+               mlt_properties_set_timecode( properties, "out", 3600.0 );
+               mlt_properties_set_timecode( properties, "length", 3600.0 );
                mlt_properties_set_int( properties, "known_length", 1 );
                mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
 
@@ -205,7 +204,6 @@ int mlt_producer_set_in_and_out( mlt_producer this, mlt_timecode in, mlt_timecod
        // Set the values
        mlt_properties_set_timecode( mlt_producer_properties( this ), "in", in );
        mlt_properties_set_timecode( mlt_producer_properties( this ), "out", out );
-       mlt_properties_set_timecode( mlt_producer_properties( this ), "playtime", out - in );
 
        // Seek to the in point
        mlt_producer_seek( this, 0 );
@@ -234,7 +232,7 @@ mlt_timecode mlt_producer_get_out( mlt_producer this )
 
 mlt_timecode mlt_producer_get_playtime( mlt_producer this )
 {
-       return mlt_properties_get_timecode( mlt_producer_properties( this ), "playtime" );
+       return mlt_producer_get_out( this ) - mlt_producer_get_in( this );
 }
 
 /** Get the total length of the producer.
index 233e8aced35de29e58700d0ecf6cf9301f7e00f5..eb571ad110715a4a8c9ed77da7b296f03c4bf277 100644 (file)
@@ -57,6 +57,39 @@ int mlt_properties_init( mlt_properties this, void *child )
        return this->private == NULL;
 }
 
+/** Constructor for stand alone object.
+*/
+
+mlt_properties mlt_properties_new( )
+{
+       // Construct a standalone properties object
+       mlt_properties this = calloc( sizeof( struct mlt_properties_s ), 1 );
+
+       // Initialise this
+       mlt_properties_init( this, NULL );
+
+       // Return the pointer
+       return this;
+}
+
+/** Inherit all serialisable properties from that into this.
+*/
+
+int mlt_properties_inherit( mlt_properties this, mlt_properties that )
+{
+       int count = mlt_properties_count( that );
+       while ( count -- )
+       {
+               char *value = mlt_properties_get_value( that, count );
+               if ( value != NULL )
+               {
+                       char *name = mlt_properties_get_name( that, count );
+                       mlt_properties_set( this, name, value );
+               }
+       }
+       return 0;
+}
+
 /** Locate a property by name
 */
 
@@ -320,5 +353,9 @@ void mlt_properties_close( mlt_properties this )
        free( list->name );
        free( list->value );
        free( list );
+
+       // Free this now if this has no child
+       if ( this->child == NULL )
+               free( this );
 }
 
index b64753bc9781a3fc60733256f681e63a7ec9c8d9..540b7aec540a500486921e1905c18b1926367219 100644 (file)
@@ -37,6 +37,8 @@ struct mlt_properties_s
 */
 
 extern int mlt_properties_init( mlt_properties, void *child );
+extern mlt_properties mlt_properties_new( );
+extern int mlt_properties_inherit( mlt_properties this, mlt_properties that );
 extern int mlt_properties_set( mlt_properties this, char *name, char *value );
 extern int mlt_properties_parse( mlt_properties this, char *namevalue );
 extern char *mlt_properties_get( mlt_properties this, char *name );
index baf1b9925b000e2ceb8565a2894674586d0ad546..b100f18f40fd289cee13d533a055eb35c229fc06 100644 (file)
 
 #include <stdint.h>
 
+typedef enum
+{
+       mlt_whence_relative_start,
+       mlt_whence_relative_current,
+       mlt_whence_relative_end
+}
+mlt_whence;
+
 typedef double mlt_timecode;
 typedef struct mlt_frame_s *mlt_frame, **mlt_frame_ptr;
 typedef struct mlt_properties_s *mlt_properties;
index ce642328d04884e7f4de7a995ea1a97c31ef8687..42145f503c3a521a4ee00f2d4c45b6d0bc22ec82 100644 (file)
@@ -44,43 +44,71 @@ mlt_producer create_producer( char *file )
 void transport_action( mlt_producer producer, char *value )
 {
        mlt_properties properties = mlt_producer_properties( producer );
+       mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL );
 
-       switch( value[ 0 ] )
+       if ( strlen( value ) == 1 )
        {
-               case 'q':
-                       mlt_properties_set_int( properties, "done", 1 );
-                       break;
-               case '0':
-                       mlt_producer_set_speed( producer, 1 );
-                       mlt_producer_seek( producer, 0 );
-                       break;
-               case '1':
-                       mlt_producer_set_speed( producer, -10 );
-                       break;
-               case '2':
-                       mlt_producer_set_speed( producer, -2.5 );
-                       break;
-               case '3':
-                       mlt_producer_set_speed( producer, -1 );
-                       break;
-               case '4':
-                       mlt_producer_set_speed( producer, -0.5 );
-                       break;
-               case '5':
-                       mlt_producer_set_speed( producer, 0 );
-                       break;
-               case '6':
-                       mlt_producer_set_speed( producer, 0.5 );
-                       break;
-               case '7':
-                       mlt_producer_set_speed( producer, 1 );
-                       break;
-               case '8':
-                       mlt_producer_set_speed( producer, 2.5 );
-                       break;
-               case '9':
-                       mlt_producer_set_speed( producer, 10 );
-                       break;
+               switch( value[ 0 ] )
+               {
+                       case 'q':
+                               mlt_properties_set_int( properties, "done", 1 );
+                               break;
+                       case '0':
+                               mlt_producer_set_speed( producer, 1 );
+                               mlt_producer_seek( producer, 0 );
+                               break;
+                       case '1':
+                               mlt_producer_set_speed( producer, -10 );
+                               break;
+                       case '2':
+                               mlt_producer_set_speed( producer, -5 );
+                               break;
+                       case '3':
+                               mlt_producer_set_speed( producer, -2 );
+                               break;
+                       case '4':
+                               mlt_producer_set_speed( producer, -1 );
+                               break;
+                       case '5':
+                               mlt_producer_set_speed( producer, 0 );
+                               break;
+                       case '6':
+                               mlt_producer_set_speed( producer, 1 );
+                               break;
+                       case '7':
+                               mlt_producer_set_speed( producer, 2 );
+                               break;
+                       case '8':
+                               mlt_producer_set_speed( producer, 5 );
+                               break;
+                       case '9':
+                               mlt_producer_set_speed( producer, 10 );
+                               break;
+                       case 'j':
+                               if ( multitrack != NULL )
+                               {
+                                       mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, -1 );
+                                       mlt_producer_seek( producer, time );
+                                       mlt_producer_prepare_next( producer );
+                               }
+                               break;
+                       case 'k':
+                               if ( multitrack != NULL )
+                               {
+                                       mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 0 );
+                                       mlt_producer_seek( producer, time );
+                                       mlt_producer_prepare_next( producer );
+                               }
+                               break;
+                       case 'l':
+                               if ( multitrack != NULL )
+                               {
+                                       mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 );
+                                       mlt_producer_seek( producer, time );
+                                       mlt_producer_prepare_next( producer );
+                               }
+                               break;
+               }
        }
 }
 
@@ -122,9 +150,8 @@ mlt_filter create_filter( mlt_field field, char *id, int track )
        return filter;
 }
 
-void set_properties( mlt_service service, char *namevalue )
+void set_properties( mlt_properties properties, char *namevalue )
 {
-       mlt_properties properties = mlt_service_properties( service );
        mlt_properties_parse( properties, namevalue );
 }
 
@@ -133,7 +160,16 @@ void transport( mlt_producer producer )
        mlt_properties properties = mlt_producer_properties( producer );
 
        term_init( );
-       fprintf( stderr, "Press 'q' to continue\n" );
+
+       fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
+       fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|\n" );
+       fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
+
+       fprintf( stderr, "+---------------------------------------------------------------------+\n" );
+       fprintf( stderr, "|             j = previous, k = restart current, l = next             |\n" );
+       fprintf( stderr, "|                       0 = restart, q = quit                         |\n" );
+       fprintf( stderr, "+---------------------------------------------------------------------+\n" );
+
        while( mlt_properties_get_int( properties, "done" ) == 0 )
        {
                int value = term_read( );
@@ -145,12 +181,13 @@ void transport( mlt_producer producer )
 int main( int argc, char **argv )
 {
        int i;
-       mlt_service  service = NULL;
        mlt_consumer consumer = NULL;
        mlt_multitrack multitrack = NULL;
        mlt_producer producer = NULL;
        mlt_playlist playlist = NULL;
        mlt_field field = NULL;
+       mlt_properties group = mlt_properties_new( );
+       mlt_properties properties = group;
 
        // Construct the factory
        mlt_factory_init( getenv( "MLT_REPOSITORY" ) );
@@ -162,8 +199,8 @@ int main( int argc, char **argv )
        field = mlt_field_init( );
 
        // We need to track the number of registered filters
-       mlt_properties properties = mlt_field_properties( field );
-       mlt_properties_set_int( properties, "registered", 0 );
+       mlt_properties field_properties = mlt_field_properties( field );
+       mlt_properties_set_int( field_properties, "registered", 0 );
 
        // Get the multitrack from the field
        multitrack = mlt_field_multitrack( field );
@@ -175,13 +212,29 @@ int main( int argc, char **argv )
                {
                        consumer = create_consumer( argv[ ++ i ], mlt_multitrack_producer( multitrack ) );
                        if ( consumer != NULL )
-                               service = mlt_consumer_service( consumer );
+                       {
+                               properties = mlt_consumer_properties( consumer );
+                               mlt_properties_inherit( properties, group );
+                       }
+               }
+               else if ( !strcmp( argv[ i ], "-group" ) )
+               {
+                       if ( mlt_properties_count( group ) != 0 )
+                       {
+                               mlt_properties_close( group );
+                               group = mlt_properties_new( );
+                       }
+                       if ( group != NULL )
+                               properties = group;
                }
                else if ( !strcmp( argv[ i ], "-filter" ) )
                {
                        mlt_filter filter = create_filter( field, argv[ ++ i ], 0 );
                        if ( filter != NULL )
-                               service = mlt_filter_service( filter );
+                       {
+                               properties = mlt_filter_properties( filter );
+                               mlt_properties_inherit( properties, group );
+                       }
                }
                else if ( !strstr( argv[ i ], "=" ) )
                {
@@ -189,23 +242,33 @@ int main( int argc, char **argv )
                                mlt_playlist_append( playlist, producer );
                        producer = create_producer( argv[ i ] );
                        if ( producer != NULL )
-                               service = mlt_producer_service( producer );
+                       {
+                               properties = mlt_producer_properties( producer );
+                               mlt_properties_inherit( properties, group );
+                       }
                }
                else
                {
-                       set_properties( service, argv[ i ] );
+                       set_properties( properties, argv[ i ] );
                }
        }
 
        // We must have a producer at this point
        if ( producer != NULL )
        {
-               // Connect producer to playlist
-               mlt_playlist_append( playlist, producer );
-
                // If we have no consumer, default to sdl
                if ( consumer == NULL )
+               {
                        consumer = create_consumer( "sdl", mlt_multitrack_producer( multitrack ) );
+                       if ( consumer != NULL )
+                       {
+                               properties = mlt_consumer_properties( consumer );
+                               mlt_properties_inherit( properties, group );
+                       }
+               }
+
+               // Connect producer to playlist
+               mlt_playlist_append( playlist, producer );
 
                // Connect multitrack to producer
                mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), 0 );
@@ -222,7 +285,8 @@ int main( int argc, char **argv )
        }
        else
        {
-               fprintf( stderr, "Usage: inigo [ -consumer id[:arg] [ name=value ]* ]\n"
+               fprintf( stderr, "Usage: inigo [ -group [ name=value ]* ]\n"
+                                                "             [ -consumer id[:arg] [ name=value ]* ]\n"
                                         "             [ -filter id[:arg] [ name=value ] * ]\n"
                                         "             [ producer [ name=value ] * ]+\n" );
        }
@@ -230,6 +294,9 @@ int main( int argc, char **argv )
        // Close the field
        mlt_field_close( field );
 
+       // Close the group
+       mlt_properties_close( group );
+
        // Close the factory
        mlt_factory_close( );
 
index 2972d8a0de9f4298e3f57d84bad18c34592b2d58..34a73f76a73e7ca69fd6981f1c41ac8a0f622926 100644 (file)
@@ -131,7 +131,6 @@ static int producer_collect_info( producer_libdv this )
                        double fps = this->is_pal ? 25 : 30000 / 1001;
                        mlt_timecode length = ( mlt_timecode )( this->frames_in_file ) / fps;
                        mlt_properties_set_double( properties, "fps", fps );
-                       mlt_properties_set_timecode( properties, "playtime", length );
                        mlt_properties_set_timecode( properties, "length", length );
                        mlt_properties_set_timecode( properties, "in", 0.0 );
                        mlt_properties_set_timecode( properties, "out", length );
index a2fede0cbc826c206578c202ba3721c4b0b53cf3..52c407b1b111a5b7a5b33c9ce1fc19e44e232343 100644 (file)
@@ -3,7 +3,8 @@ TARGET = ../libmltffmpeg.so
 
 OBJS = factory.o \
           producer_ffmpeg.o \
-          filter_ffmpeg_dub.o
+          filter_ffmpeg_dub.o \
+          consumer_ffmpeg.o
 
 CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
index 9219312686a1aa5fcbd602988e13f44c46ffced7..539ac5bd96909aaf339a9794746511f93b8072ba 100755 (executable)
@@ -11,5 +11,9 @@ cat << EOF >> ../filters.dat
 ffmpeg_dub             libmltffmpeg.so
 EOF
 
+cat << EOF >> ../consumers.dat
+ffmpeg                 libmltffmpeg.so
+EOF
+
 fi
 
diff --git a/src/modules/ffmpeg/consumer_ffmpeg.c b/src/modules/ffmpeg/consumer_ffmpeg.c
new file mode 100644 (file)
index 0000000..11f72b7
--- /dev/null
@@ -0,0 +1,279 @@
+/*
+ * consumer_ffmpeg.c -- an ffmpeg consumer
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "consumer_ffmpeg.h"
+#include <framework/mlt_frame.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+
+/** This classes definition.
+*/
+
+typedef struct consumer_ffmpeg_s *consumer_ffmpeg;
+
+struct consumer_ffmpeg_s
+{
+       struct mlt_consumer_s parent;
+       mlt_properties properties;
+       int format;
+       int video;
+       pthread_t thread;
+       int running;
+       uint8_t audio_buffer[ 4096 * 3 ];
+       int audio_avail;
+       pthread_mutex_t audio_mutex;
+       pthread_cond_t audio_cond;
+       int window_width;
+       int window_height;
+       float aspect_ratio;
+       int width;
+       int height;
+       int playing;
+       mlt_frame *queue;
+       int size;
+       int count;
+       uint8_t *buffer;
+};
+
+/** Forward references to static functions.
+*/
+
+static void consumer_close( mlt_consumer parent );
+static void *consumer_thread( void * );
+
+/** This is what will be called by the factory - anything can be passed in
+       via the argument, but keep it simple.
+*/
+
+mlt_consumer consumer_ffmpeg_init( char *arg )
+{
+       // Create the consumer object
+       consumer_ffmpeg this = calloc( sizeof( struct consumer_ffmpeg_s ), 1 );
+
+       // If no malloc'd and consumer init ok
+       if ( this != NULL && mlt_consumer_init( &this->parent, this ) == 0 )
+       {
+               // Get the parent consumer object
+               mlt_consumer parent = &this->parent;
+
+               // We have stuff to clean up, so override the close method
+               parent->close = consumer_close;
+
+               // get a handle on properties
+               mlt_service service = mlt_consumer_service( parent );
+               this->properties = mlt_service_properties( service );
+
+               // This is the initialisation of the consumer
+               this->running = 1;
+               pthread_mutex_init( &this->audio_mutex, NULL );
+               pthread_cond_init( &this->audio_cond, NULL);
+               
+               // process actual param
+               if ( arg == NULL || !strcmp( arg, "-" ) )
+               {
+                       mlt_properties_set( this->properties, "video_file", "-" );
+                       mlt_properties_set( this->properties, "video_format", "dv" );
+               }
+               else
+               {
+                       mlt_properties_set( this->properties, "video_file", arg );
+                       mlt_properties_set( this->properties, "video_format", "" );
+               }
+
+               // Create the the thread
+               pthread_create( &this->thread, NULL, consumer_thread, this );
+
+               // Return the consumer produced
+               return parent;
+       }
+
+       // malloc or consumer init failed
+       free( this );
+
+       // Indicate failure
+       return NULL;
+}
+
+static void sdl_fill_audio( void *udata, uint8_t *stream, int len )
+{
+       consumer_ffmpeg this = udata;
+
+       pthread_mutex_lock( &this->audio_mutex );
+
+       // Block until audio received
+       while ( this->running && len > this->audio_avail )
+               pthread_cond_wait( &this->audio_cond, &this->audio_mutex );
+
+       if ( this->audio_avail >= len )
+       {
+               // Remove len from the audio available
+               this->audio_avail -= len;
+
+               // Remove the samples
+               memmove( this->audio_buffer, this->audio_buffer + len, this->audio_avail );
+       }
+       else
+       {
+               // Just to be safe, wipe the stream first
+               memset( stream, 0, len );
+
+               // Copy what we have into the stream
+               memcpy( stream, this->audio_buffer, this->audio_avail );
+
+               // No audio left
+               this->audio_avail = 0;
+       }
+
+       pthread_cond_broadcast( &this->audio_cond );
+       pthread_mutex_unlock( &this->audio_mutex );
+}
+
+static int consumer_play_audio( consumer_ffmpeg this, mlt_frame frame, int init_audio )
+{
+       // Get the properties of this consumer
+       mlt_properties properties = this->properties;
+       mlt_audio_format afmt = mlt_audio_pcm;
+       int channels;
+       int samples;
+       int frequency;
+       int16_t *pcm;
+       int bytes;
+
+       mlt_frame_get_audio( frame, &pcm, &afmt, &frequency, &channels, &samples );
+
+       if ( mlt_properties_get_int( properties, "audio_off" ) )
+               return init_audio;
+
+       if ( init_audio == 0 )
+       {
+               bytes = ( samples * channels * 2 );
+               pthread_mutex_lock( &this->audio_mutex );
+               while ( bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) )
+                       pthread_cond_wait( &this->audio_cond, &this->audio_mutex );
+               mlt_properties properties = mlt_frame_properties( frame );
+               if ( mlt_properties_get_double( properties, "speed" ) == 1 )
+                       memcpy( &this->audio_buffer[ this->audio_avail ], pcm, bytes );
+               else
+                       memset( &this->audio_buffer[ this->audio_avail ], 0, bytes );
+               this->audio_avail += bytes;
+               pthread_cond_broadcast( &this->audio_cond );
+               pthread_mutex_unlock( &this->audio_mutex );
+       }
+       else
+       {
+               this->playing = 1;
+       }
+
+       return init_audio;
+}
+
+static int consumer_play_video( consumer_ffmpeg this, mlt_frame frame )
+{
+       // Get the properties of this consumer
+       mlt_properties properties = this->properties;
+
+       if ( mlt_properties_get_int( properties, "video_off" ) )
+       {
+               mlt_frame_close( frame );
+               return 0;
+       }
+
+       if ( this->count == this->size )
+       {
+               this->size += 25;
+               this->queue = realloc( this->queue, sizeof( mlt_frame ) * this->size );
+       }
+       this->queue[ this->count ++ ] = frame;
+
+       // We're working on the oldest frame now
+       frame = this->queue[ 0 ];
+
+       // Shunt the frames in the queue down
+       int i = 0;
+       for ( i = 1; i < this->count; i ++ )
+               this->queue[ i - 1 ] = this->queue[ i ];
+       this->count --;
+
+       return 0;
+}
+
+/** Threaded wrapper for pipe.
+*/
+
+static void *consumer_thread( void *arg )
+{
+       // Identify the arg
+       consumer_ffmpeg this = arg;
+
+       // Get the consumer
+       mlt_consumer consumer = &this->parent;
+
+       // Get the service assoicated to the consumer
+       mlt_service service = mlt_consumer_service( consumer );
+
+       // Define a frame pointer
+       mlt_frame frame;
+
+       // internal intialization
+       int init_audio = 1;
+
+       // Loop until told not to
+       while( this->running )
+       {
+               // Get a frame from the service (should never return anything other than 0)
+               if ( mlt_service_get_frame( service, &frame, 0 ) == 0 )
+               {
+                       init_audio = consumer_play_audio( this, frame, init_audio );
+                       consumer_play_video( this, frame );
+               }
+       }
+
+       return NULL;
+}
+
+/** Callback to allow override of the close method.
+*/
+
+static void consumer_close( mlt_consumer parent )
+{
+       // Get the actual object
+       consumer_ffmpeg this = parent->child;
+
+       // Kill the thread and clean up
+       this->running = 0;
+
+       pthread_mutex_lock( &this->audio_mutex );
+       pthread_cond_broadcast( &this->audio_cond );
+       pthread_mutex_unlock( &this->audio_mutex );
+
+       pthread_join( this->thread, NULL );
+       pthread_mutex_destroy( &this->audio_mutex );
+       pthread_cond_destroy( &this->audio_cond );
+               
+       // Now clean up the rest (the close = NULL is a bit nasty but needed for now)
+       parent->close = NULL;
+       mlt_consumer_close( parent );
+
+       // Finally clean up this
+       free( this );
+}
+
diff --git a/src/modules/ffmpeg/consumer_ffmpeg.h b/src/modules/ffmpeg/consumer_ffmpeg.h
new file mode 100644 (file)
index 0000000..dc2fc79
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * consumer_ffmpeg.h -- simple ffmpeg test case
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _CONSUMER_FFMPEG_H_
+#define _CONSUMER_FFMPEG_H_
+
+#include <framework/mlt_consumer.h>
+
+extern mlt_consumer consumer_ffmpeg_init( char *file );
+
+#endif
index ab8240619d67cb3057d594a5c2d714d4586ecc6f..7bf697ac796bb7462329ab48c7426fb847b5c084 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "producer_ffmpeg.h"
 #include "filter_ffmpeg_dub.h"
+#include "consumer_ffmpeg.h"
 
 void *mlt_create_producer( char *id, void *arg )
 {
@@ -44,6 +45,8 @@ void *mlt_create_transition( char *id, void *arg )
 
 void *mlt_create_consumer( char *id, void *arg )
 {
+       if ( !strcmp( id, "ffmpeg" ) )
+               return consumer_ffmpeg_init( arg );
        return NULL;
 }
 
index 95763dfff4790267ce75e8d0474bb65e458c6a2f..3f9c8df2c162b51030db12d6462bf039c5d8a74e 100644 (file)
@@ -142,7 +142,7 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this )
                        char command[ 1024 ] = "";
                        float position = mlt_producer_position( &this->parent );
 
-                       if ( video_loop ) position = 0;
+                       if ( video_loop || position < 0 ) position = 0;
 
                        sprintf( command, "%s/ffmpeg/video.sh \"%s\" \"%s\" \"%s\" %f %f 2>/dev/null",
                                                          mlt_prefix,
@@ -181,7 +181,7 @@ FILE *producer_ffmpeg_run_audio( producer_ffmpeg this )
                        char command[ 1024 ] = "";
                        float position = mlt_producer_position( &this->parent );
 
-                       if ( audio_loop ) position = 0;
+                       if ( audio_loop || position < 0 ) position = 0;
 
                        sprintf( command, "%s/ffmpeg/audio.sh \"%s\" \"%s\" %f %d %d %d 2>/dev/null",
                                                          mlt_prefix,
@@ -242,11 +242,7 @@ static int sample_calculator( float fps, int frequency, int64_t position )
 {
        int samples = 0;
 
-       if ( fps == 25 )
-       {
-               samples = frequency / 25;
-       }
-       else if ( fps >= 29.97 && fps < 29.98 )
+       if ( fps > 29 && fps <= 30 )
        {
                samples = frequency / 30;
 
@@ -280,10 +276,9 @@ static int sample_calculator( float fps, int frequency, int64_t position )
                                samples = 0;
                }
        }
-       else
+       else if ( fps != 0 )
        {
-               if ( fps != 0 )
-                       samples = frequency / fps;
+               samples = frequency / fps;
        }
 
        return samples;
@@ -456,9 +451,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
        mlt_properties_set_double( properties, "speed", speed );
 
        // Set the out point on the producer
-       if ( !this->end_of_video || !this->end_of_audio )
-               mlt_producer_set_in_and_out( &this->parent, mlt_producer_get_in( &this->parent ), mlt_producer_position( &this->parent ) + 1 );
-       else
+       if ( this->end_of_video && this->end_of_audio )
                mlt_producer_set_in_and_out( &this->parent, mlt_producer_get_in( &this->parent ), mlt_producer_position( &this->parent ) );
 
        // Update timecode on the frame we're creating
index 06b32c652d76c132d1bb50a781d29c1eea4b62d9..7114979ae3538a7633a2d1aa03bf8776e7f60e10 100644 (file)
@@ -90,7 +90,6 @@ mlt_producer producer_pixbuf_init( const char *filename )
                                }
                        } 
                        mlt_properties_set_timecode( properties, "out", this->count );
-                       mlt_properties_set_timecode( properties, "playtime", this->count );
                }
                else if ( strstr( filename, "/.all." ) != NULL )
                {
@@ -118,7 +117,6 @@ mlt_producer producer_pixbuf_init( const char *filename )
                        }
 
                        mlt_properties_set_timecode( properties, "out", this->count );
-                       mlt_properties_set_timecode( properties, "playtime", this->count );
                        free( de );
                        free( dir_name );
                }
@@ -127,7 +125,6 @@ mlt_producer producer_pixbuf_init( const char *filename )
                        this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) );
                        this->filenames[ this->count ++ ] = strdup( filename );
                        mlt_properties_set_timecode( properties, "out", 1 );
-                       mlt_properties_set_timecode( properties, "playtime", 1 );
                }
 
                // Initialise gobject types
index 7ad3414321cd90f3533c9fd5a40fcf24e0315053..714fc66f5a6351512192b8b14b781d74601415ac 100644 (file)
@@ -148,7 +148,7 @@ static void sdl_unlock_display( )
                SDL_UnlockSurface( screen );
 }
 
-void sdl_fill_audio( void *udata, uint8_t *stream, int len )
+static void sdl_fill_audio( void *udata, uint8_t *stream, int len )
 {
        consumer_sdl this = udata;