You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avconv: do not overwrite the stream codec context for streamcopy
Since we are not doing encoding, there is no point in ever touching the separate encoding context. Always use the stream codec context. Fixes writing attachments. CC:libav-devel@libav.org
This commit is contained in:
23
avconv.c
23
avconv.c
@@ -318,7 +318,7 @@ static void update_sample_fmt(AVCodecContext *dec, AVCodec *dec_codec,
|
|||||||
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->enc_ctx;
|
AVCodecContext *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1706,7 +1706,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;
|
||||||
@@ -1985,20 +1985,21 @@ 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");
|
||||||
|
|
||||||
|
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->time_base = ost->enc_ctx->time_base;
|
||||||
} else {
|
} else {
|
||||||
ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts);
|
ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
ost->st->time_base = ost->st->codec->time_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
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->time_base = ost->enc_ctx->time_base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init input streams */
|
/* init input streams */
|
||||||
|
Reference in New Issue
Block a user