Combining music or video files?

Roger Heathcote usenet at
Thu Jun 19 10:10:28 CEST 2008

John Salerno wrote:
> "Dennis Lee Bieber" <wlfraed at> wrote in message 
> news:1bydnYdof97ddsjVnZ2dnUVZ_uSdnZ2d at
>> On Sun, 15 Jun 2008 22:53:19 -0400, John Salerno
>> <johnjsal at> declaimed the following in comp.lang.python:
>> Even the simplest format -> WAV, which is normally uncompressed
>> audio samples, is wrapped in layers of informational packets.
>> snip other stuff!!!
> Yikes! Then what I'm reading from your post (and others) is no, I can't do 
> it my way. ;) It *did* seem a little too easy, after all! 

I can't speak for video (and I'd imagine it's a factor more difficult) 
but it's really not that hard to concatenate audio in python. What you 
need to do...

Import the right modules for the audio formats you want to read.
Decide on a master output format, say CD quality - PCM 16bit 44.1Khz Stereo.
Open a file for appending
Read through each of your source files loading them into memory
   Get the sample rate and format
   Run the sample data through a function to convert it to the master 
output format*
   Squirt it to disk

Finally take the resulting file, calculate a new header and munge the 
two together. Voila :)

*I'm sure several modules have functions/methods for this but it 
wouldn't be very hard to roll your own either.

Roger Heathcote

More information about the Python-list mailing list