diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index ac4cd3115783cfc912fae43066654ec6d5a74a76..d5736dc5dcb42f0e90eda916e235af7816bddb3d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1332,7 +1332,7 @@ const AVClass *avformat_get_class(void);
  *
  * @return newly created stream or NULL on error.
  */
-AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c);
+AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
 
 /**
  * Get side information from stream.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 133822b3685c930b07089f5d13020116939319a0..7a054afd3b5fddbcc7ae01b21d980af64a0ac04e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2641,7 +2641,7 @@ void avformat_close_input(AVFormatContext **ps)
     avio_close(pb);
 }
 
-AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
+AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
 {
     AVStream *st;
     int i;