#!/usr/bin/python # Recalculate the length fields in the header of a WAV file. # Adam Sampson # # I managed to persuade ecasound to produce a WAV file with the length set to # zero (probably by killing it in a funny way before it had a chance to write # them properly), and writing this was quicker than doing the recording again. import sys, os, struct def print_header(header): print " Chunk size:", struct.unpack("= 1L << 32: print "File is longer than 2GB -- setting length to less than that." print "This will ignore the remaining data in the file." length = (1L << 32) - 36 - 4 - 4 chunk_size = length - 4 data_size = chunk_size - 36 header = (header[:4] + struct.pack("