diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c
index aa32403a45d45bd0122acab3d523911484368281..e5905cf6e90c4063505d4b64943cb75f15447144 100644
--- a/libavcodec/y41penc.c
+++ b/libavcodec/y41penc.c
@@ -30,6 +30,7 @@ static av_cold int y41p_encode_init(AVCodecContext *avctx)
     }
 
     avctx->coded_frame = avcodec_alloc_frame();
+    avctx->bits_per_coded_sample = 12;
 
     if (!avctx->coded_frame) {
         av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");