[FFmpeg-devel] [PATCH] Added support to enable VBV-End feature with x265 encode
Yaswanth Sastry
yaswanth.sastry at multicorewareinc.com
Wed Oct 9 11:28:13 EEST 2024
>From 5cd8272ccf9902a4eb5451fed583909c63941fb7 Mon Sep 17 00:00:00 2001
From: From: yaswanthsastry <yaswanth.sastry at multicorewareinc.com>
Date: Wed, 9 Oct 2024 13:44:54 +0530
Subject: [PATCH] Added support to enable VBV-End feature with x265 encode
---
fftools/ffmpeg_enc.c | 2 ++
libavcodec/avcodec.h | 1 +
libavcodec/libx265.c | 3 +++
3 files changed, 6 insertions(+)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index a46af4dce1..080e44f2df 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -187,7 +187,9 @@ int enc_open(void *opaque, const AVFrame *frame)
InputStream *ist = ost->ist;
Encoder *e = ost->enc;
EncoderPriv *ep = ep_from_enc(e);
+ AVFormatContext* ic = input_files[ost->file->index]->ctx;
AVCodecContext *enc_ctx = e->enc_ctx;
+ enc_ctx->duration = (double)(ic->duration);
Decoder *dec = NULL;
const AVCodec *enc = enc_ctx->codec;
OutputFile *of = ost->file;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 77ca8dee1f..e6ca5babee 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2086,6 +2086,7 @@ typedef struct AVCodecContext {
*/
AVFrameSideData **decoded_side_data;
int nb_decoded_side_data;
+ double duration;
} AVCodecContext;
/**
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 63cc497f83..e248eb2edc 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -693,6 +693,7 @@ static int libx265_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
}
x265pic.pts = pic->pts;
+ x265pic.poc = pic->pts;
x265pic.bitDepth =
av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ?
@@ -786,6 +787,8 @@ static int libx265_encode_frame(AVCodecContext *avctx,
AVPacket *pkt,
}
#if X265_BUILD >= 167
+ if(ctx->params->vbvBufferEnd)
+
ctx->api->configure_vbv_end(ctx->encoder,&x265pic,(avctx->duration/1000000));
sd = av_frame_get_side_data(pic, AV_FRAME_DATA_DOVI_METADATA);
if (ctx->dovi.cfg.dv_profile && sd) {
const AVDOVIMetadata *metadata = (const AVDOVIMetadata
*)sd->data;
--
2.17.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-Support-for-VbvEnd-Feature.patch
Type: application/octet-stream
Size: 2280 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241009/f5ca99b7/attachment.obj>
More information about the ffmpeg-devel
mailing list