Preparation work for the following commits.

Signed-off-by: James Almer <jamr...@gmail.com>
---
 fftools/ffmpeg.h          | 4 ++++
 fftools/ffmpeg_enc.c      | 5 +++++
 fftools/ffmpeg_mux_init.c | 8 ++++----
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6cc0da05a0..af76d81a10 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -567,6 +567,10 @@ typedef struct Encoder {
 
     AVCodecContext         *enc_ctx;
 
+    uint32_t                codec_tag;
+    int                     flags;
+    int                     global_quality;
+
     // number of frames/samples sent to the encoder
     uint64_t                frames_encoded;
     uint64_t                samples_encoded;
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index acb0702385..32b41ea51c 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -218,6 +218,11 @@ static int enc_reopen(void *opaque, const AVFrame *frame)
     if (ist)
         dec = ist->decoder;
 
+    if (ost->enc->codec_tag)
+        enc_ctx->codec_tag  = e->codec_tag;
+    enc_ctx->flags         |= e->flags;
+    enc_ctx->global_quality = e->global_quality;
+
     // the timebase is chosen by filtering code
     if (ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO) {
         enc_ctx->time_base      = frame->time_base;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 4a973e5286..3eff514f7b 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1490,13 +1490,13 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
         ost->st->codecpar->codec_tag = tag;
         ms->par_in->codec_tag = tag;
         if (ost->enc)
-            ost->enc->enc_ctx->codec_tag = tag;
+            ost->enc->codec_tag = tag;
     }
 
     opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale);
     if (ost->enc && qscale >= 0) {
-        ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
-        ost->enc->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
+        ost->enc->flags          |= AV_CODEC_FLAG_QSCALE;
+        ost->enc->global_quality  = FF_QP2LAMBDA * qscale;
     }
 
     if (ms->sch_idx >= 0) {
@@ -1519,7 +1519,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
                              oc, st, &ost->fix_sub_duration_heartbeat);
 
     if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc)
-        ost->enc->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+        ost->enc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 
     opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes,
                              oc, st, &ms->copy_initial_nonkeyframes);
-- 
2.48.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to