]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mpeg.c
Dont give up after 100kb of zero bytes but returnd EAGAIN
[ffmpeg] / libavformat / mpeg.c
index c5afa1d1cb01e6429997817fe352d074454498d0..2b1cc34349bebc846b69dfd5f004fcefadf1f537 100644 (file)
@@ -247,8 +247,13 @@ static int mpegps_read_pes_header(AVFormatContext *s,
         startcode = find_next_start_code(s->pb, &size, &m->header_state);
         last_sync = url_ftell(s->pb);
     //printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(s->pb));
-    if (startcode < 0)
-        return AVERROR(EIO);
+    if (startcode < 0){
+        if(url_feof(s->pb))
+            return AVERROR_EOF;
+        //FIXME we should remember header_state
+        return AVERROR(EAGAIN);
+    }
+
     if (startcode == PACK_START_CODE)
         goto redo;
     if (startcode == SYSTEM_HEADER_START_CODE)
@@ -557,6 +562,7 @@ static int mpegps_read_packet(AVFormatContext *s,
     get_buffer(s->pb, pkt->data, pkt->size);
     pkt->pts = pts;
     pkt->dts = dts;
+    pkt->pos = dummy_pos;
     pkt->stream_index = st->index;
 #if 0
     av_log(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f size=%d\n",