Recorder and write data to file in specified duration.