Fixed it, was overwriting the start of buf each time... just need to write back the avi now. (Possible small issues with videos?)