Merge commit '3892bdab9b652eb003ab95e167f1765e0b0ea035'

* commit '3892bdab9b652eb003ab95e167f1765e0b0ea035':
  avconv: do not overwrite the stream codec context for streamcopy

Conflicts:
	ffmpeg.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/130/head
Michael Niedermayer 10 years ago
commit 959894632a
  1. 24
      ffmpeg.c
  2. 4
      ffmpeg_opt.c

@ -588,7 +588,7 @@ static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream,
static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
{ {
AVBitStreamFilterContext *bsfc = ost->bitstream_filters; AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
AVCodecContext *avctx = ost->st->codec; AVCodecContext *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec;
int ret; int ret;
if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) { if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) {
@ -2637,7 +2637,7 @@ static int transcode_init(void)
if (ost->attachment_filename) if (ost->attachment_filename)
continue; continue;
enc_ctx = ost->enc_ctx; enc_ctx = ost->stream_copy ? ost->st->codec : ost->enc_ctx;
if (ist) { if (ist) {
dec_ctx = ist->dec_ctx; dec_ctx = ist->dec_ctx;
@ -3063,14 +3063,6 @@ static int transcode_init(void)
if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) 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." av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
" It takes bits/s as argument, not kbits/s\n"); " It takes bits/s as argument, not kbits/s\n");
} else {
ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL,
"Error setting up codec context options.\n");
return ret;
}
}
ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx);
if (ret < 0) { if (ret < 0) {
@ -3078,10 +3070,20 @@ static int transcode_init(void)
"Error initializing the output stream codec context.\n"); "Error initializing the output stream codec context.\n");
exit_program(1); exit_program(1);
} }
ost->st->codec->codec= ost->enc_ctx->codec;
// copy timebase while removing common factors // copy timebase while removing common factors
ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1});
ost->st->codec->codec= ost->enc_ctx->codec;
} else {
ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL,
"Error setting up codec context options.\n");
return ret;
}
// copy timebase while removing common factors
ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1});
}
} }
/* init input streams */ /* init input streams */

@ -2038,8 +2038,8 @@ loop_end:
ost->stream_copy = 0; ost->stream_copy = 0;
ost->attachment_filename = o->attachments[i]; ost->attachment_filename = o->attachments[i];
ost->finished = 1; ost->finished = 1;
ost->enc_ctx->extradata = attachment; ost->st->codec->extradata = attachment;
ost->enc_ctx->extradata_size = len; ost->st->codec->extradata_size = len;
p = strrchr(o->attachments[i], '/'); p = strrchr(o->attachments[i], '/');
av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);

Loading…
Cancel
Save