[FFmpeg-cvslog] generic seeking: fail if there are 1000 non keyframes found with no keyframe.

Michael Niedermayer git at videolan.org
Wed Oct 5 20:29:14 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Oct  5 18:23:47 2011 +0200| [f9bd9794763004852e4410f23d3f155a478357f1] | committer: Michael Niedermayer

generic seeking: fail if there are 1000 non keyframes found with no keyframe.
This avoids scanning through a whole file just to fail.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f9bd9794763004852e4410f23d3f155a478357f1
---

 libavformat/utils.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7fe2a95..d8b62f3 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1749,6 +1749,7 @@ static int seek_frame_generic(AVFormatContext *s,
 
     if(index < 0 || index==st->nb_index_entries-1){
         AVPacket pkt;
+        int nonkey=0;
 
         if(st->nb_index_entries){
             assert(st->index_entries);
@@ -1768,9 +1769,13 @@ static int seek_frame_generic(AVFormatContext *s,
             if (read_status < 0)
                 break;
             av_free_packet(&pkt);
-            if(stream_index == pkt.stream_index){
-                if((pkt.flags & AV_PKT_FLAG_KEY) && pkt.dts > timestamp)
+            if(stream_index == pkt.stream_index && pkt.dts > timestamp){
+                if(pkt.flags & AV_PKT_FLAG_KEY)
                     break;
+                if(nonkey++ > 1000){
+                    av_log(s, AV_LOG_ERROR,"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
+                    break;
+                }
             }
         }
         index = av_index_search_timestamp(st, timestamp, flags);



More information about the ffmpeg-cvslog mailing list