Added an audio buffer to VideoFFmpegComponent to avoid underflows and distortion.

This commit is contained in:
Leon Styhre 2021-05-12 22:55:00 +02:00
parent f3f86c6e20
commit 4465342724
2 changed files with 5 additions and 3 deletions

View file

@ -445,9 +445,10 @@ void VideoFFmpegComponent::outputFrames()
}
}
// Process all available audio frames that have a pts value below mAccumulatedTime.
// Process the audio frames that have a pts value below mAccumulatedTime (plus a small
// buffer to avoid underflows).
while (!mAudioFrameQueue.empty()) {
if (mAudioFrameQueue.front().pts < mAccumulatedTime) {
if (mAudioFrameQueue.front().pts < mAccumulatedTime + AUDIO_BUFFER) {
// Enable only when needed, as this generates a lot of debug output.
// LOG(LogDebug) << "Processing audio frame with PTS: " <<
// mAudioFrameQueue.front().pts;

View file

@ -9,7 +9,8 @@
#ifndef ES_CORE_COMPONENTS_VIDEO_FFMPEG_COMPONENT_H
#define ES_CORE_COMPONENTS_VIDEO_FFMPEG_COMPONENT_H
#define VIDEO_FRAME_QUEUE_SIZE 3
// Audio buffer in seconds.
#define AUDIO_BUFFER 0.2l
#include "VideoComponent.h"