Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 13 additions & 49 deletions patches/FFmpeg/FFmpeg/MF/01-mfenc-lowlatency.patch
Original file line number Diff line number Diff line change
@@ -1,64 +1,28 @@
From 126671e73065e29c9582e47bc74774af2200fc8f Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[email protected]>
To: [email protected]
Date: Sat, 2 Aug 2025 23:55:25 -0500
Message-ID: <[email protected]>
X-Mailer: git-send-email 2.50.1.windows.1
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH] avcodec/mfenc: add low_latency encoder
parameter
X-BeenThere: [email protected]
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
<mailto:[email protected]?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <[email protected]>
Cc: Conn O'Griofa <[email protected]>
Errors-To: [email protected]
Sender: "ffmpeg-devel" <[email protected]>
Date: Sun, 31 Aug 2025 16:05:15 -0500
Subject: [PATCH] avcodec/mfenc: add AVLowLatencyMode support

Implement support for CODECAPI_AVLowLatencyMode property, which is
useful for live streaming use cases (and cannot be achieved by
selecting any of the low latency "scenario" encoder presets alone).
Set CODECAPI_AVLowLatencyMode when AV_CODEC_FLAG_LOW_DELAY is enabled on
the AVCodecContext. AVLowLatencyMode can acheive lower latency encoding
that may not be accessible using eAVScenarioInfo options alone.

Co-authored-by: Conn O'Griofa <[email protected]>
Signed-off-by: Cameron Gutman <[email protected]>
---
libavcodec/mfenc.c | 5 +++++
1 file changed, 5 insertions(+)
libavcodec/mfenc.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 30531fe3e8..e84ce7bde0 100644
index 6f79386404502..541f7fb9612af 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -64,6 +64,7 @@ typedef struct MFContext {
int opt_enc_quality;
int opt_enc_scenario;
int opt_enc_hw;
+ int opt_enc_lowlatency;
AVD3D11VADeviceContext* device_hwctx;
} MFContext;

@@ -866,6 +867,9 @@ static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type)

@@ -876,6 +876,9 @@ static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type)

if (c->opt_enc_scenario >= 0)
ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVScenarioInfo, FF_VAL_VT_UI4(c->opt_enc_scenario));
+
+ if (c->opt_enc_lowlatency)
+ if (avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
+ ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVLowLatencyMode, FF_VAL_VT_UI4(1));
}

return 0;
@@ -1445,6 +1449,7 @@ static const AVOption venc_opts[] = {

{"quality", "Quality", OFFSET(opt_enc_quality), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 100, VE},
{"hw_encoding", "Force hardware encoding", OFFSET(opt_enc_hw), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VE},
+ {"low_latency", "Low latency mode", OFFSET(opt_enc_lowlatency), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, VE},
{NULL}
};

Loading