diff --git a/libavcodec/apiexample.c b/libavcodec/apiexample.c
index af339571b1a841aa673c1924a100bb8918bdb388..674560f0f9d20c6136ed2687dddcfb3404f85110 100644
--- a/libavcodec/apiexample.c
+++ b/libavcodec/apiexample.c
@@ -291,6 +291,9 @@ void video_decode_example(const char *outfilename, const char *filename)
 
     c= avcodec_alloc_context();
 
+    if(codec->capabilities&CODEC_CAP_TRUNCATED)
+        c->flags|= CODEC_FLAG_TRUNCATED; /* we dont send complete frames */
+
     /* for some codecs, such as msmpeg4 and mpeg4, width and height
        MUST be initialized there because these info are not available
        in the bitstream */