There is one stupid bug in code above. formatSegmentPath must have the way to pick right time based on index number, so time cant be get each time from time() function but interpolated. Sorry for this. I write fix on Thursday.