Rocshy
Rocshy

Reputation: 3509

Delete first segments of an audio file

Is there any tool or piece of code that could be used to remove the first 10 seconds of many audio files? You could select the path to a folder that contains lots of audio files, and process them. The files are in mp3 format.

Upvotes: 1

Views: 514

Answers (1)

learnvst
learnvst

Reputation: 16193

Option 1: Scripting language.

I have done stuff like this before on wav files using Matlab as it has convenient builtin wavread and wavwrite commands. However, any scripting language that abstracts the file reading/writing part of the job should be fit for purpose. The easiest way is to have an inbox type folder with the files to be processed, and an outbox type folder for the modified files. You then just create a script that reads that does the following . . .

  • Looks at the files in the folder, perhaps organising the file names into a list

  • Begins to loop over the files in the list

    • Opens the file at the current loop index

    • Convert the file into a raw (uncompressed) sample array

    • Truncates the file by the appropriate number of samples

    • Convert the raw samples back to your desired compressed format

    • Write the file to the outbox

There are mp3read and mp3write functions available for Matlab, and I'm sure there are similar for whatever scripting language you're comfortable with. The only problem that I can foresee, is that repeated conversion between compressed and uncompressed formats would probably begin to leave audible artefacts. For fidelity, the best solution might be one that directly modifies the mp3 file format, although this would actually require a good understanding of the mp3 format itself (unless there is a library for this type of functionality)

Option 2: Batching in sound editing software

It looks as if you might be able to batch process audio clips using Audacity ...

http://manual.audacityteam.org/man/Batch_Processing

... and other editing software, such as Audition, might have similar batching functionality. You'll have to search the documentation to see if these batching processes will do what you want.

Upvotes: 1

Related Questions