aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bunk <bunk@iat.uni-leipzig.de>2018-08-30 08:56:19 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-10-28 02:22:42 +0200
commit462edf5b94354fac265f5c76eff7c733f8ee5b3e (patch)
treea100d535fd26e18cb7d691a41ec18c12ed5a8ff8
parentb61b38766ee9ebf31f69bea834fa23bb63dcb8b8 (diff)
downloadffmpeg-462edf5b94354fac265f5c76eff7c733f8ee5b3e.tar.gz
examples: Fix use of AV_CODEC_FLAG_GLOBAL_HEADER
AV_CODEC_FLAG_GLOBAL_HEADER should be set before calling avcodec_open2() to have any effect. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit a82e4fb8c6f26e75506df6818fee1b61f940cbeb) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--doc/examples/transcoding.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index fb15a2148d..6e5124e6d3 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -173,6 +173,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) {
@@ -184,8 +187,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;