diff options
author | Rodeo <[email protected]> | 2013-05-17 16:09:54 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2013-05-17 16:09:54 +0000 |
commit | 87b4f3319314ff7dbb33ca0097b5cf2cc65da7af (patch) | |
tree | 0e964e94ff14562697ee2f772026d3949600ff94 /libhb | |
parent | a080bd20151cc8d21522ad731cc9a2312a26f68c (diff) |
sync: fall back to drop_video_to_sync when hb_avcodec_open() fails, instesd of killing the job.
Patch by John Stebbins. Thanks!
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5459 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/sync.c | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/libhb/sync.c b/libhb/sync.c index 3771a8e8e..3e88c40e5 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -982,51 +982,53 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) if (hb_avcodec_open(c, codec, NULL, 0) < 0) { - hb_error("sync: avcodec_open failed"); - *job->die = 1; - return; + hb_log("sync: track %d, hb_avcodec_open() failed, dropping video to sync", + w->audio->config.out.track); + sync->drop_video_to_sync = 1; } - - // Prepare input frame - AVFrame frame = { .nb_samples = c->frame_size, .pts = 0, }; - int input_size = av_samples_get_buffer_size(NULL, c->channels, - frame.nb_samples, - c->sample_fmt, 1); - uint8_t *zeros = calloc(1, input_size); - avcodec_fill_audio_frame(&frame, c->channels, c->sample_fmt, zeros, - input_size, 1); - - // Allocate enough space for the encoded silence - // The output should be < the input - sync->silence_buf = malloc( input_size ); - - // There is some delay in getting output from some audio encoders. - // So encode a few packets till we get output. - int ii; - for ( ii = 0; ii < 10; ii++ ) + else { - // Prepare output packet - AVPacket pkt; - int got_packet; - av_init_packet(&pkt); - pkt.data = sync->silence_buf; - pkt.size = input_size; - - int ret = avcodec_encode_audio2( c, &pkt, &frame, &got_packet); - if ( ret < 0 ) + // Prepare input frame + AVFrame frame = { .nb_samples = c->frame_size, .pts = 0, }; + int input_size = av_samples_get_buffer_size(NULL, c->channels, + frame.nb_samples, + c->sample_fmt, 1); + uint8_t *zeros = calloc(1, input_size); + avcodec_fill_audio_frame(&frame, c->channels, c->sample_fmt, zeros, + input_size, 1); + + // Allocate enough space for the encoded silence + // The output should be < the input + sync->silence_buf = malloc( input_size ); + + // There is some delay in getting output from some audio encoders. + // So encode a few packets till we get output. + int ii; + for ( ii = 0; ii < 10; ii++ ) { - hb_log( "sync: avcodec_encode_audio failed" ); - break; - } + // Prepare output packet + AVPacket pkt; + int got_packet; + av_init_packet(&pkt); + pkt.data = sync->silence_buf; + pkt.size = input_size; + + int ret = avcodec_encode_audio2( c, &pkt, &frame, &got_packet); + if ( ret < 0 ) + { + hb_log( "sync: avcodec_encode_audio failed" ); + break; + } - if ( got_packet ) - { - sync->silence_size = pkt.size; - break; + if ( got_packet ) + { + sync->silence_size = pkt.size; + break; + } } + free( zeros ); + hb_avcodec_close( c ); } - free( zeros ); - hb_avcodec_close( c ); av_free( c ); } else |