From c369d4f7d2eefe0fb79accd8218400fac2d265fc Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Sat, 3 Jan 2004 16:26:07 +0000 Subject: [PATCH] more complete next/prev clip behaviour git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@36 d19143bc-622f-0410-bfdd-b5b2a6649095 --- mlt/src/framework/mlt_multitrack.c | 134 ++++++++++++++++++------------ mlt/src/framework/mlt_playlist.c | 4 + mlt/src/framework/mlt_producer.c | 5 +- mlt/src/inigo/inigo.c | 3 - mlt/src/modules/ffmpeg/producer_ffmpeg.c | 33 ++++--- src/framework/mlt_multitrack.c | 134 ++++++++++++++++++------------ src/framework/mlt_playlist.c | 4 + src/framework/mlt_producer.c | 5 +- src/inigo/inigo.c | 3 - src/modules/ffmpeg/producer_ffmpeg.c | 33 ++++--- 10 files changed, 212 insertions(+), 146 deletions(-) diff --git a/mlt/src/framework/mlt_multitrack.c b/mlt/src/framework/mlt_multitrack.c index d3496de..9db2aad 100644 --- a/mlt/src/framework/mlt_multitrack.c +++ b/mlt/src/framework/mlt_multitrack.c @@ -60,6 +60,7 @@ mlt_multitrack mlt_multitrack_init( ) mlt_properties properties = mlt_multitrack_properties( this ); producer->get_frame = producer_get_frame; mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); + mlt_properties_set( properties, "log_id", "multitrack" ); } else { @@ -121,7 +122,7 @@ void mlt_multitrack_refresh( mlt_multitrack this ) if ( producer != NULL ) { // Determine the longest length - length = mlt_producer_get_length( producer ) > length ? mlt_producer_get_length( producer ) : length; + length = mlt_producer_get_playtime( producer ) > length ? mlt_producer_get_playtime( producer ) : length; // Handle fps if ( fps == 0 ) @@ -147,6 +148,9 @@ void mlt_multitrack_refresh( mlt_multitrack this ) } /** Connect a producer to a given track. + + Note that any producer can be connected here, but see special case treatment + of playlist in clip point determination below. */ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ) @@ -180,6 +184,75 @@ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int trac return result; } +/** Determine the clip point. + + Special case here: a 'producer' has no concept of multiple clips - only the + playlist and multitrack producers have clip functionality. Further to that a + multitrack determines clip information from any connected tracks that happen + to be playlists. + + Additionally, it must locate clips in the correct order, for example, consider + the following track arrangement: + + playlist1 |0.0 |b0.0 |0.1 |0.1 |0.2 | + playlist2 |b1.0 |1.0 |b1.1 |1.1 | + + Note - b clips represent blanks. They are also reported as clip positions. + + When extracting clip positions from these playlists, we should get a sequence of: + + 0.0, 1.0, b0.0, 0.1, b1.1, 1.1, 0.1, 0.2, [out of playlist2], [out of playlist1] +*/ + +mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ) +{ + int first = 1; + mlt_timecode position = 0; + int i = 0; + + // Loop through each of the tracks + for ( i = 0; i < this->count; i ++ ) + { + // Get the producer for this track + mlt_producer producer = this->list[ i ]; + + // If it's assigned... + 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; +} + /** Get frame method. Special case here: The multitrack must be used in a conjunction with a downstream @@ -236,15 +309,18 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind // Generate a test frame *frame = mlt_frame_init( ); - // Let tractor know if we've reached the end - mlt_properties_set_int( mlt_frame_properties( *frame ), "last_track", index >= this->count ); - // Update timecode on the frame we're creating mlt_frame_set_timecode( *frame, mlt_producer_position( parent ) ); // Move on to the next frame if ( index >= this->count ) + { + // Let tractor know if we've reached the end + mlt_properties_set_int( mlt_frame_properties( *frame ), "last_track", 1 ); + + // Move to the next frame mlt_producer_prepare_next( parent ); + } // Refresh our stats mlt_multitrack_refresh( this ); @@ -253,56 +329,6 @@ 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. */ diff --git a/mlt/src/framework/mlt_playlist.c b/mlt/src/framework/mlt_playlist.c index ed33da9..7a2ad65 100644 --- a/mlt/src/framework/mlt_playlist.c +++ b/mlt/src/framework/mlt_playlist.c @@ -113,6 +113,8 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer // Get the fps of the first producer double fps = mlt_properties_get_double( mlt_playlist_properties( this ), "first_fps" ); + mlt_timecode playtime = mlt_producer_get_playtime( mlt_playlist_producer( this ) ) + out - in; + // If fps is 0 if ( fps == 0 ) { @@ -147,6 +149,8 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer mlt_properties_set_double( mlt_playlist_properties( this ), "first_fps", fps ); mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps ); + mlt_properties_set_timecode( mlt_playlist_properties( this ), "length", playtime ); + mlt_properties_set_timecode( mlt_playlist_properties( this ), "out", playtime ); return 0; } diff --git a/mlt/src/framework/mlt_producer.c b/mlt/src/framework/mlt_producer.c index 164ed59..87c2f08 100644 --- a/mlt/src/framework/mlt_producer.c +++ b/mlt/src/framework/mlt_producer.c @@ -58,10 +58,11 @@ int mlt_producer_init( mlt_producer this, void *child ) 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", 3600.0 ); - mlt_properties_set_timecode( properties, "length", 3600.0 ); + mlt_properties_set_timecode( properties, "out", 36000.0 ); + mlt_properties_set_timecode( properties, "length", 36000.0 ); mlt_properties_set_int( properties, "known_length", 1 ); mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 ); + mlt_properties_set( properties, "log_id", "multitrack" ); // Override service get_frame parent->get_frame = producer_get_frame; diff --git a/mlt/src/inigo/inigo.c b/mlt/src/inigo/inigo.c index 42145f5..bc087ba 100644 --- a/mlt/src/inigo/inigo.c +++ b/mlt/src/inigo/inigo.c @@ -89,7 +89,6 @@ void transport_action( mlt_producer producer, char *value ) { 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': @@ -97,7 +96,6 @@ void transport_action( mlt_producer producer, char *value ) { 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': @@ -105,7 +103,6 @@ void transport_action( mlt_producer producer, char *value ) { mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 ); mlt_producer_seek( producer, time ); - mlt_producer_prepare_next( producer ); } break; } diff --git a/mlt/src/modules/ffmpeg/producer_ffmpeg.c b/mlt/src/modules/ffmpeg/producer_ffmpeg.c index 3f9c8df..8777fb1 100644 --- a/mlt/src/modules/ffmpeg/producer_ffmpeg.c +++ b/mlt/src/modules/ffmpeg/producer_ffmpeg.c @@ -88,6 +88,8 @@ mlt_producer producer_ffmpeg_init( char *file ) mlt_properties_set_int( properties, "audio_channels", 2 ); mlt_properties_set_int( properties, "audio_track", 0 ); + mlt_properties_set( properties, "log_id", file ); + this->buffer = malloc( 1024 * 1024 * 2 ); return producer; @@ -119,7 +121,7 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma return 0; } -FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) +FILE *producer_ffmpeg_run_video( producer_ffmpeg this, mlt_timecode position ) { if ( this->video == NULL ) { @@ -140,9 +142,6 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) float video_rate = mlt_properties_get_double( properties, "fps" ); char *video_size = mlt_properties_get( properties, "video_size" ); char command[ 1024 ] = ""; - float position = mlt_producer_position( &this->parent ); - - if ( video_loop || position < 0 ) position = 0; sprintf( command, "%s/ffmpeg/video.sh \"%s\" \"%s\" \"%s\" %f %f 2>/dev/null", mlt_prefix, @@ -150,7 +149,7 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) video_file, video_size, video_rate, - position ); + ( float )position ); this->video = popen( command, "r" ); } @@ -158,7 +157,7 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) return this->video; } -FILE *producer_ffmpeg_run_audio( producer_ffmpeg this ) +FILE *producer_ffmpeg_run_audio( producer_ffmpeg this, mlt_timecode position ) { // Get the producer mlt_producer producer = &this->parent; @@ -179,15 +178,12 @@ FILE *producer_ffmpeg_run_audio( producer_ffmpeg this ) int channels = mlt_properties_get_int( properties, "audio_channels" ); int track = mlt_properties_get_int( properties, "audio_track" ); char command[ 1024 ] = ""; - float position = mlt_producer_position( &this->parent ); - - if ( audio_loop || position < 0 ) position = 0; sprintf( command, "%s/ffmpeg/audio.sh \"%s\" \"%s\" %f %d %d %d 2>/dev/null", mlt_prefix, audio_type, audio_file, - position, + ( float )position, frequency, channels, track ); @@ -226,13 +222,13 @@ static void producer_ffmpeg_position( producer_ffmpeg this, uint64_t requested, } // This is the next frame we expect - this->expected = mlt_producer_frame( &this->parent ) + 1; + this->expected = requested + 1; // Open the pipe - this->video = producer_ffmpeg_run_video( this ); + this->video = producer_ffmpeg_run_video( this, 0 ); // Open the audio pipe - this->audio = producer_ffmpeg_run_audio( this ); + this->audio = producer_ffmpeg_run_audio( this, 0 ); // We should be open now this->open = 1; @@ -437,7 +433,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Set the audio pipe mlt_properties_set_data( properties, "producer_ffmpeg", this, 0, NULL, NULL ); - mlt_properties_set_int( properties, "end_of_clip", this->end_of_video && this->end_of_audio ); // Hmm - register audio callback ( *frame )->get_audio = producer_get_audio; @@ -445,14 +440,24 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Get the additional properties double aspect_ratio = mlt_properties_get_double( producer_properties, "aspect_ratio" ); double speed = mlt_properties_get_double( producer_properties, "speed" ); + char *video_file = mlt_properties_get( producer_properties, "video_file" ); // Set them on the frame mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio ); mlt_properties_set_double( properties, "speed", speed ); + if ( strchr( video_file, '/' ) != NULL ) + mlt_properties_set( properties, "file", strrchr( video_file, '/' ) + 1 ); + else + mlt_properties_set( properties, "file", video_file ); + // Set the out point on the producer if ( this->end_of_video && this->end_of_audio ) + { + mlt_properties_set_int( properties, "end_of_clip", 1 ); + mlt_properties_set_timecode( producer_properties, "length", mlt_producer_position( &this->parent ) ); 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 mlt_frame_set_timecode( *frame, mlt_producer_position( producer ) ); diff --git a/src/framework/mlt_multitrack.c b/src/framework/mlt_multitrack.c index d3496de..9db2aad 100644 --- a/src/framework/mlt_multitrack.c +++ b/src/framework/mlt_multitrack.c @@ -60,6 +60,7 @@ mlt_multitrack mlt_multitrack_init( ) mlt_properties properties = mlt_multitrack_properties( this ); producer->get_frame = producer_get_frame; mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); + mlt_properties_set( properties, "log_id", "multitrack" ); } else { @@ -121,7 +122,7 @@ void mlt_multitrack_refresh( mlt_multitrack this ) if ( producer != NULL ) { // Determine the longest length - length = mlt_producer_get_length( producer ) > length ? mlt_producer_get_length( producer ) : length; + length = mlt_producer_get_playtime( producer ) > length ? mlt_producer_get_playtime( producer ) : length; // Handle fps if ( fps == 0 ) @@ -147,6 +148,9 @@ void mlt_multitrack_refresh( mlt_multitrack this ) } /** Connect a producer to a given track. + + Note that any producer can be connected here, but see special case treatment + of playlist in clip point determination below. */ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ) @@ -180,6 +184,75 @@ int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int trac return result; } +/** Determine the clip point. + + Special case here: a 'producer' has no concept of multiple clips - only the + playlist and multitrack producers have clip functionality. Further to that a + multitrack determines clip information from any connected tracks that happen + to be playlists. + + Additionally, it must locate clips in the correct order, for example, consider + the following track arrangement: + + playlist1 |0.0 |b0.0 |0.1 |0.1 |0.2 | + playlist2 |b1.0 |1.0 |b1.1 |1.1 | + + Note - b clips represent blanks. They are also reported as clip positions. + + When extracting clip positions from these playlists, we should get a sequence of: + + 0.0, 1.0, b0.0, 0.1, b1.1, 1.1, 0.1, 0.2, [out of playlist2], [out of playlist1] +*/ + +mlt_timecode mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ) +{ + int first = 1; + mlt_timecode position = 0; + int i = 0; + + // Loop through each of the tracks + for ( i = 0; i < this->count; i ++ ) + { + // Get the producer for this track + mlt_producer producer = this->list[ i ]; + + // If it's assigned... + 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; +} + /** Get frame method. Special case here: The multitrack must be used in a conjunction with a downstream @@ -236,15 +309,18 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind // Generate a test frame *frame = mlt_frame_init( ); - // Let tractor know if we've reached the end - mlt_properties_set_int( mlt_frame_properties( *frame ), "last_track", index >= this->count ); - // Update timecode on the frame we're creating mlt_frame_set_timecode( *frame, mlt_producer_position( parent ) ); // Move on to the next frame if ( index >= this->count ) + { + // Let tractor know if we've reached the end + mlt_properties_set_int( mlt_frame_properties( *frame ), "last_track", 1 ); + + // Move to the next frame mlt_producer_prepare_next( parent ); + } // Refresh our stats mlt_multitrack_refresh( this ); @@ -253,56 +329,6 @@ 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. */ diff --git a/src/framework/mlt_playlist.c b/src/framework/mlt_playlist.c index ed33da9..7a2ad65 100644 --- a/src/framework/mlt_playlist.c +++ b/src/framework/mlt_playlist.c @@ -113,6 +113,8 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer // Get the fps of the first producer double fps = mlt_properties_get_double( mlt_playlist_properties( this ), "first_fps" ); + mlt_timecode playtime = mlt_producer_get_playtime( mlt_playlist_producer( this ) ) + out - in; + // If fps is 0 if ( fps == 0 ) { @@ -147,6 +149,8 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer mlt_properties_set_double( mlt_playlist_properties( this ), "first_fps", fps ); mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps ); + mlt_properties_set_timecode( mlt_playlist_properties( this ), "length", playtime ); + mlt_properties_set_timecode( mlt_playlist_properties( this ), "out", playtime ); return 0; } diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index 164ed59..87c2f08 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -58,10 +58,11 @@ int mlt_producer_init( mlt_producer this, void *child ) 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", 3600.0 ); - mlt_properties_set_timecode( properties, "length", 3600.0 ); + mlt_properties_set_timecode( properties, "out", 36000.0 ); + mlt_properties_set_timecode( properties, "length", 36000.0 ); mlt_properties_set_int( properties, "known_length", 1 ); mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 ); + mlt_properties_set( properties, "log_id", "multitrack" ); // Override service get_frame parent->get_frame = producer_get_frame; diff --git a/src/inigo/inigo.c b/src/inigo/inigo.c index 42145f5..bc087ba 100644 --- a/src/inigo/inigo.c +++ b/src/inigo/inigo.c @@ -89,7 +89,6 @@ void transport_action( mlt_producer producer, char *value ) { 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': @@ -97,7 +96,6 @@ void transport_action( mlt_producer producer, char *value ) { 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': @@ -105,7 +103,6 @@ void transport_action( mlt_producer producer, char *value ) { mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 ); mlt_producer_seek( producer, time ); - mlt_producer_prepare_next( producer ); } break; } diff --git a/src/modules/ffmpeg/producer_ffmpeg.c b/src/modules/ffmpeg/producer_ffmpeg.c index 3f9c8df..8777fb1 100644 --- a/src/modules/ffmpeg/producer_ffmpeg.c +++ b/src/modules/ffmpeg/producer_ffmpeg.c @@ -88,6 +88,8 @@ mlt_producer producer_ffmpeg_init( char *file ) mlt_properties_set_int( properties, "audio_channels", 2 ); mlt_properties_set_int( properties, "audio_track", 0 ); + mlt_properties_set( properties, "log_id", file ); + this->buffer = malloc( 1024 * 1024 * 2 ); return producer; @@ -119,7 +121,7 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma return 0; } -FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) +FILE *producer_ffmpeg_run_video( producer_ffmpeg this, mlt_timecode position ) { if ( this->video == NULL ) { @@ -140,9 +142,6 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) float video_rate = mlt_properties_get_double( properties, "fps" ); char *video_size = mlt_properties_get( properties, "video_size" ); char command[ 1024 ] = ""; - float position = mlt_producer_position( &this->parent ); - - if ( video_loop || position < 0 ) position = 0; sprintf( command, "%s/ffmpeg/video.sh \"%s\" \"%s\" \"%s\" %f %f 2>/dev/null", mlt_prefix, @@ -150,7 +149,7 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) video_file, video_size, video_rate, - position ); + ( float )position ); this->video = popen( command, "r" ); } @@ -158,7 +157,7 @@ FILE *producer_ffmpeg_run_video( producer_ffmpeg this ) return this->video; } -FILE *producer_ffmpeg_run_audio( producer_ffmpeg this ) +FILE *producer_ffmpeg_run_audio( producer_ffmpeg this, mlt_timecode position ) { // Get the producer mlt_producer producer = &this->parent; @@ -179,15 +178,12 @@ FILE *producer_ffmpeg_run_audio( producer_ffmpeg this ) int channels = mlt_properties_get_int( properties, "audio_channels" ); int track = mlt_properties_get_int( properties, "audio_track" ); char command[ 1024 ] = ""; - float position = mlt_producer_position( &this->parent ); - - if ( audio_loop || position < 0 ) position = 0; sprintf( command, "%s/ffmpeg/audio.sh \"%s\" \"%s\" %f %d %d %d 2>/dev/null", mlt_prefix, audio_type, audio_file, - position, + ( float )position, frequency, channels, track ); @@ -226,13 +222,13 @@ static void producer_ffmpeg_position( producer_ffmpeg this, uint64_t requested, } // This is the next frame we expect - this->expected = mlt_producer_frame( &this->parent ) + 1; + this->expected = requested + 1; // Open the pipe - this->video = producer_ffmpeg_run_video( this ); + this->video = producer_ffmpeg_run_video( this, 0 ); // Open the audio pipe - this->audio = producer_ffmpeg_run_audio( this ); + this->audio = producer_ffmpeg_run_audio( this, 0 ); // We should be open now this->open = 1; @@ -437,7 +433,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Set the audio pipe mlt_properties_set_data( properties, "producer_ffmpeg", this, 0, NULL, NULL ); - mlt_properties_set_int( properties, "end_of_clip", this->end_of_video && this->end_of_audio ); // Hmm - register audio callback ( *frame )->get_audio = producer_get_audio; @@ -445,14 +440,24 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Get the additional properties double aspect_ratio = mlt_properties_get_double( producer_properties, "aspect_ratio" ); double speed = mlt_properties_get_double( producer_properties, "speed" ); + char *video_file = mlt_properties_get( producer_properties, "video_file" ); // Set them on the frame mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio ); mlt_properties_set_double( properties, "speed", speed ); + if ( strchr( video_file, '/' ) != NULL ) + mlt_properties_set( properties, "file", strrchr( video_file, '/' ) + 1 ); + else + mlt_properties_set( properties, "file", video_file ); + // Set the out point on the producer if ( this->end_of_video && this->end_of_audio ) + { + mlt_properties_set_int( properties, "end_of_clip", 1 ); + mlt_properties_set_timecode( producer_properties, "length", mlt_producer_position( &this->parent ) ); 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 mlt_frame_set_timecode( *frame, mlt_producer_position( producer ) ); -- 1.7.4.4