Fix audio frame pts
Jeffrey Pfau jeffrey@endrift.com
Mon, 27 Oct 2014 23:31:51 -0700
2 files changed,
4 insertions(+),
1 deletions(-)
M
src/platform/ffmpeg/ffmpeg-encoder.c
→
src/platform/ffmpeg/ffmpeg-encoder.c
@@ -241,6 +241,7 @@ encoder->context = 0;
encoder->currentAudioSample = 0; encoder->currentAudioFrame = 0; + encoder->nextAudioPts = 0; encoder->currentVideoFrame = 0; }@@ -272,7 +273,8 @@ }
avresample_read(encoder->resampleContext, encoder->audioFrame->data, encoder->postaudioBufferSize / channelSize); AVRational timeBase = { 1, PREFERRED_SAMPLE_RATE }; - encoder->audioFrame->pts = av_rescale_q(encoder->currentAudioFrame, timeBase, encoder->audioStream->time_base); + encoder->audioFrame->pts = encoder->nextAudioPts; + encoder->nextAudioPts = av_rescale_q(encoder->currentAudioFrame, timeBase, encoder->audioStream->time_base); AVPacket packet; av_init_packet(&packet);
M
src/platform/ffmpeg/ffmpeg-encoder.h
→
src/platform/ffmpeg/ffmpeg-encoder.h
@@ -29,6 +29,7 @@ size_t postaudioBufferSize;
AVFrame* audioFrame; size_t currentAudioSample; int64_t currentAudioFrame; + int64_t nextAudioPts; AVAudioResampleContext* resampleContext; AVStream* audioStream;