Reputation: 12414
If I have several audio files in a directory, how would I go about writing a script that would take the audio from the time 10 seconds to 20 seconds from each file and concatenate these 10 second chunks together into a single audio file? Any specific packages, extensions, etc. which would be helpful? (I would prefer an answer for generic file types, but if a specific format is needed let's go with mp3)
I would prefer python, but if you have an easy solution in some other language, please tell me.
Thank you much!
Upvotes: 0
Views: 851
Reputation: 139
If you prefer to make a solution yourself, you can also glue MP3 files together. They're composed by just a sequence of frames, so if you copy byte-by-byte each file to an unique file, it should work well.
For the audio extraction, if you can rely on an external programme, you can use FFmpeg, and the -t
and -tt
options, with the -acodec copy
switch, to preserve the original data.
Upvotes: 1
Reputation: 2909
I've used mp3wrap from a bash script to catenate mp3's. The mp3wrap package includes an mp3splt executable.
It's not Python, but you could subprocess them from Python. They appear to be written in C, based on a quick ldd.
Upvotes: 1