{
mlt_position position = mlt_frame_get_position( *frame );
if ( position >= in && ( out == 0 || position <= out ) )
- {
- mlt_frame_set_position( *frame, position - in );
*frame = mlt_filter_process( this, *frame );
- mlt_frame_set_position( *frame, position + in );
- }
return 0;
}
else
if ( !mlt_producer_is_cut( this ) )
{
+ // Get the properties of this producer
+ mlt_properties properties = mlt_producer_properties( this );
+
// Determine eof handling
char *eof = mlt_properties_get( mlt_producer_properties( this ), "eof" );
+ // Get the speed of the producer
+ double speed = mlt_producer_get_speed( this );
+
+ // We need to use the clone if it's specified
+ mlt_producer clone = mlt_properties_get_data( properties, "use_clone", NULL );
+
+ // If no clone is specified, use this
+ clone = clone == NULL ? this : clone;
+
// A properly instatiated producer will have a get_frame method...
if ( this->get_frame == NULL || ( !strcmp( eof, "continue" ) && mlt_producer_position( this ) > mlt_producer_get_out( this ) ) )
{
else
{
// Get the frame from the implementation
- result = this->get_frame( this, frame, index );
+ result = this->get_frame( clone, frame, index );
}
// Copy the fps and speed of the producer onto the frame
- mlt_properties properties = mlt_frame_properties( *frame );
- double speed = mlt_producer_get_speed( this );
+ 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 ) );
}
else
{
+ // Get the parent of this cut
+ mlt_producer parent = mlt_producer_cut_parent( this );
+
+ // Get the properties of the parent
+ mlt_properties parent_properties = mlt_producer_properties( parent );
+
+ // Get the properties of the cut
mlt_properties properties = mlt_producer_properties( this );
+
+ // Determine the clone index
int clone_index = mlt_properties_get_int( properties, "_clone" );
+
+ // Determine the clone to use
mlt_producer clone = this;
+
if ( clone_index > 0 )
{
char key[ 25 ];
}
else
{
- clone = mlt_producer_cut_parent( this );
+ clone = parent;
}
+
+ // We need to seek to the correct position in the clone
mlt_producer_seek( clone, mlt_producer_get_in( this ) + mlt_properties_get_int( properties, "_position" ) );
- result = producer_get_frame( mlt_producer_service( clone ), frame, index );
- double speed = mlt_producer_get_speed( this );
- mlt_properties_set_double( mlt_frame_properties( *frame ), "_speed", speed );
- mlt_producer_prepare_next( clone );
+
+ // Assign the clone property to the parent
+ mlt_properties_set_data( parent_properties, "use_clone", clone, 0, NULL, NULL );
+
+ // Now get the frame from the parents service
+ result = mlt_service_get_frame( mlt_producer_service( parent ), frame, index );
+
+ // We're done with the clone now
+ mlt_properties_set_data( parent_properties, "use_clone", NULL, 0, NULL, NULL );
}
return result;
mlt_position this_in = mlt_properties_get_position( service_properties, "in" );
mlt_position this_out = mlt_properties_get_position( service_properties, "out" );
- // Hmm - special case for cuts - apply filters from the parent first
- if ( mlt_properties_get_int( service_properties, "_cut" ) )
- {
- mlt_service_apply_filters( ( mlt_service )mlt_properties_get_data( service_properties, "_cut_parent", NULL ), frame, 0 );
- position -= this_in;
- mlt_frame_set_position( frame, position );
- }
-
if ( index == 0 || mlt_properties_get_int( service_properties, "_filter_private" ) == 0 )
{
// Process the frame with the attached filters
{
mlt_properties_set_position( frame_properties, "in", 0 );
mlt_properties_set_position( frame_properties, "out", out == 0 ? this_out - this_in : out - in );
- mlt_frame_set_position( frame, position - in );
mlt_filter_process( base->filters[ i ], frame );
mlt_service_apply_filters( mlt_filter_service( base->filters[ i ] ), frame, index + 1 );
- mlt_frame_set_position( frame, position + in );
}
}
}
}
-
- if ( mlt_properties_get_int( service_properties, "_cut" ) )
- {
- mlt_properties_set_position( frame_properties, "in", this_in );
- mlt_properties_set_position( frame_properties, "out", this_out );
- mlt_frame_set_position( frame, position + this_in );
- }
}
/** Obtain a frame.
// Now stack callbacks
if ( audio != NULL )
{
- mlt_properties audio_properties = mlt_frame_properties( audio );
mlt_frame_push_audio( *frame, audio );
( *frame )->get_audio = producer_get_audio;
- mlt_properties_set_position( frame_properties, "_position", mlt_properties_get_position( audio_properties, "_position" ) );
}
if ( video != NULL )
mlt_properties_set_int( frame_properties, "width", mlt_properties_get_int( video_properties, "width" ) );
mlt_properties_set_int( frame_properties, "height", mlt_properties_get_int( video_properties, "height" ) );
mlt_properties_set_double( frame_properties, "aspect_ratio", mlt_properties_get_double( video_properties, "aspect_ratio" ) );
- mlt_properties_set_position( frame_properties, "_position", mlt_properties_get_position( video_properties, "_position" ) );
}
mlt_frame_set_position( *frame, mlt_producer_frame( parent ) );
pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, buffer );
// Write the compressed frame in the media file
- pkt.pts= c->coded_frame->pts;
+ if ( c->coded_frame )
+ pkt.pts= c->coded_frame->pts;
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= audio_st->index;
pkt.data= audio_outbuf;
- if ( av_write_frame( oc, &pkt ) != 0)
+ if ( av_interleaved_write_frame( oc, &pkt ) != 0)
fprintf(stderr, "Error while writing audio frame\n");
}
else
AVPacket pkt;
av_init_packet( &pkt );
- pkt.pts= c->coded_frame->pts;
+ if ( c->coded_frame )
+ pkt.pts= c->coded_frame->pts;
if(c->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= video_st->index;
pkt.size= out_size;
// write the compressed frame in the media file
- ret = av_write_frame(oc, &pkt);
+ ret = av_interleaved_write_frame(oc, &pkt);
}
}
frame_count++;
}
// Set the original position on the frame
- mlt_frame_set_position( frame, mlt_properties_get_int( feed, "position" ) );
+ mlt_frame_set_position( frame, mlt_properties_get_int( feed, "position" ) - mlt_properties_get_int( feed, "in" ) );
// Process the filter
mlt_filter_process( requested, frame );
char *name = mlt_properties_get( mlt_filter_properties( this ), "_unique_id" );
// Assign the current position to the name
- mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) );
+ mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
// Push the filter on to the stack
mlt_frame_push_service( frame, this );
char *name = mlt_properties_get( mlt_filter_properties( this ), "_unique_id" );
// Assign the current position to the name
- mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) );
+ mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
// Push the frame filter
mlt_frame_push_service( frame, this );