Index: libhb/reader.c =================================================================== --- libhb/reader.c (revision 1346) +++ libhb/reader.c (working copy) @@ -304,6 +304,14 @@ if( id == 0xE0 ) { + if( (job->current_frame < job->start_frame) ) + { + /* Skip video frames until the requested start, + but keep track of how many have been skipped. */ + job->current_frame++; + return NULL; + } + if( job->indepth_scan ) { /* @@ -318,6 +326,13 @@ return fifos; } } + + if( (job->current_frame < job->start_frame) ) + { + /* Skip audio and subtitle samples until + the requested video start frame is reached. */ + return NULL; + } if( job->indepth_scan ) { /* Index: libhb/sync.c =================================================================== --- libhb/sync.c (revision 1346) +++ libhb/sync.c (working copy) @@ -270,6 +270,22 @@ return HB_WORK_DONE; } + if(pv->count_frames > job->end_frame) + { + /* If we've reached the requested last frame, end early. */ + hb_log("Hit %i frames, ending early.", job->end_frame); + + pv->done = 1; + + // Drop an empty buffer into our output to ensure that things + // get flushed all the way out. + hb_buffer_t * buf_tmp; + buf_tmp = hb_buffer_init(0); // Empty end buffer + hb_fifo_push( job->fifo_sync, buf_tmp ); + + return HB_WORK_DONE; + } + if( hb_thread_has_exited( job->reader ) && !hb_fifo_size( job->fifo_mpeg2 ) && !hb_fifo_size( job->fifo_raw ) ) @@ -310,7 +326,7 @@ { /* This is our first frame */ pv->pts_offset = 0; - if ( cur->start != 0 ) + if ( (cur->start != 0 && job->start_frame == 0) || (job->start_frame == job->current_frame) ) { /* * The first pts from a dvd should always be zero but Index: libhb/work.c =================================================================== --- libhb/work.c (revision 1346) +++ libhb/work.c (working copy) @@ -122,6 +122,11 @@ hb_log( " + device %s", title->dvd ); hb_log( " + title %d, chapter(s) %d to %d", title->index, job->chapter_start, job->chapter_end ); + + job->start_frame = 10040; + job->end_frame = 500; + job->current_frame = 0; + if ( job->pixel_ratio == 1 ) { /* Correct the geometry of the output movie when using PixelRatio */ Index: libhb/common.h =================================================================== --- libhb/common.h (revision 1346) +++ libhb/common.h (working copy) @@ -275,6 +275,10 @@ int subtitle_force; char * native_language; + int start_frame; + int end_frame; + int current_frame; + #ifdef __LIBHB__ /* Internal data */ hb_handle_t * h;