diff --git a/ffmpeg.c b/ffmpeg.c
index 282f58f9e0f56b49f32e07618ba84c1e3786139e..501af29d916756dda78930b01793c512852a7f19 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2841,6 +2841,7 @@ static int transcode_init(void)
                    "Error initializing the output stream codec context.\n");
             exit_program(1);
         }
+        ost->st->codec->codec= ost->enc_ctx->codec;
     }
 
     /* init input streams */