X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_producer.c;h=278d9026957b9455183024663a65c405bbfc11b3;hb=cc8b6005abe30b5f0816b5aa6b87aa6867275228;hp=751e19a9e3066309fd03efd267743c15325a6e97;hpb=9390e8b584f3f717f0a326893c0e37cf187a0a51;p=melted diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index 751e19a..278d902 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -87,6 +87,28 @@ mlt_properties mlt_producer_properties( mlt_producer this ) return mlt_service_properties( &this->parent ); } +/** Convert frame position to timecode. +*/ + +mlt_timecode mlt_producer_time( mlt_producer this, int64_t frame ) +{ + if ( frame < 0 ) + return -1; + else + return ( mlt_timecode )frame / mlt_producer_get_fps( this ); +} + +/** Convert timecode to frame position. +*/ + +int64_t mlt_producer_frame_position( mlt_producer this, mlt_timecode position ) +{ + if ( position < 0 ) + return -1; + else + return ( int64_t )( floor( position * mlt_producer_get_fps( this ) + 0.5 ) ); +} + /** Seek to a specified time code. */ @@ -111,13 +133,13 @@ int mlt_producer_seek( mlt_producer this, mlt_timecode timecode ) /** Seek to a specified absolute frame. */ -int mlt_producer_seek_frame( mlt_producer this, uint64_t frame ) +int mlt_producer_seek_frame( mlt_producer this, int64_t frame ) { // Calculate the time code double timecode = ( frame / mlt_producer_get_fps( this ) ) - mlt_producer_get_in( this ); // If timecode is invalid, then seek on time - if ( timecode < 0 ) + if ( frame < 0 || timecode < 0 ) { // Seek to the in point mlt_producer_seek( this, 0 );