title: Picture size 0x0 is invalid in FFMPEG log
body: <p>In my program I'm trying to decode an MPEG4 stream from a certain url and the decoding fails. Strangely, MPEG4 streams from other urls are decoded fine, so it's not a problem of the absence of the codec.</p>
  
  <p>Here's how I decode:</p>
  
  <p>1) Find the decoder:</p>
  
  <pre><code>   AVCodec* codec = avcodec_find_decoder(CODEC_ID_MPEG4);
  </code></pre>
  
  <p>2) Allocate a context </p>
  
  <pre><code> ACodecContext* ctx = avcodec_alloc_context3(0);
  </code></pre>
  
  <p>3) Open the codec</p>
  
  <pre><code>avcodec_open2(ctx, codec, 0) // it returns &gt; 0, fine 
  </code></pre>
  
  <p>4) Decoding a packet (which I have)</p>
  
  <pre><code>   avcodec_decode_video2(ctx, frame, &amp;decoded, &amp;packet);
  </code></pre>
  
  <p>Now <code>avcodec_decode_video2</code> fails returning <code>-1</code> and FFMPEG log prints:</p>
  
  <p><strong>Picture size 0x0 is invalid
  get_buffer() failed (-1 0 0x0)</strong></p>
  
  <p>If I manually set up <code>ctx-&gt;width</code> and <code>ctx-&gt;height</code> before decoding to the correct values (I know the dimensions of the picture) then it decodes fine.</p>
  
  <p>But I can not be sure of the dimensions all the time, therefore I would like to know if I can overcome the -1 error.</p>
  
  <p>By seeing the FFMPEG log output can anyone suggest something for me to do?</p>