@@ -4255,6 +4255,21 @@ static int transcode(void)
term_exit();
+ /* update output codec parameters after encoding */
+ for (i = 0; i < nb_output_streams; i++) {
+ ost = output_streams[i];
+ if (ost->encoding_needed) {
+ ret = avcodec_parameters_from_context(
+ output_files[ost->file_index]->ctx->streams[ost->index]->codecpar,
+ 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;