Help
Difference between revisions of "Converting audios"
m |
|||
Line 1: | Line 1: | ||
= How to convert large batch of audios ? = | = How to convert large batch of audios ? = | ||
== Dependencies == | == Dependencies == | ||
− | < | + | <syntaxhighlight lang="bash"> |
sudo apt-get install lame avconv | sudo apt-get install lame avconv | ||
man lame # then search for parameters via "/{param}". ex: /-m | man lame # then search for parameters via "/{param}". ex: /-m | ||
− | </ | + | </syntaxhighlight> |
== Technolect == | == Technolect == | ||
Line 13: | Line 13: | ||
== Helpers == | == Helpers == | ||
− | < | + | <syntaxhighlight lang="bash"> |
mkdir -p ./new/ # create folder, if not existing (-p) | mkdir -p ./new/ # create folder, if not existing (-p) | ||
file="./dir/audio-0a6f36g.flac" # path to .flac file into varible "$file" | file="./dir/audio-0a6f36g.flac" # path to .flac file into varible "$file" | ||
avconv -i "$file" 2>1 # print out metadata of $file, for some formats only | avconv -i "$file" 2>1 # print out metadata of $file, for some formats only | ||
− | </ | + | </syntaxhighlight> |
== Simple batch format conversion == | == Simple batch format conversion == | ||
− | < | + | <syntaxhighlight lang="bash"> |
for file in ./flac/*.flac | for file in ./flac/*.flac | ||
do | do | ||
Line 26: | Line 26: | ||
lame --abr 24 -m m -h --resample 22.05 "$file" "./new/$key"; | lame --abr 24 -m m -h --resample 22.05 "$file" "./new/$key"; | ||
done | done | ||
− | </ | + | </syntaxhighlight> |
== Metadata-based format conversion == | == Metadata-based format conversion == | ||
This example works on SWAC recorder audio files having the <code>SWAC_TEXT</code> metadata field. In this exemple, we assume a folder with file <code>audio-0a6f36g.flac</code> and metadata <code>SWAC_TEXT : 很</code>. | This example works on SWAC recorder audio files having the <code>SWAC_TEXT</code> metadata field. In this exemple, we assume a folder with file <code>audio-0a6f36g.flac</code> and metadata <code>SWAC_TEXT : 很</code>. | ||
− | < | + | <syntaxhighlight lang="bash"> |
for file in ./flac/*.flac | for file in ./flac/*.flac | ||
do | do | ||
Line 37: | Line 37: | ||
lame --abr 24 -m m -h --resample 22.05 "$file" "./new-24k/cmn-$key.mp3"; # ex: cmn-很.mp3 (24k abr) | lame --abr 24 -m m -h --resample 22.05 "$file" "./new-24k/cmn-$key.mp3"; # ex: cmn-很.mp3 (24k abr) | ||
lame --cbr -b 96 -m m -h --resample 22.05 "$file" "./new-96k/cmn-$key.mp3"; # ex: cmn-很.mp3 (96k cbr) | lame --cbr -b 96 -m m -h --resample 22.05 "$file" "./new-96k/cmn-$key.mp3"; # ex: cmn-很.mp3 (96k cbr) | ||
− | done</ | + | done</syntaxhighlight> |
== See also == | == See also == |
Revision as of 07:37, 20 May 2021
How to convert large batch of audios ?
Dependencies
sudo apt-get install lame avconv
man lame # then search for parameters via "/{param}". ex: /-m
Technolect
cbr
: constant bit rate.abr
: average bit rate.vbr
: variable bit rate.
For more, see man lame
.
Helpers
mkdir -p ./new/ # create folder, if not existing (-p)
file="./dir/audio-0a6f36g.flac" # path to .flac file into varible "$file"
avconv -i "$file" 2>1 # print out metadata of $file, for some formats only
Simple batch format conversion
for file in ./flac/*.flac
do
key=$(basename "$file" .flac).mp3 # name of the file minus .flac, plus .mp3
lame --abr 24 -m m -h --resample 22.05 "$file" "./new/$key";
done
Metadata-based format conversion
This example works on SWAC recorder audio files having the SWAC_TEXT
metadata field. In this exemple, we assume a folder with file audio-0a6f36g.flac
and metadata SWAC_TEXT : 很
.
for file in ./flac/*.flac
do
key=$(avconv -i "$file" 2>&1 | sed -ne 's/.*SWAC_TEXT *: //p') # print metadata, assign SWAC_TEXT's value to variable.
lame --abr 24 -m m -h --resample 22.05 "$file" "./new-24k/cmn-$key.mp3"; # ex: cmn-很.mp3 (24k abr)
lame --cbr -b 96 -m m -h --resample 22.05 "$file" "./new-96k/cmn-$key.mp3"; # ex: cmn-很.mp3 (96k cbr)
done