Skip to content

Commit

Permalink
encoder check
Browse files Browse the repository at this point in the history
  • Loading branch information
rectalogic committed Apr 23, 2024
1 parent 6247eea commit 12d9279
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/MediaFX/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void Encoder::setFrameSize(const QSize& frameSize)
return;
}
m_frameSize = frameSize;
m_frameByteSize = frameSize.width() * frameSize.height() * 4;
emit frameSizeChanged();
}
}
Expand Down Expand Up @@ -193,6 +194,16 @@ bool Encoder::encode(const QAudioBuffer& audioBuffer, const QByteArray& videoDat
emit encodingError();
return false;
}
if (audioBuffer.format().sampleRate() != sampleRate()) {
qmlWarning(this) << "Audio buffer has incorrect sampleRate";
emit encodingError();
return false;
}
if (videoData.size() != m_frameByteSize) {
qmlWarning(this) << "Video buffer has incorrect byte size";
emit encodingError();
return false;
}
AVPacket* videoPacket = m_videoStream->packet();
videoPacket->flags |= AV_PKT_FLAG_KEY;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast, cppcoreguidelines-pro-type-reinterpret-cast)
Expand Down
1 change: 1 addition & 0 deletions src/MediaFX/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public slots:

bool m_isValid = false;
QSize m_frameSize;
int m_frameByteSize = 0;
Rational m_frameRate = DefaultFrameRate;
int m_sampleRate = DefaultSampleRate;
QString m_outputFileName;
Expand Down

0 comments on commit 12d9279

Please sign in to comment.