mlt_properties producer_properties = mlt_producer_properties( producer );
// Get the original get_audio
- int ( *get_audio )( mlt_frame, int16_t **, mlt_audio_format *, int *, int *, int * ) = mlt_properties_get_data( frame_properties, "get_audio", NULL );
+ frame->get_audio = mlt_properties_get_data( frame_properties, "get_audio", NULL );
// Call the original get_audio
- get_audio( frame, buffer, format, frequency, channels, samples );
+ mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples );
// Now if our producer is still producing, override the audio
if ( !mlt_properties_get_int( producer_properties, "end_of_clip" ) )
{
// Get the position
- double position = mlt_properties_get_double( producer_properties, "dub_position" );
+ mlt_position position = mlt_properties_get_position( producer_properties, "dub_position" );
// We need a frame from the producer
mlt_frame producer_frame;
+ // Set the FPS
+ mlt_properties_set_double( producer_properties, "fps", mlt_properties_get_double( frame_properties, "fps" ) );
+
// Seek to the position
- mlt_producer_seek_frame( producer, ( int64_t )position );
+ mlt_producer_seek( producer, position );
// Get the next frame
producer->get_frame( producer, &producer_frame, 0 );
mlt_properties_set_data( frame_properties, "ffmpeg_dub_frame", producer_frame, 0, ( mlt_destructor )mlt_frame_close, NULL );
// Incrment the position
- mlt_properties_set_double( producer_properties, "dub_position", position + 1 );
+ mlt_properties_set_position( producer_properties, "dub_position", position + 1 );
}
}
// Obtain the frame properties
mlt_properties frame_properties = mlt_frame_properties( frame );
- // Backup the original get_audio (it's still needed)
- mlt_properties_set_data( frame_properties, "get_audio", frame->get_audio, 0, NULL, NULL );
+ // Get the producer properties
+ mlt_properties producer_properties = mlt_producer_properties( producer );
- // Pass the producer on the frame
- mlt_properties_set_data( frame_properties, "producer", producer, 0, NULL, NULL );
+ // Only do this if we have not reached end of clip and ffmpeg_dub has not already been done
+ if ( !mlt_properties_get_int( producer_properties, "end_of_clip" ) &&
+ mlt_properties_get_data( frame_properties, "get_audio", NULL ) == NULL )
+ {
+ // Backup the original get_audio (it's still needed)
+ mlt_properties_set_data( frame_properties, "get_audio", frame->get_audio, 0, NULL, NULL );
- // Override the get_audio method
- frame->get_audio = filter_get_audio;
+ // Pass the producer on the frame
+ mlt_properties_set_data( frame_properties, "producer", producer, 0, NULL, NULL );
+
+ // Override the get_audio method
+ frame->get_audio = filter_get_audio;
+ }
return frame;
}
mlt_filter filter_ffmpeg_dub_init( char *file )
{
// Create the filter object
- mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter this = mlt_filter_new( );
// Initialise it
- mlt_filter_init( this, NULL );
-
- // Overide the filter process method
- this->process = filter_process;
+ if ( this != NULL )
+ {
+ // Obtain the properties
+ mlt_properties properties = mlt_filter_properties( this );
- // Obtain the properties
- mlt_properties properties = mlt_filter_properties( this );
+ // Create an ffmpeg producer
+ // TODO: THIS SHOULD NOT BE HERE....
+ mlt_producer producer = mlt_factory_producer( "ffmpeg", file );
- // Create an ffmpeg producer
- mlt_producer producer = mlt_factory_producer( "ffmpeg", file );
+ // Overide the filter process method
+ this->process = filter_process;
- // Pass the producer
- mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
+ // Pass the producer
+ mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
- // Initialise the audio frame position
- mlt_properties_set_double( properties, "dub_position", 0 );
+ // Initialise the audio frame position
+ mlt_properties_set_position( properties, "dub_position", 0 );
+ }
return this;
}