obs-ffmpeg: Add linux VAAPI h.264 encoding support

Closes obsproject/obs-studio#1482
Closes obsproject/obs-studio#1256
This commit is contained in:
Thomas Crider
2018-04-08 15:05:22 -04:00
committed by jp9000
parent 2a08f1d144
commit a64ae11bce
4 changed files with 576 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
#include <util/darray.h>
#include <util/platform.h>
#include <libavutil/log.h>
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <pthread.h>
@@ -21,6 +22,14 @@ extern struct obs_encoder_info aac_encoder_info;
extern struct obs_encoder_info opus_encoder_info;
extern struct obs_encoder_info nvenc_encoder_info;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 27, 100)
#define LIBAVUTIL_VAAPI_AVAILABLE
#endif
#ifdef LIBAVUTIL_VAAPI_AVAILABLE
extern struct obs_encoder_info vaapi_encoder_info;
#endif
static DARRAY(struct log_context {
void *context;
char str[4096];
@@ -162,6 +171,14 @@ cleanup:
#endif
#ifdef LIBAVUTIL_VAAPI_AVAILABLE
static bool vaapi_supported(void)
{
AVCodec *vaenc = avcodec_find_encoder_by_name("h264_vaapi");
return !!vaenc;
}
#endif
bool obs_module_load(void)
{
da_init(active_log_contexts);
@@ -180,6 +197,12 @@ bool obs_module_load(void)
blog(LOG_INFO, "NVENC supported");
obs_register_encoder(&nvenc_encoder_info);
}
#if !defined(_WIN32) && defined(LIBAVUTIL_VAAPI_AVAILABLE)
if (vaapi_supported()) {
blog(LOG_INFO, "FFMPEG VAAPI supported");
obs_register_encoder(&vaapi_encoder_info);
}
#endif
#endif
return true;
}