diff options
author | Michael Niedermayer <[email protected]> | 2015-04-05 16:08:29 +0200 |
---|---|---|
committer | Michael Niedermayer <[email protected]> | 2015-04-05 16:08:29 +0200 |
commit | 4347cf9f0fc753706d2c507cab6ed67fc0d0eeee (patch) | |
tree | f9305b0598d95dd4b48be1d69a388b508bc0f659 | |
parent | 17b27a7cbe26c790a5ef2967c04a7f5e2add8b93 (diff) | |
parent | 420aa06a2487469259a04f9be66fd15535372796 (diff) |
Merge commit '420aa06a2487469259a04f9be66fd15535372796' into release/2.4
* commit '420aa06a2487469259a04f9be66fd15535372796':
avconv: do not overwrite the stream codec context for streamcopy
Conflicts:
ffmpeg.c
Merged-by: Michael Niedermayer <[email protected]>
-rw-r--r-- | ffmpeg.c | 28 | ||||
-rw-r--r-- | ffmpeg_opt.c | 4 |
2 files changed, 17 insertions, 15 deletions
@@ -587,7 +587,7 @@ static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) { AVBitStreamFilterContext *bsfc = ost->bitstream_filters; - AVCodecContext *avctx = ost->st->codec; + AVCodecContext *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec; int ret; if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) { @@ -2513,7 +2513,7 @@ static int transcode_init(void) if (ost->attachment_filename) continue; - enc_ctx = ost->enc_ctx; + enc_ctx = ost->stream_copy ? ost->st->codec : ost->enc_ctx; if (ist) { dec_ctx = ist->dec_ctx; @@ -2881,24 +2881,26 @@ static int transcode_init(void) if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." " It takes bits/s as argument, not kbits/s\n"); + + ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error initializing the output stream codec context.\n"); + exit_program(1); + } + + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); + ost->st->codec->codec= ost->enc_ctx->codec; } else { if (av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts) < 0) { av_log(NULL, AV_LOG_FATAL, "Error setting up codec context options.\n"); exit_program(1); } + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1}); } - - ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, - "Error initializing the output stream codec context.\n"); - exit_program(1); - } - ost->st->codec->codec= ost->enc_ctx->codec; - - // copy timebase while removing common factors - ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); } /* init input streams */ diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 0c7b35a269..239a030031 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1977,8 +1977,8 @@ loop_end: ost->stream_copy = 0; ost->attachment_filename = o->attachments[i]; ost->finished = 1; - ost->enc_ctx->extradata = attachment; - ost->enc_ctx->extradata_size = len; + ost->st->codec->extradata = attachment; + ost->st->codec->extradata_size = len; p = strrchr(o->attachments[i], '/'); av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); |