[Ffmpeg-devel] av_read_frame and EOF

Steve Lhomme slhomme
Thu Apr 27 23:00:43 CEST 2006


We've been struggling with issues where we read some files with 
libavformat and at the end of the file we loop infinitely looking for a 
packet that never comes.

Our loop to read packets is similar to what ffplay does:

while(1) {
   ret = av_read_frame(fctx, &pkt);

   if (ret < 0) {
       if (url_ferror(&fctx->pb)) {
       } else

But for some files (MOV and WMV at least) the demuxer is too smart and 
will not read past its boundaries. That means if no packet is left to 
read it won't attempt to read more. So the underlying I/O stream never 
reports an error nor an EOF. This lead to an infinite loop...

So my question is: is the demuxer supposed to return a different value 
if there is a stream error or if there is no packet left ? Is there any 
way to know in which case we are ?

We also have the case where we use url_feof() instead of url_ferror(). 
The problem is the same. But WMV at least tries to look around in the 
file and so we can detect the EOF with a patched url_fseek().

Thanks for any clue.

(or conclusion that av_read_packet() < 0 means don't bother reading a 
new packet)


More information about the ffmpeg-devel mailing list