diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 8a1784f94f07c73df8ef29c77b5d1f9d84dcf39e..efeadb6b9df450f73eeeae41114d7d39f9a5abee 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -4113,7 +4113,7 @@ not_extra:
     if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
         if (avctx->skip_frame >= AVDISCARD_NONREF ||
             buf_size >= 4 && !memcmp("Q264", buf, 4))
-            return 0;
+            return buf_size;
         av_log(avctx, AV_LOG_ERROR, "no frame!\n");
         return -1;
     }