From 1ab19c13e332432230ef443483c65135a22d3e00 Mon Sep 17 00:00:00 2001 From: van Date: Mon, 21 Sep 2009 07:18:49 +0000 Subject: Fix bug that was causing one sec. of audio to be dropped on many ffmpeg files. Problem is that audio & video can be interleaved in any order but we drop everything up to the first video frame. Since ffmpeg returns a second of audio per read on an audio stream, if audio started before video we lose the first second of it. Changed to allow either audio or video to signal start 'reader'. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2831 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/reader.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'libhb') diff --git a/libhb/reader.c b/libhb/reader.c index 88617f90b..11cb23b6f 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -333,17 +333,22 @@ static void ReaderFunc( void * _r ) hb_list_rem( list, buf ); fifos = GetFifoForId( r->job, buf->id ); - if ( ! r->saw_video ) + if ( fifos && ! r->saw_video ) { - /* The first video packet defines 'time zero' so discard - data until we get a video packet with a PTS & DTS */ - if ( buf->id == r->title->video_id && buf->start != -1 && - buf->renderOffset != -1 ) + // The first data packet with a PTS from an audio or video stream + // that we're decoding defines 'time zero'. Discard packets until + // we get one. + if ( buf->start != -1 && buf->renderOffset != -1 && + ( buf->id == r->title->video_id || is_audio( r, buf->id ) ) ) { // force a new scr offset computation r->scr_changes = r->demux.scr_changes - 1; + // create a stream state if we don't have one so the + // offset will get computed correctly. + id_to_st( r, buf ); r->saw_video = 1; - hb_log( "reader: first SCR %"PRId64, r->demux.last_scr ); + hb_log( "reader: first SCR %"PRId64" id %d DTS %"PRId64, + r->demux.last_scr, buf->id, buf->renderOffset ); } else { -- cgit v1.2.3