[FFmpeg-devel] [PATCH v2 09/12] ffmpeg: pass first video AVFrame's side data to encoder

Jan Ekström jeebjp at gmail.com
Wed Apr 12 00:20:49 EEST 2023


This enables further configuration of output based on the results
of input decoding and filtering in a similar manner as the color
information.
---
 fftools/ffmpeg_enc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 2f1803a74c..f389addcf8 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -223,11 +223,23 @@ int enc_open(OutputStream *ost, AVFrame *frame)
                                                  av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
         if (frame) {
+            int ret = AVERROR_BUG;
+
             enc_ctx->color_range            = frame->color_range;
             enc_ctx->color_primaries        = frame->color_primaries;
             enc_ctx->color_trc              = frame->color_trc;
             enc_ctx->colorspace             = frame->colorspace;
             enc_ctx->chroma_sample_location = frame->chroma_location;
+
+            if ((ret = av_extend_side_data_set(&enc_ctx->side_data_set,
+                                               (const AVFrameSideDataSet){
+                                                   .side_data    = frame->side_data,
+                                                   .nb_side_data = frame->nb_side_data
+                                               })) < 0) {
+                av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: %s!\n",
+                       av_err2str(ret));
+                return ret;
+            }
         }
 
         enc_ctx->framerate = ost->frame_rate;
-- 
2.40.0



More information about the ffmpeg-devel mailing list