Small refactoring of VideoFFmpegComponent.

This commit is contained in:
Leon Styhre 2021-07-04 11:36:16 +02:00
parent a0e587c19b
commit 45d3bb9bad

View file

@ -13,6 +13,8 @@
#include "Settings.h" #include "Settings.h"
#include "Window.h" #include "Window.h"
#define DEBUG_VIDEO false
VideoFFmpegComponent::VideoFFmpegComponent( VideoFFmpegComponent::VideoFFmpegComponent(
Window* window) Window* window)
: VideoComponent(window), : VideoComponent(window),
@ -631,10 +633,10 @@ void VideoFFmpegComponent::getProcessedFrames()
mAudioFrameResampled) >= 0) { mAudioFrameResampled) >= 0) {
AudioFrame currFrame; AudioFrame currFrame;
AVRational timeBase;
mAudioFrameResampled->best_effort_timestamp = mAudioFrameResampled->pts; mAudioFrameResampled->best_effort_timestamp = mAudioFrameResampled->pts;
AVRational timeBase;
timeBase.num = 1; timeBase.num = 1;
timeBase.den = mAudioFrameResampled->sample_rate; timeBase.den = mAudioFrameResampled->sample_rate;
@ -671,10 +673,12 @@ void VideoFFmpegComponent::outputFrames()
while (!mAudioFrameQueue.empty()) { while (!mAudioFrameQueue.empty()) {
if (mAudioFrameQueue.front().pts < mAccumulatedTime + AUDIO_BUFFER) { if (mAudioFrameQueue.front().pts < mAccumulatedTime + AUDIO_BUFFER) {
// Enable only when needed, as this generates a lot of debug output. // Enable only when needed, as this generates a lot of debug output.
// LOG(LogDebug) << "Processing audio frame with PTS: " << if (DEBUG_VIDEO) {
// mAudioFrameQueue.front().pts; LOG(LogDebug) << "Processing audio frame with PTS: " <<
// LOG(LogDebug) << "Total audio frames processed / audio frame queue size: " << mAudioFrameQueue.front().pts;
// mAudioFrameCount << " / " << std::to_string(mAudioFrameQueue.size()); LOG(LogDebug) << "Total audio frames processed / audio frame queue size: " <<
mAudioFrameCount << " / " << std::to_string(mAudioFrameQueue.size());
}
bool outputSound = false; bool outputSound = false;
@ -712,10 +716,12 @@ void VideoFFmpegComponent::outputFrames()
while (mIsActuallyPlaying && !mVideoFrameQueue.empty()) { while (mIsActuallyPlaying && !mVideoFrameQueue.empty()) {
if (mVideoFrameQueue.front().pts < mAccumulatedTime) { if (mVideoFrameQueue.front().pts < mAccumulatedTime) {
// Enable only when needed, as this generates a lot of debug output. // Enable only when needed, as this generates a lot of debug output.
// LOG(LogDebug) << "Processing video frame with PTS: " << if (DEBUG_VIDEO) {
// mVideoFrameQueue.front().pts; LOG(LogDebug) << "Processing video frame with PTS: " <<
// LOG(LogDebug) << "Total video frames processed / video frame queue size: " << mVideoFrameQueue.front().pts;
// mVideoFrameCount << " / " << std::to_string(mVideoFrameQueue.size()); LOG(LogDebug) << "Total video frames processed / video frame queue size: " <<
mVideoFrameCount << " / " << std::to_string(mVideoFrameQueue.size());
}
mPictureMutex.lock(); mPictureMutex.lock();