hb_list_t * list;
AVAudioResampleContext *avresample;
+
+ int64_t last_pts;
};
static int encavcodecaInit( hb_work_object_t *, hb_job_t * );
w->private_data = pv;
pv->job = job;
pv->list = hb_list_init();
+ pv->last_pts = AV_NOPTS_VALUE;
// channel count, layout and matrix encoding
int matrix_encoding;
out = hb_buffer_init(pkt.size);
memcpy(out->data, pkt.data, out->size);
- // The output pts from libav is in context->time_base. Convert it
- // back to our timebase.
- out->s.start = av_rescale_q(pkt.pts, pv->context->time_base,
- (AVRational){1, 90000});
- out->s.duration = (double)90000 * pv->samples_per_frame /
- audio->config.out.samplerate;
- out->s.stop = out->s.start + out->s.duration;
- out->s.type = AUDIO_BUF;
- out->s.frametype = HB_FRAME_AUDIO;
-
- hb_buffer_list_append(list, out);
+ // FIXME: On windows builds, there is an upstream bug in the lame
+ // encoder that causes an extra output packet that has the same
+ // timestamp as the second to last packet. This causes an error
+ // during muxing. Work around it by dropping such packets here.
+ // See: https://github.com/HandBrake/HandBrake/issues/726
+ if (pkt.pts > pv->last_pts)
+ {
+ // The output pts from libav is in context->time_base. Convert it
+ // back to our timebase.
+ out->s.start = av_rescale_q(pkt.pts, pv->context->time_base,
+ (AVRational){1, 90000});
+ out->s.duration = (double)90000 * pv->samples_per_frame /
+ audio->config.out.samplerate;
+ out->s.stop = out->s.start + out->s.duration;
+ out->s.type = AUDIO_BUF;
+ out->s.frametype = HB_FRAME_AUDIO;
+
+ hb_buffer_list_append(list, out);
+ pv->last_pts = pkt.pts;
+ }
av_packet_unref(&pkt);
}
}