MP4: fix segfault and file boundary detection