mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-15 19:40:07 +01:00
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 a82e4fb8c6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
b61b38766e
commit
462edf5b94
@@ -173,6 +173,9 @@ static int open_output_file(const char *filename)
|
|||||||
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
|
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 */
|
/* Third parameter can be used to pass settings to encoder */
|
||||||
ret = avcodec_open2(enc_ctx, encoder, NULL);
|
ret = avcodec_open2(enc_ctx, encoder, NULL);
|
||||||
if (ret < 0) {
|
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);
|
av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", i);
|
||||||
return ret;
|
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;
|
out_stream->time_base = enc_ctx->time_base;
|
||||||
stream_ctx[i].enc_ctx = enc_ctx;
|
stream_ctx[i].enc_ctx = enc_ctx;
|
||||||
|
|||||||
Reference in New Issue
Block a user