code: Fix support for libAVCodec 59.x and beyond

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2023-05-03 20:31:38 +02:00 committed by Xaymar
parent 5ce59b4c12
commit 0476185a65
2 changed files with 17 additions and 8 deletions

View file

@ -1042,14 +1042,15 @@ const char* ffmpeg_factory::get_name()
void ffmpeg_factory::get_defaults2(obs_data_t* settings)
{
if (_handler)
if (_handler) {
_handler->get_defaults(settings, _avcodec, nullptr, _handler->is_hardware_encoder(this));
if ((_avcodec->capabilities & AV_CODEC_CAP_INTRA_ONLY) == 0) {
if (_handler->has_keyframe_support(this)) {
obs_data_set_default_int(settings, ST_KEY_KEYFRAMES_INTERVALTYPE, 0);
obs_data_set_default_double(settings, ST_KEY_KEYFRAMES_INTERVAL_SECONDS, 2.0);
obs_data_set_default_int(settings, ST_KEY_KEYFRAMES_INTERVAL_FRAMES, 300);
}
}
{ // Integrated Options
// FFmpeg

View file

@ -9,7 +9,15 @@ using namespace streamfx::encoder::ffmpeg;
bool handler::handler::has_keyframe_support(ffmpeg_factory* instance)
{
#if LIBAVCODEC_VERSION_MAJOR > 58
if (auto* desc = avcodec_descriptor_get(instance->get_avcodec()->id); desc) {
return (desc->props & AV_CODEC_PROP_INTRA_ONLY) == 0;
} else {
return false;
}
#else
return (instance->get_avcodec()->capabilities & AV_CODEC_CAP_INTRA_ONLY) == 0;
#endif
}
bool handler::handler::is_hardware_encoder(ffmpeg_factory* instance)