Skip to content
Snippets Groups Projects
Commit ac6044f8 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

contrib: build ffmpeg with nvcodec

Change-Id: I9b58121d326be4a0789c03145551d5417ba13698
parent a24fb11b
No related branches found
No related tags found
No related merge requests found
......@@ -168,6 +168,7 @@ FFMPEGCONF += --disable-asm
endif
else
# Desktop Linux
DEPS_ffmpeg += ffnvcodec
FFMPEGCONF += \
--target-os=linux \
--enable-indev=v4l2 \
......@@ -183,7 +184,17 @@ FFMPEGCONF += \
--enable-hwaccel=mjpeg_vaapi \
--enable-encoder=h264_vaapi \
--enable-encoder=vp8_vaapi \
--enable-encoder=mjpeg_vaapi
--enable-encoder=mjpeg_vaapi \
--enable-cuvid \
--enable-ffnvcodec \
--enable-nvdec \
--enable-nvenc \
--enable-hwaccel=h264_nvdec \
--enable-hwaccel=hevc_nvdec \
--enable-hwaccel=vp8_nvdec \
--enable-hwaccel=mjpeg_nvdec \
--enable-encoder=h264_nvenc \
--enable-encoder=hevc_nvenc
endif
endif
......
# ffnvcodec
FFNVCODEC_VERSION := n9.0.18.1
FFNVCODEC_GITURL := https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
PKGS += ffnvcodec
ifeq ($(call need_pkg,"ffnvcodec >= 8"),)
PKGS_FOUND += ffnvcodec
endif
$(TARBALLS)/ffnvcodec-$(FFNVCODEC_VERSION).tar.xz:
$(call download_git,$(FFNVCODEC_GITURL),master,$(FFNVCODEC_VERSION))
.sum-ffnvcodec: ffnvcodec-$(FFNVCODEC_VERSION).tar.xz
$(warning $@ not implemented)
touch $@
.sum-ffnvcodec: ffnvcodec-$(FFNVCODEC_VERSION).tar.xz
ffnvcodec: ffnvcodec-$(FFNVCODEC_VERSION).tar.xz .sum-ffnvcodec
$(UNPACK)
$(MOVE)
.ffnvcodec: ffnvcodec
cd $< && $(HOSTVARS) DESTDIR=$(PREFIX) $(MAKE) install PREFIX=""
touch $@
......@@ -159,6 +159,9 @@ HardwareAccel::initDevice()
{
int ret = 0;
auto hwType = av_hwdevice_find_type_by_name(name_.c_str());
if (hwType == AV_HWDEVICE_TYPE_NONE and (name_ == "nvenc" or name_ == "nvdec")) {
hwType = AV_HWDEVICE_TYPE_CUDA;
}
#ifdef HAVE_VAAPI_ACCEL_DRM
// default DRM device may not work on multi GPU computers, so check all possible values
if (name_ == "vaapi") {
......@@ -258,6 +261,7 @@ std::unique_ptr<HardwareAccel>
HardwareAccel::setupDecoder(AVCodecID id, int width, int height)
{
static const HardwareAPI apiList[] = {
{ "nvdec", AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_H265, AV_CODEC_ID_VP8, AV_CODEC_ID_MJPEG } },
{ "vaapi", AV_PIX_FMT_VAAPI, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4, AV_CODEC_ID_VP8, AV_CODEC_ID_MJPEG } },
{ "vdpau", AV_PIX_FMT_VDPAU, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4 } },
{ "videotoolbox", AV_PIX_FMT_VIDEOTOOLBOX, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4 } },
......@@ -270,7 +274,7 @@ HardwareAccel::setupDecoder(AVCodecID id, int width, int height)
// we don't need frame context for videotoolbox
if (api.format == AV_PIX_FMT_VIDEOTOOLBOX ||
accel->initFrame(width, height)) {
JAMI_DBG() << "Attempting to use hardware dencoder " << accel->getCodecName() << " with " << api.name;
JAMI_DBG() << "Attempting to use hardware decoder " << accel->getCodecName() << " with " << api.name;
return accel;
}
}
......@@ -284,6 +288,7 @@ std::unique_ptr<HardwareAccel>
HardwareAccel::setupEncoder(AVCodecID id, int width, int height, AVBufferRef* framesCtx)
{
static const HardwareAPI apiList[] = {
{ "nvenc", AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_H265 } },
{ "vaapi", AV_PIX_FMT_VAAPI, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_MJPEG, AV_CODEC_ID_VP8 } },
{ "videotoolbox", AV_PIX_FMT_VIDEOTOOLBOX, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264 } },
};
......@@ -299,7 +304,7 @@ HardwareAccel::setupEncoder(AVCodecID id, int width, int height, AVBufferRef* fr
if (api.format == AV_PIX_FMT_VIDEOTOOLBOX ||
accel->linkHardware(framesCtx) ||
accel->initFrame(width, height)) {
JAMI_DBG() << "Attempting to use hardware encoder " << codecName;
JAMI_DBG() << "Attempting to use hardware encoder " << codecName << " with " << api.name;
return accel;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment