Merge pull request #9086 from Robyt3/Video-Config-Deprecation-Fix

Fix use of deprecated member variables in video recorder
This commit is contained in:
heinrich5991 2024-09-30 20:21:00 +00:00 committed by GitHub
commit 054eb37b13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -893,13 +893,23 @@ bool CVideo::AddStream(COutputStream *pStream, AVFormatContext *pFormatContext,
switch((*ppCodec)->type) switch((*ppCodec)->type)
{ {
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
pContext->sample_fmt = (*ppCodec)->sample_fmts ? (*ppCodec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
if((*ppCodec)->supported_samplerates)
{ {
pContext->sample_rate = (*ppCodec)->supported_samplerates[0]; const AVSampleFormat *pSampleFormats = nullptr;
for(int i = 0; (*ppCodec)->supported_samplerates[i]; i++) const int *pSampleRates = nullptr;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100)
avcodec_get_supported_config(pContext, *ppCodec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void **)&pSampleFormats, nullptr);
avcodec_get_supported_config(pContext, *ppCodec, AV_CODEC_CONFIG_SAMPLE_RATE, 0, (const void **)&pSampleRates, nullptr);
#else
pSampleFormats = (*ppCodec)->sample_fmts;
pSampleRates = (*ppCodec)->supported_samplerates;
#endif
pContext->sample_fmt = pSampleFormats ? pSampleFormats[0] : AV_SAMPLE_FMT_FLTP;
if(pSampleRates)
{ {
if((*ppCodec)->supported_samplerates[i] == m_pSound->MixingRate()) pContext->sample_rate = pSampleRates[0];
for(int i = 0; pSampleRates[i]; i++)
{
if(pSampleRates[i] == m_pSound->MixingRate())
{ {
pContext->sample_rate = m_pSound->MixingRate(); pContext->sample_rate = m_pSound->MixingRate();
break; break;
@ -921,6 +931,7 @@ bool CVideo::AddStream(COutputStream *pStream, AVFormatContext *pFormatContext,
pStream->m_pStream->time_base.num = 1; pStream->m_pStream->time_base.num = 1;
pStream->m_pStream->time_base.den = pContext->sample_rate; pStream->m_pStream->time_base.den = pContext->sample_rate;
break; break;
}
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
pContext->codec_id = CodecId; pContext->codec_id = CodecId;