title: Progressive or Interlace detection in ffmpeg
body: <p>I am trying to write a decoder using ffmpeg and I want to display some information about the video stream. I can detect if a frame is progressive or interlaced (tff, bff) only after decoding the frame. i.e,</p>
  
  <pre><code>avcodec_decode_video2(pCodecCtx, pFrame, &amp;gotFrame, &amp;packet);
  .....(assume we have a frame) 
  .....
  // print information
  printf("prog=%d inter=%d", !pFrame-&gt;interlaced_frame, pFrame-&gt;interlaced_frame);
  </code></pre>
  
  <p>This works well. </p>
  
  <p>But I want to know if there is a way of detecting this from the AVFormatContext, AVCodecCtx or AVCodec structs or some other functions. This would be very useful, if for example I want to abort decoding if the file is interlaced. I don't want to decode a frame to get this piece of information. </p>
  
  <p>I am trying to support MPEG2, H.264/AVC and HEVC codecs (either elementary streams or in MP4 container). </p>
  
  <p>Sorry if this is a trivial question! Thank you very much!</p>