diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 49b45779e41031f0b5f0ba5c450bdbb58e88f6bd..d8ba07bc1de7dad1161cfe6824cb03e9b7780c6c 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -103,6 +103,8 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
     FLACContext *s = avctx->priv_data;
     s->avctx = avctx;
 
+    avctx->sample_fmt = SAMPLE_FMT_S16;
+
     if (avctx->extradata_size > 4) {
         /* initialize based on the demuxer-supplied streamdata header */
         if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {
@@ -115,7 +117,6 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
         }
     }
 
-    avctx->sample_fmt = SAMPLE_FMT_S16;
     return 0;
 }