Help
Difference between revisions of "Converting audios"
Line 23: | Line 23: | ||
ffmpeg version 5.1.2-3ubuntu1 Copyright (c) 2000-2022 the FFmpeg developers | ffmpeg version 5.1.2-3ubuntu1 Copyright (c) 2000-2022 the FFmpeg developers | ||
built with gcc 12 (Ubuntu 12.2.0-14ubuntu2) | built with gcc 12 (Ubuntu 12.2.0-14ubuntu2) | ||
− | configuration: --prefix=/usr --extra-version=3ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared | + | configuration: --prefix=/usr --extra-version=3ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu |
+ | --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b | ||
+ | --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi | ||
+ | --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt | ||
+ | --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr | ||
+ | --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis | ||
+ | --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 | ||
+ | --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg | ||
+ | --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo | ||
+ | --enable-librav1e --enable-shared | ||
libavutil 57. 28.100 / 57. 28.100 | libavutil 57. 28.100 / 57. 28.100 | ||
libavcodec 59. 37.100 / 59. 37.100 | libavcodec 59. 37.100 / 59. 37.100 |
Revision as of 14:24, 29 December 2023
Converting audio files is a frequently needed task when serving audio files to target services and users.
How to convert large batch of audios ?
Dependencies
- Warning :
avconv
have been removed from Ubuntu packages since 18.04. Use ffmpeg instead.
sudo apt-get install lame ffmpeg
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/cmn-0a0a8a8b.flac" # path to .flac file into varible "$file"
$ ffmpeg -i "$file" # print out metadata of $file, for some formats only
ffmpeg version 5.1.2-3ubuntu1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (Ubuntu 12.2.0-14ubuntu2)
configuration: --prefix=/usr --extra-version=3ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu
--arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b
--enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis
--enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2
--enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg
--enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo
--enable-librav1e --enable-shared
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, ogg, from './data/cmn-0a0a8a8b.ogg':
Duration: 00:00:01.25, start: 0.000000, bitrate: 99 kb/s
Stream #0:0: Audio: vorbis, 44100 Hz, mono, fltp, 80 kb/s
Metadata:
TITLE : 高低
LICENSE : Creative Commons BY-SA 3.0 U.S
COPYRIGHT : (c) 2009 Yue Tan
ARTIST : Tan
DATE : 2009-07-08
GENRE : Speech
SWAC_LANG : cmn
SWAC_TEXT : 高低
SWAC_ALPHAIDX : gāodī
SWAC_SPEAK_NAME : Tan
SWAC_SPEAK_GENDER: F
SWAC_SPEAK_BIRTH_YEAR: 1978
SWAC_SPEAK_LANG : zho
SWAC_SPEAK_LANG_REGION: Liaoning
SWAC_SPEAK_LIV_COUNTRY: FR
SWAC_SPEAK_LIV_TOWN: Caen
SWAC_PRON_PHON : gāodī
SWAC_COLL_SECTION: HSK niveau IV
SWAC_COLL_LICENSE: Creative Commons BY-SA 3.0 U.S
SWAC_COLL_COPYRIGHT: (c) 2009 Yue Tan
SWAC_TECH_DATE : 2009-07-08
SWAC_TECH_SOFT : Shtooka Recorder/1.3
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 example, 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