diff mbox

[FFmpeg-devel,2/2] examples: Fix use of AV_CODEC_FLAG_GLOBAL_HEADER

Message ID 1535612179-24393-2-git-send-email-bunk@iat.uni-leipzig.de
State Accepted
Commit a82e4fb8c6f26e75506df6818fee1b61f940cbeb
Headers show

Commit Message

Michael Bunk Aug. 30, 2018, 6:56 a.m. UTC
AV_CODEC_FLAG_GLOBAL_HEADER should be set before calling avcodec_open2() to have any effect.
---
 doc/examples/transcoding.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Aug. 31, 2018, 12:25 p.m. UTC | #1
On Thu, Aug 30, 2018 at 08:56:19AM +0200, Michael Bunk wrote:
> AV_CODEC_FLAG_GLOBAL_HEADER should be set before calling avcodec_open2() to have any effect.
> ---
>  doc/examples/transcoding.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

will apply

thx

[...]
diff mbox

Patch

diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index a83fa3a..e48837c 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -172,6 +172,9 @@  static int open_output_file(const char *filename)
                 enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
             }
 
+            if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
+                enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+
             /* Third parameter can be used to pass settings to encoder */
             ret = avcodec_open2(enc_ctx, encoder, NULL);
             if (ret < 0) {
@@ -183,8 +186,6 @@  static int open_output_file(const char *filename)
                 av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", i);
                 return ret;
             }
-            if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
-                enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 
             out_stream->time_base = enc_ctx->time_base;
             stream_ctx[i].enc_ctx = enc_ctx;