[FFmpeg-devel] EOF and IO error checking

Michael Niedermayer michael at niedermayer.cc
Sun Aug 18 11:16:00 EEST 2019


On Sat, Aug 17, 2019 at 09:10:59PM +0200, Marton Balint wrote:
> Hi,
> 
> As you might now avio_feof() returns true both in case of actual EOF and in
> case of IO errors.
> 
> Some demuxers (matroska) have special handling for this exact reason, e.g.:
> 
> if (avio_feof(pb)) {
>     if (pb->error) {
>         return pb->error;
>     } else {
>         return AVERROR_EOF;
>     }
> }
> 
> Most of the demuxers do not, so there is a real chance that IO errrors are
> mistaken for EOF.
> 
> What should we do about this?
> 
> a) Fix every demuxer to return IO error if there is one.
> 
> b) Add special code to ff_read_packet which checks if there is an error in
> the IO context and return that if there is?

> 
> c) Add code to ffmpeg.c which checks the IO context error code after every
> av_read_frame call?

This while generally correct is not guranteed to be correct.
The internal IO context may have an IO error without the demuxer having an
error. From the possibility of reconnects to redundancy to errors after
all essential parts of a file ...
so this may need some flag per demuxer that either declares this relation
true or a flag declaring it false


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190818/c91753be/attachment.sig>


More information about the ffmpeg-devel mailing list