Audio Maniputlation, Editing and Processing in Linux

Multiple loudness, normalization, mono, change kbit

for f in *.mp3
    # loudnorm and true peak and convert to mono with ffmpeg
    do ffmpeg -i $f -ac 1 -ab 64k  -af loudnorm=I=-16:TP=-1.5:LRA=11 `basename $f .mp3`-MONO-LOUDNORM.mp3

ffmpeg -i $f -ac 1 -ab 64k -af loudnorm=I=-16:TP=-1.5:LRA=11 `basename $f .mp3`-MONO-LOUDNORM.mp3

  • -i $f | input file name
  • -ac 1 | Set the number of audio channels. 1 = Mono
  • -ab 64k | Set the audio bitrate in bit/s
  • -af loudnorm=I=-16:TP=-1.5:LRA=11 | Apply EBU R128 loudness normalization. Includes both dynamic and linear normalization modes.

For details regarding the filters, see:

Extract parts from larger audio file

Will create the MP3 file target.mp3 which contains audio from source.mp3 starting at 01:05:34 up to 01:28:02, keeping the original codec and bitrate:

ffmpeg -i source.mp3 -acodec copy -ss 01:05:34 -to 01:28:02 target.mp3

Normalize files

sox --norm output1-MONO.wav output1-MONO.wav

Create WAV with 22kHz

sox GestiefelterKater-01-MONO.wav -r 22050 GestiefelterKater-01-MONO-22kHz.wav

Split long audio files (mp3/ogg)

mp3splt -f -t 4.0 -a -d split *.mp3

Now press the key to start the splitting. Mp3Splt writes status messages in the Command Prompt window as it works.

All the command line options are listed farther below. Here’s an explanation of the recommended options:

  • -f: for MP3 files only, increases precision and is needed if the MP3 files are variable bit rate (VBR).
  • -t TIME: specifies the length, measured in time, to make each piece. You will replace TIME with a numerical value expressed in minutes, such as 4.0 for four minutes or 7.30 for seven minutes, thirty seconds. In our example, we picked four minute pieces, so the command line will be
  • -a: automatically adjusts the split points to occur during silences, which avoids splitting in the middle of a word. Therefore, the pieces will vary in their exact length.
  • -d split: writes the split files to a sub-folder named split(you may pick any name you wish). The folder will be created if it doesn’t already exist. It’s more convenient if you don’t put the split files in the same folder with the original ones.
  • *.mp3: process all the MP3 files in the current folder. If you are splitting Ogg Vorbis files, change this to *.ogg.
mp3splt -a -t 30.00 -o Drood_02-@n -d Drood Drood2-MONO.mp3 

Creating a Video from Audio and Images for YouTube

ffmpeg  -loop 1 -r 1/3 -i egl-%03d.png -i audio.mp3 -vcodec copy -shortest -strict experimental video.mp4 

Extracting parts of a video

With ffmpeg

Getting the content from a video into a new file, in this example starting at minute 17 second 2 up to minute 21 and second 32.

ffmpeg -i Source-Video-Konzert.m4v -ss 00:17:02.000 -to 00:21:32.000  -c copy -copyts /home/micz/Videos/Video-Konzert.mp4