diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index fc9fc1b58f1267260a284323ab75b0f0bd955e1e..b3cce3ab207cb0d56219c8d8a458eb5be0ed30b1 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -340,13 +340,14 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         put_byte(pb, FLV_TAG_TYPE_AUDIO);
     }
 
-    if (enc->codec_id == CODEC_ID_H264 &&
+    if (enc->codec_id == CODEC_ID_H264) {
         /* check if extradata looks like mp4 formated */
-        enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1) {
+        if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1) {
         if (ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size) < 0)
             return -1;
         assert(pkt->size);
         size = pkt->size;
+        }
         /* cast needed to get negative value */
         if (!flv->delay && pkt->dts < 0)
             flv->delay = -pkt->dts;