summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-04-04 00:38:02 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-04 00:38:02 +0200
commit959894632ae67e356ede734e352eabda6bb55794 (patch)
tree52eaa0f88d733d8fc25ce152fb39f9e907c92f07 /ffmpeg.c
parent4d02dfbde475d249916eb19c360e890059aa6aa5 (diff)
parent3892bdab9b652eb003ab95e167f1765e0b0ea035 (diff)
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>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index b42bb7db21..8d2cbe3cef 100644
--- a/ffmpeg.c
+++ b/ffmpeg.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)
{
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) {
@@ -2637,7 +2637,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;
@@ -3063,6 +3063,17 @@ 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 {
ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts);
if (ret < 0) {
@@ -3070,18 +3081,9 @@ static int transcode_init(void)
"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});
}
-
- 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 */