3

[Bash] Convert wav to mp3 via ffmpeg

 2 years ago
source link: http://siongui.github.io/2016/02/22/bash-wav-to-mp3-via-ffmpeg/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Question

Convert 9dt/9dtXXX.wav to output/9dtXXX.mp3, where XXX are numbers from 000 to 094.

Answer

Install ffmpeg:

# install ffmpeg on Ubuntu Linux 15.10
$ sudo apt-get install ffmpeg

The bash script to convert wav to mp3 via ffmpeg:

#!/bin/bash

OUTPUTDIR="output"

mkdir -p $OUTPUTDIR
for i in {000..094}
do
  ffmpeg -i 9dt/9dt$i.wav $OUTPUTDIR/9dt$i.mp3
done

Save the above bash script as wav2mp3.sh

Run the script by:

$ bash wav2mp3.sh

Tested on Ubuntu Linux 15.10


References:

[1]Google search: linux convert wav to mp3

[2]Converting WAV Files to High Quality MP3 Using Linux terminal - Stack Overflow

[3]Why would I choose Libav over FFmpeg, or is there even a difference? - Super User

[4]software installation - Is FFmpeg missing from the official repositories in 14.04? - Ask Ubuntu


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK