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
{
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 )
}
/** 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 )
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
// 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 );
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.
*/
// 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 )
{
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;
}
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;
{
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':
{
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':
{
mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 );
mlt_producer_seek( producer, time );
- mlt_producer_prepare_next( producer );
}
break;
}
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;
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 )
{
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,
video_file,
video_size,
video_rate,
- position );
+ ( float )position );
this->video = popen( command, "r" );
}
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;
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 );
}
// 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;
// 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;
// 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 ) );
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
{
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 )
}
/** 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 )
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
// 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 );
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.
*/
// 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 )
{
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;
}
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;
{
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':
{
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':
{
mlt_timecode time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 );
mlt_producer_seek( producer, time );
- mlt_producer_prepare_next( producer );
}
break;
}
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;
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 )
{
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,
video_file,
video_size,
video_rate,
- position );
+ ( float )position );
this->video = popen( command, "r" );
}
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;
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 );
}
// 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;
// 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;
// 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 ) );