static void apply_profile_properties( mlt_profile profile, mlt_properties properties )
{
+ mlt_event_block( g_event_listener );
mlt_properties_set_double( properties, "fps", mlt_profile_fps( profile ) );
mlt_properties_set_int( properties, "frame_rate_num", profile->frame_rate_num );
mlt_properties_set_int( properties, "frame_rate_den", profile->frame_rate_den );
mlt_properties_set_double( properties, "display_ratio", mlt_profile_dar( profile ) );
mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num );
mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num );
+ mlt_event_unblock( g_event_listener );
}
static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name )
// Locate the profile
mlt_profile_select( mlt_properties_get( properties, "profile" ) );
- // Stop listening to this
- mlt_event_block( g_event_listener );
-
// Apply to properties
apply_profile_properties( mlt_profile_get(), properties );
}
+ else if ( !strcmp( name, "frame_rate_num" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->frame_rate_num = mlt_properties_get_int( properties, "frame_rate_num" );
+ mlt_properties_set_double( properties, "fps", mlt_profile_fps( NULL ) );
+ }
+ else if ( !strcmp( name, "frame_rate_den" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->frame_rate_den = mlt_properties_get_int( properties, "frame_rate_den" );
+ mlt_properties_set_double( properties, "fps", mlt_profile_fps( NULL ) );
+ }
+ else if ( !strcmp( name, "width" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->width = mlt_properties_get_int( properties, "width" );
+ }
+ else if ( !strcmp( name, "height" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->height = mlt_properties_get_int( properties, "height" );
+ }
+ else if ( !strcmp( name, "progressive" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->progressive = mlt_properties_get_int( properties, "progressive" );
+ }
+ else if ( !strcmp( name, "sample_aspect_num" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->sample_aspect_num = mlt_properties_get_int( properties, "sample_aspect_num" );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) );
+ }
+ else if ( !strcmp( name, "sample_aspect_den" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->sample_aspect_den = mlt_properties_get_int( properties, "sample_aspect_den" );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) );
+ }
+ else if ( !strcmp( name, "display_aspect_num" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->display_aspect_num = mlt_properties_get_int( properties, "display_aspect_num" );
+ mlt_properties_set_double( properties, "display_ratio", mlt_profile_dar( NULL ) );
+ }
+ else if ( !strcmp( name, "display_aspect_den" ) )
+ {
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
+ mlt_profile_get()->display_aspect_den = mlt_properties_get_int( properties, "display_aspect_den" );
+ mlt_properties_set_double( properties, "display_ratio", mlt_profile_dar( NULL ) );
+ }
}
static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args )
int mlt_consumer_start( mlt_consumer this )
{
+ // Stop listening to the property-changed event
+ mlt_event_block( g_event_listener );
+
// Get the properies
mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
{
mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( this ), "running", 0 );
mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-stopped", NULL );
+ mlt_event_unblock( g_event_listener );
}
/** Stop the consumer.
mlt_audio_format format = mlt_audio_pcm;
int frequency = 32000; // lower frequency available?
int channels = 2;
- double fps = mlt_properties_get_double( properties, "fps" );
+ double fps = mlt_profile_fps( NULL );
int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) );
// Get the pcm data
// We need to ensure that the multitrack reports the longest track as its length
mlt_position length = 0;
- // We need to ensure that fps are the same on all services
- double fps = 0;
-
// Obtain stats on all connected services
for ( i = 0; i < this->count; i ++ )
{
// Determine the longest length
//if ( !mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "hide" ) )
length = mlt_producer_get_playtime( producer ) > length ? mlt_producer_get_playtime( producer ) : length;
-
- // Handle fps
- if ( fps == 0 )
- {
- // This is the first producer, so it controls the fps
- fps = mlt_producer_get_fps( producer );
- }
- else if ( fps != mlt_producer_get_fps( producer ) )
- {
- // Generate a warning for now - the following attempt to fix may fail
- fprintf( stderr, "Warning: fps mismatch on track %d\n", i );
-
- // It should be safe to impose fps on an image producer, but not necessarily safe for video
- mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( producer ), "fps", fps );
- }
}
}
mlt_properties_set_position( properties, "length", length );
mlt_events_unblock( properties, properties );
mlt_properties_set_position( properties, "out", length - 1 );
- mlt_properties_set_double( properties, "fps", fps );
}
/** Listener for producers on the playlist.
{
// Obtain the properties
mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this );
-
- // Get the fps of the first producer
- double fps = mlt_properties_get_double( properties, "first_fps" );
int i = 0;
mlt_position frame_count = 0;
mlt_producer producer = this->list[ i ]->producer;
int current_length = mlt_producer_get_out( producer ) - mlt_producer_get_in( producer ) + 1;
- // If fps is 0
- if ( fps == 0 )
- {
- // Inherit it from the producer
- fps = mlt_producer_get_fps( producer );
- }
- else if ( fps != mlt_properties_get_double( MLT_PRODUCER_PROPERTIES( producer ), "fps" ) )
- {
- // Generate a warning for now - the following attempt to fix may fail
- fprintf( stderr, "Warning: fps mismatch on playlist producer %d\n", this->count );
-
- // It should be safe to impose fps on an image producer, but not necessarily safe for video
- mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( producer ), "fps", fps );
- }
-
// Check if the length of the producer has changed
if ( this->list[ i ]->frame_in != mlt_producer_get_in( producer ) ||
this->list[ i ]->frame_out != mlt_producer_get_out( producer ) )
}
// Refresh all properties
- mlt_properties_set_double( properties, "first_fps", fps );
- mlt_properties_set_double( properties, "fps", fps == 0 ? 25 : fps );
mlt_events_block( properties, properties );
mlt_properties_set_position( properties, "length", frame_count );
mlt_events_unblock( properties, properties );
mlt_producer_close( this->list[ i ]->producer );
}
this->count = 0;
- mlt_properties_set_double( MLT_PLAYLIST_PROPERTIES( this ), "first_fps", 0 );
return mlt_playlist_virtual_refresh( this );
}
mlt_properties_set( properties, "mlt_type", "mlt_producer" );
mlt_properties_set_position( properties, "_position", 0.0 );
mlt_properties_set_double( properties, "_frame", 0 );
- mlt_properties_set_double( properties, "fps", mlt_profile_fps( NULL ) );
- mlt_properties_set_int( properties, "frame_rate_num", mlt_profile_get()->frame_rate_num );
- mlt_properties_set_int( properties, "frame_rate_den", mlt_profile_get()->frame_rate_den );
mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) );
mlt_properties_set_double( properties, "_speed", 1.0 );
mlt_properties_set_position( properties, "in", 0 );
double mlt_producer_get_fps( mlt_producer this )
{
- return mlt_properties_get_double( MLT_PRODUCER_PROPERTIES( this ), "fps" );
+ return mlt_profile_fps( NULL );
}
/** Set the in and out points.
// Copy the fps and speed of the producer onto the frame
properties = MLT_FRAME_PROPERTIES( *frame );
mlt_properties_set_double( properties, "_speed", speed );
- mlt_properties_set_double( properties, "fps", mlt_producer_get_fps( this ) );
mlt_properties_set_int( properties, "test_audio", mlt_frame_is_test_audio( *frame ) );
mlt_properties_set_int( properties, "test_image", mlt_frame_is_test_card( *frame ) );
if ( mlt_properties_get_data( properties, "_producer", NULL ) == NULL )
mlt_properties properties = MLT_PRODUCER_PROPERTIES( this );
// We will treat everything with the producer fps
- double fps = mlt_properties_get_double( properties, "fps" );
+ double fps = mlt_producer_get_fps( this );
// Lock the mutex now
avformat_lock( );
params->width = 640;
params->height = 480;
params->time_base= (AVRational){1,25};
- params->device = file;
+ // params->device = file;
params->channels = 2;
params->sample_rate = 48000;
}
+ // XXX: this does not work anymore since avdevice
+ // TODO: make producer_avddevice?
// Parse out params
mrl = strchr( file, '?' );
while ( mrl )
static double producer_time_of_frame( mlt_producer this, mlt_position position )
{
- // Get the properties
- mlt_properties properties = MLT_PRODUCER_PROPERTIES( this );
-
- // Obtain the fps
- double fps = mlt_properties_get_double( properties, "fps" );
-
- // Do the calc
- return ( double )position / fps;
+ return ( double )position / mlt_producer_get_fps( this );
}
static inline void convert_image( AVFrame *frame, uint8_t *buffer, int pix_fmt, mlt_image_format format, int width, int height )
// We may want to use the source fps if available
double source_fps = mlt_properties_get_double( properties, "source_fps" );
- double fps = mlt_properties_get_double( properties, "fps" );
+ double fps = mlt_producer_get_fps( this );
// This is the physical frame position in the source
int req_position = ( int )( position / fps * source_fps + 0.5 );
}
else
{
- int is_pal = mlt_properties_get_double( properties, "fps" ) == 25.0;
+ int is_pal = mlt_producer_get_fps( this ) == 25.0;
aspect_ratio = is_pal ? 59.0/54.0 : 10.0/11.0;
}
source_fps = ( double )codec_context->time_base.den / ( codec_context->time_base.num == 0 ? 1 : codec_context->time_base.num );
// We'll use fps if it's available
- if ( source_fps > 0 && source_fps < 30 )
+ if ( source_fps > 0 )
mlt_properties_set_double( properties, "source_fps", source_fps );
else
- mlt_properties_set_double( properties, "source_fps", mlt_properties_get_double( properties, "fps" ) );
+ mlt_properties_set_double( properties, "source_fps", mlt_producer_get_fps( this ) );
mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio );
// Set the width and height
{
// special case: replace #timecode# with current frame timecode
int pos = mlt_properties_get_int( feed, "position" );
- char *tc = frame_to_timecode( pos, mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "fps" ) );
+ char *tc = frame_to_timecode( pos, mlt_profile_fps( NULL ) );
strcat( result, tc );
free( tc );
}
destroy = 1;
else
mlt_properties_pass( properties, MLT_PRODUCER_PROPERTIES( this->alternative ), "" );
- this->is_pal = mlt_properties_get_int( properties, "fps" ) == 25;
+ this->is_pal = ( ( int ) mlt_producer_get_fps( producer ) ) == 25;
}
else
{
// Calculate default in/out points
double fps = this->is_pal ? 25 : 30000.0 / 1001.0;
- if ( mlt_properties_get_double( properties, "fps" ) == fps )
+ if ( mlt_producer_get_fps( &this->parent ) == fps )
{
if ( this->frames_in_file > 0 )
{
mlt_properties_set_data( props, "group", group, 0, ( mlt_destructor )mlt_properties_close, NULL );
mlt_properties_set_position( props, "length", mlt_producer_get_out( MLT_MULTITRACK_PRODUCER( multitrack ) ) + 1 );
mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( MLT_MULTITRACK_PRODUCER( multitrack ) ) );
- mlt_properties_set_double( props, "fps", mlt_producer_get_fps( MLT_MULTITRACK_PRODUCER( multitrack ) ) );
if ( title != NULL )
mlt_properties_set( props, "title", strchr( title, '/' ) ? strrchr( title, '/' ) + 1 : title );
double length = ov_time_total( ov, -1 );
// We will treat everything with the producer fps
- double fps = mlt_properties_get_double( properties, "fps" );
+ double fps = mlt_producer_get_fps( this );
// Set out and length of file
mlt_properties_set_position( properties, "out", ( length * fps ) - 1 );
static double producer_time_of_frame( mlt_producer this, mlt_position position )
{
- // Get the properties
- mlt_properties properties = MLT_PRODUCER_PROPERTIES( this );
-
- // Obtain the fps
- double fps = mlt_properties_get_double( properties, "fps" );
-
- // Do the calc
- return ( double )position / fps;
+ return ( double )position / mlt_producer_get_fps( this );
}
/** Get the audio from a frame.
mlt_position expected = mlt_properties_get_position( properties, "audio_expected" );
// Get the fps for this producer
- double fps = mlt_properties_get_double( properties, "fps" );
+ double fps = mlt_producer_get_fps( this );
// Get the vorbis info
vorbis_info *vi = ov_info( ov, -1 );
if ( strchr( mlt_properties_get( properties, "clipBegin" ), ':' ) )
// Parse clock value
in = parse_clock_value( mlt_properties_get( properties, "clipBegin" ),
- mlt_properties_get_double( mlt_producer_properties( MLT_PRODUCER( producer ) ), "fps" ) );
+ mlt_producer_get_fps( MLT_PRODUCER( producer ) ) );
else
// Parse frames value
in = mlt_properties_get_position( properties, "clipBegin" );
if ( strchr( mlt_properties_get( properties, "clipEnd" ), ':' ) )
// Parse clock value
out = parse_clock_value( mlt_properties_get( properties, "clipEnd" ),
- mlt_properties_get_double( mlt_producer_properties( MLT_PRODUCER( producer ) ), "fps" ) );
+ mlt_producer_get_fps( MLT_PRODUCER( producer ) ) );
else
// Parse frames value
out = mlt_properties_get_position( properties, "clipEnd" );