Create fade mp3 sample

I need to know if it is possible to create a 30 second sample MP3 from a WAV file. The generated MP3 file must have fading at the beginning and end.

Currently, ffmpeg is used, but cannot find any documentation that supports the ability to perform such a task.

Can someone please provide me with the name of the software (CLI, * nix only) that could do this?

+7
encoding ffmpeg mp3
source share
3 answers

Check out SoX - Sound eXchange

I did not use it myself, but one of my friends appreciates it.

From a web page (highlighted by me):

SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various computer audio file formats to other formats. It can also apply various effects to these sound files , and as an added bonus, SoX can play and record audio files on most platforms.

+6
source share

This will

  • finishing from a position of 45 sec. the next 30 seconds (0: 45.0 30) and
  • fade out the first 5 seconds (0: 5) and the last 5 seconds (0 0: 5) and
  • convert from wav to mp3

    sox infile.wav outfile.mp3 trim 0:45.0 30 fade h 0:5 0 0:5 
+12
source share

The best way to do this is to apply a 30 second truncation, fade out and fade out to WAV audio files before converting it to MP3. If your conversion library has a method that accepts an array of samples, this is very easy to do. If the method accepts only a WAV file (either in memory or on disk), then this is a little less simple, since you need to learn the format of a WAV file (which is easy to write, but somewhat harder to read). In any case, applying gain and / or attenuation to time domain data (like in a WAV file) is much simpler than trying to apply these effects to frequency domain data (like in an MP3 file).

Of course, if your conversion library already does all of this, it's best to use it and not worry about it yourself.

+1
source share

All Articles