title: Why AVCodecContext extradata is NULL?
body: <p>I am trying to decode <code>h264</code> video using <code>ffmpeg</code> and <code>stagefright</code> library. I'm using <a href="https://vec.io/posts/use-android-hardware-decoder-with-omxcodec-in-ndk" rel="nofollow">this</a> example. </p>
  
  <p>The example shows how to decode <code>mp4</code> files, but i want to decode only <code>h264</code> video. </p>
  
  <p>Here is piece of my code.. </p>
  
  <pre><code>    AVFormatSource::AVFormatSource(const char *videoPath) 
      {
          av_register_all();
  
          mDataSource = avformat_alloc_context();
          avformat_open_input(&amp;mDataSource, videoPath, NULL, NULL);
          for (int i = 0; i &lt; mDataSource-&gt;nb_streams; i++) 
          {
              if (mDataSource-&gt;streams[i]-&gt;codec-&gt;codec_type == AVMEDIA_TYPE_VIDEO) 
              {
                  mVideoIndex = i;
                  break;
              }
          }
          mVideoTrack = mDataSource-&gt;streams[mVideoIndex]-&gt;codec;
  
          size_t bufferSize = (mVideoTrack-&gt;width * mVideoTrack-&gt;height * 3) / 2;
          mGroup.add_buffer(new MediaBuffer(bufferSize));
          mFormat = new MetaData;
  
          switch (mVideoTrack-&gt;codec_id == CODEC_ID_H264) 
          {
              mConverter = av_bitstream_filter_init("h264_mp4toannexb");
              mFormat-&gt;setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
              if (mVideoTrack-&gt;extradata[0] == 1) //SIGSEGV Here
              {
                  mFormat-&gt;setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
                  mFormat-&gt;setData(kKeyAVCC, kTypeAVCC, mVideoTrack-&gt;extradata,
                                   mVideoTrack-&gt;extradata_size);
              }
           }
  
          mFormat-&gt;setInt32(kKeyWidth, mVideoTrack-&gt;width);
          mFormat-&gt;setInt32(kKeyHeight, mVideoTrack-&gt;height);
      }
  </code></pre>
  
  <p><code>mVideoTrack-&gt;extradata</code> is NULL. What i'm doing wrong?? My question is, what should be in <code>mVideoTrack-&gt;extradata</code> for <strong>kKeyAVCC</strong> ?? </p>
  
  <p>Please help me, I need Your help. 
  Thanks in advance. </p>