From 2cfa891e215a71a541df4b3cde14c4c1487a2c0b Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 30 Nov 2023 01:45:30 +0800 Subject: [PATCH 1/3] Fix the broken DTS with fractional framerates on NVENC Signed-off-by: nyanmisaka --- ...en-dts-with-fractional-framerates-on-nvenc.patch | 13 +++++++++++++ debian/patches/series | 1 + 2 files changed, 14 insertions(+) create mode 100644 debian/patches/0058-fix-the-broken-dts-with-fractional-framerates-on-nvenc.patch diff --git a/debian/patches/0058-fix-the-broken-dts-with-fractional-framerates-on-nvenc.patch b/debian/patches/0058-fix-the-broken-dts-with-fractional-framerates-on-nvenc.patch new file mode 100644 index 00000000000..0b41bccfa02 --- /dev/null +++ b/debian/patches/0058-fix-the-broken-dts-with-fractional-framerates-on-nvenc.patch @@ -0,0 +1,13 @@ +Index: jellyfin-ffmpeg/libavcodec/nvenc.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc.c ++++ jellyfin-ffmpeg/libavcodec/nvenc.c +@@ -2034,7 +2034,7 @@ static int nvenc_set_timestamp(AVCodecCo + pkt->pts = params->outputTimeStamp; + pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list); + +- pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1) * FFMAX(avctx->time_base.num, 1); ++ pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1); + + return 0; + } diff --git a/debian/patches/series b/debian/patches/series index 9fccc2cdbcc..2eb319d241c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -55,3 +55,4 @@ 0055-fix-libplacebo-filter-build-with-v6-api.patch 0056-sync-intel-d3d11va-textures-before-mapping-to-opencl.patch 0057-add-icon-for-windows-version-ffmpeg.patch +0058-fix-the-broken-dts-with-fractional-framerates-on-nvenc.patch From a6bcc952e19d01f8d8881d195426e812b444dd74 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 30 Nov 2023 01:45:59 +0800 Subject: [PATCH 2/3] Fix the compatibility with ffnvcodec SDK 12.1 Signed-off-by: nyanmisaka --- ...ompatibility-with-ffnvcodec-sdk-12-1.patch | 147 ++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 148 insertions(+) create mode 100644 debian/patches/0059-fix-the-compatibility-with-ffnvcodec-sdk-12-1.patch diff --git a/debian/patches/0059-fix-the-compatibility-with-ffnvcodec-sdk-12-1.patch b/debian/patches/0059-fix-the-compatibility-with-ffnvcodec-sdk-12-1.patch new file mode 100644 index 00000000000..abd55b6e2fb --- /dev/null +++ b/debian/patches/0059-fix-the-compatibility-with-ffnvcodec-sdk-12-1.patch @@ -0,0 +1,147 @@ +Index: jellyfin-ffmpeg/configure +=================================================================== +--- jellyfin-ffmpeg.orig/configure ++++ jellyfin-ffmpeg/configure +@@ -6984,7 +6984,7 @@ enabled nvenc && + test_cc -I$source_path < + NV_ENCODE_API_FUNCTION_LIST flist; +-void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_PRESET_HQ_GUID } }; } ++void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_CODEC_H264_GUID } }; } + int main(void) { return 0; } + EOF + +Index: jellyfin-ffmpeg/libavcodec/nvenc.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc.c ++++ jellyfin-ffmpeg/libavcodec/nvenc.c +@@ -41,9 +41,14 @@ + #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x) + + #define NVENC_CAP 0x30 ++ ++#ifndef NVENC_NO_DEPRECATED_RC + #define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR || \ + rc == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ || \ + rc == NV_ENC_PARAMS_RC_CBR_HQ) ++#else ++#define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR) ++#endif + + const enum AVPixelFormat ff_nvenc_pix_fmts[] = { + AV_PIX_FMT_YUV420P, +@@ -877,6 +882,7 @@ static void nvenc_override_rate_control( + case NV_ENC_PARAMS_RC_CONSTQP: + set_constqp(avctx); + return; ++#ifndef NVENC_NO_DEPRECATED_RC + case NV_ENC_PARAMS_RC_VBR_MINQP: + if (avctx->qmin < 0) { + av_log(avctx, AV_LOG_WARNING, +@@ -887,12 +893,15 @@ static void nvenc_override_rate_control( + } + /* fall through */ + case NV_ENC_PARAMS_RC_VBR_HQ: ++#endif + case NV_ENC_PARAMS_RC_VBR: + set_vbr(avctx); + break; + case NV_ENC_PARAMS_RC_CBR: ++#ifndef NVENC_NO_DEPRECATED_RC + case NV_ENC_PARAMS_RC_CBR_HQ: + case NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ: ++#endif + break; + } + +@@ -1149,12 +1158,14 @@ static av_cold int nvenc_setup_h264_conf + + h264->outputPictureTimingSEI = 1; + ++#ifndef NVENC_NO_DEPRECATED_RC + if (cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ || + cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_HQ || + cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_VBR_HQ) { + h264->adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; + h264->fmoMode = NV_ENC_H264_FMO_DISABLE; + } ++#endif + + if (ctx->flags & NVENC_LOSSLESS) { + h264->qpPrimeYZeroTransformBypassFlag = 1; +Index: jellyfin-ffmpeg/libavcodec/nvenc.h +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc.h ++++ jellyfin-ffmpeg/libavcodec/nvenc.h +@@ -77,6 +77,11 @@ typedef void ID3D11Device; + #define NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH + #endif + ++// SDK 12.1 compile time feature checks ++#if NVENCAPI_CHECK_VERSION(12, 1) ++#define NVENC_NO_DEPRECATED_RC ++#endif ++ + typedef struct NvencSurface + { + NV_ENC_INPUT_PTR input_surface; +Index: jellyfin-ffmpeg/libavcodec/nvenc_h264.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc_h264.c ++++ jellyfin-ffmpeg/libavcodec/nvenc_h264.c +@@ -100,6 +100,7 @@ static const AVOption options[] = { + { "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" }, + { "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" }, + { "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" }, ++#ifndef NVENC_NO_DEPRECATED_RC + { "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_MINQP) }, 0, 0, VE, "rc" }, + { "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)", + 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_2_PASS_QUALITY) }, 0, 0, VE, "rc" }, +@@ -109,6 +110,17 @@ static const AVOption options[] = { + { "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) }, 0, 0, VE, "rc" }, + { "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_HQ) }, 0, 0, VE, "rc" }, + { "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_HQ) }, 0, 0, VE, "rc" }, ++#else ++ { "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++ { "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)", ++ 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++ { "ll_2pass_size", "Multi-pass optimized for constant frame size (deprecated)", ++ 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" }, ++ { "vbr_2pass", "Multi-pass variable bitrate mode (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++ { "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" }, ++ { "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" }, ++ { "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++#endif + { "rc-lookahead", "Number of frames to look ahead for rate-control", + OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + { "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_REGISTERED_FRAMES, VE }, +Index: jellyfin-ffmpeg/libavcodec/nvenc_hevc.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc_hevc.c ++++ jellyfin-ffmpeg/libavcodec/nvenc_hevc.c +@@ -89,6 +89,7 @@ static const AVOption options[] = { + { "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" }, + { "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" }, + { "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" }, ++#ifndef NVENC_NO_DEPRECATED_RC + { "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_MINQP) }, 0, 0, VE, "rc" }, + { "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)", + 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_2_PASS_QUALITY) }, 0, 0, VE, "rc" }, +@@ -98,6 +99,17 @@ static const AVOption options[] = { + { "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) }, 0, 0, VE, "rc" }, + { "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_HQ) }, 0, 0, VE, "rc" }, + { "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_HQ) }, 0, 0, VE, "rc" }, ++#else ++ { "vbr_minqp", "Variable bitrate mode with MinQP (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++ { "ll_2pass_quality", "Multi-pass optimized for image quality (deprecated)", ++ 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++ { "ll_2pass_size", "Multi-pass optimized for constant frame size (deprecated)", ++ 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" }, ++ { "vbr_2pass", "Multi-pass variable bitrate mode (deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++ { "cbr_ld_hq", "Constant bitrate low delay high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" }, ++ { "cbr_hq", "Constant bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE, "rc" }, ++ { "vbr_hq", "Variable bitrate high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE, "rc" }, ++#endif + { "rc-lookahead", "Number of frames to look ahead for rate-control", + OFFSET(rc_lookahead), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, + { "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_REGISTERED_FRAMES, VE }, diff --git a/debian/patches/series b/debian/patches/series index 2eb319d241c..08c8284f457 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -56,3 +56,4 @@ 0056-sync-intel-d3d11va-textures-before-mapping-to-opencl.patch 0057-add-icon-for-windows-version-ffmpeg.patch 0058-fix-the-broken-dts-with-fractional-framerates-on-nvenc.patch +0059-fix-the-compatibility-with-ffnvcodec-sdk-12-1.patch From 604f263b93ec0950032fb05ea794e9080fc4e725 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 30 Nov 2023 01:47:59 +0800 Subject: [PATCH 3/3] Bump version to 5.1.4-2 Signed-off-by: nyanmisaka --- build.yaml | 2 +- debian/changelog | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/build.yaml b/build.yaml index e415f36a0d5..c1a2ee71141 100644 --- a/build.yaml +++ b/build.yaml @@ -1,7 +1,7 @@ --- # We just wrap `build` so this is really it name: "jellyfin-ffmpeg" -version: "5.1.4-1" +version: "5.1.4-2" packages: - buster-amd64 - buster-armhf diff --git a/debian/changelog b/debian/changelog index 18aaaa007d8..514c52ba2db 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +jellyfin-ffmpeg (5.1.4-2) unstable; urgency=medium + + * Fix the broken DTS with fractional framerates on NVENC + * Fix the compatibility with ffnvcodec SDK 12.1 + + -- nyanmisaka Wed, 30 Nov 2023 22:10:31 +0800 + jellyfin-ffmpeg (5.1.4-1) unstable; urgency=medium * New upstream version 5.1.4