Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not a direct answer, but is a lot of useful information for the above problem. After going through more information and coding a little, the following are my observations : </p> <p>I provided a <code>.mpg</code> file as input and these are my observations : </p> <p>BBC RD 1996/3 in it's very informative report says :</p> <blockquote> <p>To enable backward prediction from a future frame, the coder re-orders the pictures from natural display order to ‘transmission’ (or ‘bitstream’) order so that the B-picture is transmitted after the past and future pictures which it references. (See Fig. 14). This introduces a delay which depends upon the number of consecutive B-pictures. </p> </blockquote> <ul> <li><p>The provided input file had it's first few video frames as follows : (in their natural display order) </p> <p><code>I0 B0 B1 P0 B2 B3 P1 B4 B5 P2 B6 B7 P3 B8 B9 I1</code> ...</p></li> <li><p>But the encoder (during the process of encoding, at some time in the past when the file was encoded) puts the packets in the video stream as : (this is to enable decoding of <code>P</code> and <code>B</code> frames)</p> <p><code>I0 P0 B0 B1 P1 B2 B3 P2 B4 B5 P3 B6 B7 I1 B8 B9</code> ...</p></li> <li><p>Now, when <code>av_read_frame()</code> reads packets from the video stream, they are obtained in the same above order : </p> <p><code>I0 P0 B0 B1 P1 B2 B3 P2 B4 B5 P3 B6 B7 I1 B8 B9</code> ... </p></li> <li><p>This is what <code>avcodec_decode_video2()</code> does (or atleast is doing in this case) : </p> <p><em>Input</em> <code>I0</code> <code>(pts_I0, dts_I0)</code> -----> <code>DECODER</code> ----> <em>No Output Frame</em><br> <em>Input</em> <code>P0</code> <code>(pts_P0, dts_P0)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>I0</code> <code>(pts_I0, dts_P0)</code><br> <em>Input</em> <code>B0</code> <code>(pts_B0, dts_B0)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B0</code> <code>(pts_B0, dts_B0)</code><br> <em>Input</em> <code>B1</code> <code>(pts_B1, dts_B1)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B1</code> <code>(pts_B1, dts_B1)</code><br> <em>Input</em> <code>P1</code> <code>(pts_P1, dts_P1)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>P0</code> <code>(pts_P0, dts_P1)</code><br> <em>Input</em> <code>B2</code> <code>(pts_B2, dts_B2)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B2</code> <code>(pts_B2, dts_B2)</code><br> <em>Input</em> <code>B3</code> <code>(pts_B3, dts_B3)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B3</code> <code>(pts_B3, dts_B3)</code><br> <em>Input</em> <code>P2</code> <code>(pts_P2, dts_P2)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>P1</code> <code>(pts_P1, dts_P2)</code><br> <em>Input</em> <code>B4</code> <code>(pts_B4, dts_B4)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B4</code> <code>(pts_B4, dts_B4)</code><br> <em>Input</em> <code>B5</code> <code>(pts_B5, dts_B5)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B5</code> <code>(pts_B5, dts_B5)</code><br> <em>Input</em> <code>P3</code> <code>(pts_P3, dts_P3)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>P2</code> <code>(pts_P2, dts_P3)</code><br> <em>Input</em> <code>B6</code> <code>(pts_B6, dts_B6)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B6</code> <code>(pts_B6, dts_B6)</code><br> <em>Input</em> <code>B7</code> <code>(pts_B7, dts_B7)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B7</code> <code>(pts_B7, dts_B7)</code><br> <em>Input</em> <code>I1</code> <code>(pts_I1, dts_I1)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>P3</code> <code>(pts_P3, dts_I1)</code><br> <em>Input</em> <code>B8</code> <code>(pts_B8, dts_B8)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B8</code> <code>(pts_B8, dts_B8)</code><br> <em>Input</em> <code>B9</code> <code>(pts_B9, dts_B9)</code> -----> <code>DECODER</code> ----> <em>Output</em> <code>B9</code> <code>(pts_B9, dts_B9)</code> </p> <pre> Next Input Packet ---------> DECODER ----------> Next Output Frame </pre> <pre> (pts_PKT, dts_PKT) I1 (pts_I1, dts_PKT) </pre></li> </ul> <p>I think you can now notice that, at every step of decoding, the decoder <em>already has</em> the <em>other frames</em> (either past frames or future frames of the natural display order) to successfully decode the input packet. The decoder outputs frames in the natural display order. Also as far as I observed, usually the <em>pts</em> for access units (packets) containing I or P frames is AV_NOPTS_VALUE.</p> <p>PS : I do not know ASCII art ! Sorry if the illustration is not too good. Hope it helped others.<br> Now after knowing this, I guess it helps in understanding pts and dts much better.<br> <a href="https://stackoverflow.com/questions/14044335/keyframe-is-not-a-keyframe-av-pkt-flag-key-does-not-decode-to-av-picture-type-i">This link</a> and <a href="https://stackoverflow.com/questions/96107/can-the-ffmpeg-av-libs-return-an-accurate-pts">this link</a> are the other ones which I found useful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload