As far as i know the key frames can be categorized to two type of referencing frames: IDR frames and I-Frames. IDR frames are more important because they actually break the video stream, in this mean that all frames after IDR frame are not related to any frames before IDR. So IDR are a very special type of I-Frame. After IDR, we can see referencing and non referencing frames which are: I,P and B frames. I-Frames can be considered as key frames because the P and B should reference to I-frames (before or even after them) directly(for P frames) or indirectly(for B frames.<br>
For detecting IDR frames and I-Frames in NAL units you should search a specific bitstream.<br>The bitstream format is 00 00 01 X Y (in Hex)<br><br>X =  IDR Picture NAL Units (25, 45, 65)<br>X = Non IDR Picture NAL Units (01, 21, 41, 61) ; 01 = b-frames, 41 = p-frames<br>
since frames can be splitted over multiple NAL Units only consider the NAL Units with Y != 00 (in golomb code it would be 0×80)<br><br>Amir<br><br><div class="gmail_quote">On 12 September 2011 16:12, amol mahamuni <span dir="ltr"><<a href="mailto:ajm2707@yahoo.com">ajm2707@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt">
<div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt">Hello Experts!</div><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><br>
</div><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><span style="white-space:pre-wrap">     </span>I have MPEG4 stream from rtsp server. I could decode it and play it using ffmepg library.</div>
<div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><br></div><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><span style="white-space:pre-wrap">       </span>I stored the stream as binary files for later playing using ffmpeg library. </div>
<div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><span style="white-space:pre-wrap"> </span>I can play the stream in forward direction - just I want to feed the ffmpeg decoder with stored frames.</div>
<div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><br></div><div>A)<span style="font-family:'times new roman', 'new york', times, serif;font-size:12pt;white-space:pre-wrap">       </span><font face="'times new roman', 'new york', times, serif" size="3"><b>Now, my requirement is to play the stream in reverse direction</b>. Can you ppl suggest me a way to </font><font face="'times new roman', 'new york', times, serif">accomplish this?</font></div>
<div><font face="'times new roman', 'new york', times, serif" size="3"><span style="white-space:pre-wrap">      </span>I tried to feed the stored
 packets/data in reverse way but of course it's giving  bad stream (distorted and ill-motion video display).</font></div><div><font face="'times new roman', 'new york', times, serif" size="3"><span style="white-space:pre-wrap">     </span>Is there any trick through which decoder can understand about reverse playing? Is reverse playing possible with ffmpeg decode?</font></div>
<div><font face="'times new roman', 'new york', times, serif" size="3"><br></font></div><div><font face="'times new roman', 'new york', times, serif" size="3">B)<span style="white-space:pre-wrap">  </span>Also, what is key frame in MPEG4 video stream? How can I understand key frame?</font></div>
<div><font face="'times new roman', 'new york', times, serif" size="3"><span style="white-space:pre-wrap">      </span>If I could understand
 key frame, does decoder give a good decoded frame when I fed it with key frame?</font></div><div><font face="'times new roman', 'new york', times, serif" size="3"><br></font></div><div><font face="'times new roman', 'new york', times, serif" size="3"><span style="white-space:pre-wrap">   </span>My understanding is that when I feed MPEG4 key frame, ffmepg will output good decoded frame</font></div>
<div><font face="'times new roman', 'new york', times, serif" size="3"><span style="white-space:pre-wrap">      </span>- meaning key frame does not depend on other frames to produce good decoded frame output. Is it correct?</font></div>
<div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><br></div><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt">Thanks,</div>
<div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt">-Amol.</div></div></div><br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div>Amir H. Rouhi</div>
<div>PhD Student/ CSIT RMIT University</div>
<div>Room: 14-09-04</div><br>