- if ( pkt.dts != AV_NOPTS_VALUE )
- {
- double delay = mlt_properties_get_double( properties, "video_delay" );
- int_position = ( int64_t )( ( av_q2d( stream->time_base ) * pkt.dts + delay ) * source_fps + 0.5 );
- if ( context->start_time != AV_NOPTS_VALUE )
- int_position -= ( int64_t )( context->start_time * source_fps / AV_TIME_BASE + 0.5 );
- if ( int_position == self->last_position )
- int_position = self->last_position + 1;
- }
- mlt_log_debug( MLT_PRODUCER_SERVICE(producer), "pkt.dts %"PRId64" req_pos %"PRId64" cur_pos %"PRId64" pkt_pos %"PRId64"\n",
- pkt.dts, req_position, self->current_position, int_position );
- // Make a dumb assumption on streams that contain wild timestamps
- if ( abs( req_position - int_position ) > 999 )
- {
- int_position = req_position;
- mlt_log_debug( MLT_PRODUCER_SERVICE(producer), " WILD TIMESTAMP!" );
- }
+ self->invalid_pts_counter = 0;
+ }
+ int64_t pts = ( use_pts && pkt.pts != AV_NOPTS_VALUE )? pkt.pts : pkt.dts;
+ if ( pts != AV_NOPTS_VALUE )
+ {
+ if ( !self->seekable && self->first_pts == AV_NOPTS_VALUE )
+ self->first_pts = pts;
+ if ( self->first_pts != AV_NOPTS_VALUE )
+ pts -= self->first_pts;
+ else if ( context->start_time != AV_NOPTS_VALUE )
+ pts -= context->start_time;
+ int_position = ( int64_t )( ( av_q2d( stream->time_base ) * pts + delay ) * source_fps + 0.5 );
+ if ( int_position == self->last_position )
+ int_position = self->last_position + 1;
+ }
+ mlt_log_debug( MLT_PRODUCER_SERVICE(producer),
+ "V pkt.pts %"PRId64" pkt.dts %"PRId64" req_pos %"PRId64" cur_pos %"PRId64" pkt_pos %"PRId64"\n",
+ pkt.pts, pkt.dts, req_position, self->current_position, int_position );
+
+ // Make a dumb assumption on streams that contain wild timestamps
+ if ( abs( req_position - int_position ) > 999 )
+ {
+ int_position = req_position;
+ mlt_log_warning( MLT_PRODUCER_SERVICE(producer), " WILD TIMESTAMP!\n" );