How to split WAV files which have grown larger than file size limit

11 次查看(过去 30 天)
I have a scientific instrument which continually logs to a wav file until the user stops the recording. A colleague left it running too long resulting in a 3GB+ file, and the header of the wave file getting corrupted. The only fields which show up using audioinfo are the sample rate and bytes per sample. It have attempted to generate a blank 10 minute wav file, and then replace the data from byte 44 onwards (I.e. I skip the header). The approach didn’t work. Does anyone have ideas of other approaches I can try?

回答(1 个)

Walter Roberson
Walter Roberson 2022-12-5
However, depending on how the data was logged, it might not be possible to get anything back.
When growing WAV files, it is common for one chunk of WAV data to be written out, and then for the header to be updated to reflect how long it turned out to be. Unfortunately that is prone to problems if you try to store more than the maximum file size, or if something goes wrong during the writing. One approach that reduces the errors is to update the header after a bufffer-full, so that at any one time only the last buffer might go missing... provided that you do not write too much data.
Another approach when growing WAV files is to put bunches of samples into separate segments. If I recall correctly you can get around some of the header limitations by mostly ignoring them, and writing out chunks that each individually live within the size limits. The original WAV format was designed by Microsoft to be able to just copy one WAV file after another without having to update anything in the headers. If that is the approach taken by the software, you might be able to get a fair bit of the data back, perhaps.
But if the data happened to be logged to a filesystem that has a 2 gigabyte limit, then it becomes more difficult to predict what the file system would have done with the file when you tried to grow the file larger than that.
  3 个评论
Walter Roberson
Walter Roberson 2022-12-5
I am confused now about whether you are asking how to rescue an particular corrupted file, or if you are asking for techniques to prevent the problem in the future ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by