use uniform io offered by libav; add eof detection