Re: [FFmpeg-devel] [PATCH 1/4] ffmpeg: re-copy codec contexts after encoding
This was sent in error, please disregard. Jon Toohill | Google Play Music | jtooh...@google.com | (650) 215-0770 On Wed, Sep 28, 2016 at 11:28 AM, Jon Toohillwrote: > This preserves changes to fields of AVCodecContext that get > updated during encoding, such as trailing_padding (which > may not be known until encoding is complete). > --- > ffmpeg.c | 15 +++ > 1 file changed, 15 insertions(+) > > diff --git a/ffmpeg.c b/ffmpeg.c > index df55a49..1e973f5 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -4243,6 +4243,21 @@ static int transcode(void) > > term_exit(); > > +/* update output codec contexts after encoding */ > +for (i = 0; i < nb_output_streams; i++) { > +ost = output_streams[i]; > +if (ost->encoding_needed) { > +ret = avcodec_copy_context( > +output_files[ost->file_index]->ctx->streams[ost->index]-> > codec, > +ost->enc_ctx); > +if (ret < 0) { > +av_log(ost, AV_LOG_ERROR, "Error copying final codec > context: %s\n", av_err2str(ret)); > +if (exit_on_error) > +exit_program(1); > +} > +} > +} > + > /* write the trailer if needed and close file */ > for (i = 0; i < nb_output_files; i++) { > os = output_files[i]->ctx; > -- > 2.8.0.rc3.226.g39d4020 > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/4] ffmpeg: re-copy codec contexts after encoding
This preserves changes to fields of AVCodecContext that get updated during encoding, such as trailing_padding (which may not be known until encoding is complete). --- ffmpeg.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/ffmpeg.c b/ffmpeg.c index df55a49..1e973f5 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4243,6 +4243,21 @@ static int transcode(void) term_exit(); +/* update output codec contexts after encoding */ +for (i = 0; i < nb_output_streams; i++) { +ost = output_streams[i]; +if (ost->encoding_needed) { +ret = avcodec_copy_context( +output_files[ost->file_index]->ctx->streams[ost->index]->codec, +ost->enc_ctx); +if (ret < 0) { +av_log(ost, AV_LOG_ERROR, "Error copying final codec context: %s\n", av_err2str(ret)); +if (exit_on_error) +exit_program(1); +} +} +} + /* write the trailer if needed and close file */ for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx; -- 2.8.0.rc3.226.g39d4020 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] ffmpeg: re-copy codec contexts after encoding
On 9/26/2016 2:13 PM, Jon Toohill wrote: > This preserves changes to fields of AVCodecContext that get > updated during encoding, such as trailing_padding (which > may not be known until encoding is complete). > --- > ffmpeg.c | 15 +++ > 1 file changed, 15 insertions(+) > > diff --git a/ffmpeg.c b/ffmpeg.c > index df55a49..1e973f5 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -4243,6 +4243,21 @@ static int transcode(void) > > term_exit(); > > +/* update output codec contexts after encoding */ > +for (i = 0; i < nb_output_streams; i++) { > +ost = output_streams[i]; > +if (ost->encoding_needed) { > +ret = avcodec_copy_context( > + > output_files[ost->file_index]->ctx->streams[ost->index]->codec, > +ost->enc_ctx); We ported ffmpeg to codecpar, so AVStream.codec shouldn't be used anymore. While i can't say if adding this chunk here is a good idea or even correct to begin with, you should in any case use avcodec_parameters_from_context() to copy parameters to the output stream's codecpar context. > +if (ret < 0) { > +av_log(ost, AV_LOG_ERROR, "Error copying final codec > context: %s\n", av_err2str(ret)); > +if (exit_on_error) > +exit_program(1); > +} > +} > +} > + > /* write the trailer if needed and close file */ > for (i = 0; i < nb_output_files; i++) { > os = output_files[i]->ctx; > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/4] ffmpeg: re-copy codec contexts after encoding
This preserves changes to fields of AVCodecContext that get updated during encoding, such as trailing_padding (which may not be known until encoding is complete). --- ffmpeg.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/ffmpeg.c b/ffmpeg.c index df55a49..1e973f5 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4243,6 +4243,21 @@ static int transcode(void) term_exit(); +/* update output codec contexts after encoding */ +for (i = 0; i < nb_output_streams; i++) { +ost = output_streams[i]; +if (ost->encoding_needed) { +ret = avcodec_copy_context( +output_files[ost->file_index]->ctx->streams[ost->index]->codec, +ost->enc_ctx); +if (ret < 0) { +av_log(ost, AV_LOG_ERROR, "Error copying final codec context: %s\n", av_err2str(ret)); +if (exit_on_error) +exit_program(1); +} +} +} + /* write the trailer if needed and close file */ for (i = 0; i < nb_output_files; i++) { os = output_files[i]->ctx; -- 2.8.0.rc3.226.g39d4020 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel