Skip to content

Commit

Permalink
pixel format error check
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnut committed Dec 29, 2024
1 parent daa649c commit e8b0cfd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ geode::Result<> Recorder::init(const RenderSettings& settings) {
m_codecContext->pix_fmt = AV_PIX_FMT_NONE;
m_videoStream->time_base = m_codecContext->time_base;

if(!m_codecContext->pix_fmt)
return geode::Err("Codec does not have any supported pixel formats.");

if (const AVPixelFormat *pix_fmt = m_codec->pix_fmts) {
while (*pix_fmt != AV_PIX_FMT_NONE) {
if(*pix_fmt == static_cast<AVPixelFormat>(settings.m_pixelFormat))
m_codecContext->pix_fmt = *pix_fmt;
++pix_fmt;
}
}

if(m_codecContext->pix_fmt == AV_PIX_FMT_NONE) {
geode::log::info("Codec {} does not support pixel format, defaulting to codec's format", settings.m_codec);
m_codecContext->pix_fmt = m_codec->pix_fmts[0];
Expand Down

0 comments on commit e8b0cfd

Please sign in to comment.