・2017/12/01
Amazon AWS EC2で MP3に対応の最新版の Sox Sound eXchange v14.4.2をビルドする方法
(AWS Lambda用に Sox Sound eXchangeの MP3対応版を Staticライブラリ指定でコンパイルする方法)
Tags: [Raspberry Pi], [電子工作]
● Raspberry Pi 3 Model Bを遂に購入
Raspberry Pi3 Model B RPI2 RPI3
大人気の CPUボードの Raspberry Piに WiFiと Bluetoothが搭載されたモデルが新発売となりました。
以前から Raspberry Pi 2を買おうかどうか迷っていましたが、Raspberry Pi 3 Model Bの発売を機に購入を決意してラズベリアンになる事にしました。
※ ラズパイの OS Raspbianはバージョンが上がる毎に過去の版と OSの内部の作りが変わり、過去に書かれた製作記事(例えば Raspbian Wheezyの時代の記事)がそのままではエラーが出たりして動かない事が有ります。
※ 当方のホームページのラズパイ記事は全て Raspberry Pi 3 Model Bと Raspbian Jessieの組み合わせで動作確認をしております。
(ただし、将来的に新しい Raspbian OSが出た場合に、当方の Raspbian Jessieを基にした内容がそのままでは動かない可能性が有ります。)
※ 2017/08/16から Raspbian OSは Raspbian Jessieから Raspbian Stretchに変わりました。
※ 2019/06/20から Raspbian OSは Raspbian Stretchから Raspbian Busterに変わりました。
Download Raspbian for Raspberry Pi
ちなみに、歴代のバージョンと名称は
Debian | コードネーム | 年月 | 備考 | (参考)Ubuntuでの該当名称 |
Debian 11 | Bullseye | 2021/08/14~ | 2021/11からラズパイにリリース | Focal Fossa 20.04 LTS ? |
Debian 10 | Buster | 2019/06/20~ | 2019/06からラズパイ4対応 | Bionic 18.04 LTS |
Debian 9 | Stretch | 2017/08/16~ | 2018/03からラズパイ3B+対応 | Xenial 16.04 LTS |
Debian 8 | Jessie | 2015~ | 2016/02からラズパイ3対応 | Trusty 14.04 LTS |
Debian 7 | Wheezy | 2013~2016 | | |
Debian 6.0 | Squeeze | 2011~2014 | | |
Debian GNU/Linux 5.0 | Lenny | 2009~2012 | | |
● SoXのソースコードからコンパイルしてバイナリを作成してみる
yum install soxでインストールした Sound eXchangeにはライセンスの関係で MP3機能が有りません。
MP3に対応した SoXは自前でコンパイルして作成する必要が有ります。
オーディオ形式のファイル変換アプリの SoXをコンパイルします。
AWSの Lambdaで動かすので Staticライブラリ指定でビルドします。
Amazon Elastic Transcoder(AWS - メディア、動画の変換サービス)を使うまでも無い用途に SoXを使います。
SoX - Sound eXchange
SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in 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.
Amazon Elastic Transcoder
Amazon Elastic Transcoder はクラウドのメディア変換サービスです。
login as: ec2-user
Authenticating with public key "imported-openssh-key"
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2017.09-release-notes/
No packages needed for security; 1 packages available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
[ec2-user@ip-xxx-xxx-xxx-xxx libmad-0.15.1b]$ yum -y install gcc44 gcc-c++ libgcc44 cmake
Loaded plugins: priorities, update-motd, upgrade-helper
You need to be root to perform this command.
sudo yum -y install gcc44 gcc-c++ libgcc44 cmake
Installed:
cmake.x86_64 0:2.8.12.2-4.25.amzn1 gcc-c++.noarch 0:4.8.5-1.22.amzn1
gcc44.x86_64 0:4.4.6-4.81.amzn1 libgcc44.x86_64 0:4.4.6-4.81.amzn1
Dependency Installed:
cloog-ppl.x86_64 0:0.15.11-3.6.amzn1
compat-gmp4.x86_64 0:4.3.2-1.14.amzn1
compat-mpfr2.x86_64 0:2.4.2-1.12.amzn1
cpp44.x86_64 0:4.4.6-4.81.amzn1
cpp48.x86_64 0:4.8.5-11.135.amzn1
gcc.noarch 0:4.8.5-1.22.amzn1
gcc48.x86_64 0:4.8.5-11.135.amzn1
gcc48-c++.x86_64 0:4.8.5-11.135.amzn1
glibc-devel.x86_64 0:2.17-196.172.amzn1
glibc-headers.x86_64 0:2.17-196.172.amzn1
kernel-headers.x86_64 0:4.9.62-21.56.amzn1
libarchive.x86_64 0:3.1.2-10.11.amzn1
libgcc48.x86_64 0:4.8.5-11.135.amzn1
libgomp.x86_64 0:6.4.1-1.45.amzn1
libmpc.x86_64 0:1.0.1-3.3.amzn1
libstdc++48.x86_64 0:4.8.5-11.135.amzn1
lzo.x86_64 0:2.08-1.5.amzn1
mpfr.x86_64 0:3.1.1-4.14.amzn1
ppl.x86_64 0:0.11.2-8.7.amzn1
ppl-pwl.x86_64 0:0.11.2-8.7.amzn1
Complete!
sudo yum update
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
amazon-ssm-agent x86_64 2.2.120.0-1.amzn1 amzn-updates 11 M
Transaction Summary
================================================================================
Upgrade 1 Package
cd
mkdir SOX
cd SOX
# SoX - Sound eXchange
# http://sox.sourceforge.net/
wget https://jaist.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2
tar xvf sox-14.4.2.tar.bz2
# MAD: MPEG Audio Decoder
# https://www.underbit.com/products/mad
wget https://jaist.dl.sourceforge.net/project/mad/libmad/0.15.1b/libmad-0.15.1b.tar.gz
tar xvf libmad-0.15.1b.tar.gz
# FLAC - Free Lossless Audio Codec
# http://flac.sourceforge.net
wget https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.2.tar.xz
tar xvf flac-1.3.2.tar.xz
# Vorbis.com - Ogg Vorbis
# http://www.vorbis.com
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.xz
tar xvf libogg-1.3.3.tar.xz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz
tar xvf libvorbis-1.3.5.tar.xz
# Opus Interactive Audio Codec
# http://www.opus-codec.org/comparison/
# wget https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
# tar xvf opus-1.2.1.tar.gz
# Sound eXchange SoXを MP3に対応させる
# The LAME Project - Hhigh quality MP3 encoder
# http://lame.sourceforge.net
wget https://jaist.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xvf lame-3.100.tar.gz
#-----------------------
mkdir tmp
SOX_CPPFLAGS=""
SOX_LDFLAGS=""
SOX_WITH=""
mkdir tmp/libmad
cd libmad-0.15.1b
# gcc: error: unrecognized command line option '-fforce-mem'; did you mean '-fforce-addr'?
# $ grep "\-fforce-mem" configure
# optimize="$optimize -fforce-mem"
sed -i '/-fforce-mem/d' configure
./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/libmad)
make && make install
SOX_CPPFLAGS="$SOX_CPPFLAGS -I$(realpath ../tmp/libmad/include)"
SOX_LDFLAGS="$SOX_LDFLAGS -L$(realpath ../tmp/libmad/lib)"
SOX_WITH="$SOX_WITH --with-mad"
cd ..
#-----------------------
mkdir tmp/flac
cd flac-1.3.2
./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/flac)
make && make install
SOX_CPPFLAGS="$SOX_CPPFLAGS -I$(realpath ../tmp/flac/include)"
SOX_LDFLAGS="$SOX_LDFLAGS -L$(realpath ../tmp/flac/lib)"
SOX_WITH="$SOX_WITH --with-flac"
cd ..
#-----------------------
mkdir tmp/lame
cd lame-3.100
./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/lame)
make && make install
SOX_CPPFLAGS="$SOX_CPPFLAGS -I$(realpath ../tmp/lame/include)"
SOX_LDFLAGS="$SOX_LDFLAGS -L$(realpath ../tmp/lame/lib)"
SOX_WITH="$SOX_WITH --with-lame"
cd ..
#-----------------------
# mkdir tmp/opus
# cd opus-1.2.1
# ./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/opus)
# make && make install
# cd ..
# wget https://archive.mozilla.org/pub/opus/opus-tools-0.1.10.tar.gz
# tar xvf opus-tools-0.1.10.tar.gz
# cd opus-tools-0.1.10
# ./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/opus)
#-----------------------
mkdir tmp/libogg
cd libogg-1.3.3
./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/libogg)
make && make install
SOX_CPPFLAGS="$SOX_CPPFLAGS -I$(realpath ../tmp/libogg/include)"
SOX_LDFLAGS="$SOX_LDFLAGS -L$(realpath ../tmp/libogg/lib)"
cd ..
mkdir tmp/libvorbis
cd libvorbis-1.3.5
CPPFLAGS="-I$(realpath ../tmp/libogg/include)" \
LDFLAGS="-L$(realpath ../tmp/libogg/lib)" \
./configure --enable-static --disable-shared --prefix=$(realpath ../tmp/libvorbis)
make && make install
SOX_CPPFLAGS="$SOX_CPPFLAGS -I$(realpath ../tmp/libvorbis/include)"
SOX_LDFLAGS="$SOX_LDFLAGS -L$(realpath ../tmp/libvorbis/lib)"
SOX_WITH="$SOX_WITH --with-oggvorbis"
cd ..
# echo "*** Warning: Doxygen not found; documentation will not be built."
# *** Warning: Doxygen not found; documentation will not be built.
# touch doxygen-build.stamp
#-----------------------
mkdir tmp/sox
cd sox-14.4.2
CPPFLAGS="$SOX_CPPFLAGS" \
LDFLAGS="$SOX_LDFLAGS" \
./configure --disable-shared --enable-static --prefix=$(realpath ../tmp/sox) \
$SOX_WITH \
--without-png --without-lpc10 --without-gsm \
--disable-symlinks
make clean
make -s && make install
cd ..
cp ./tmp/sox/bin/sox .
ls -l sox
BUILD OPTIONS
Debugging build............no
Distro name ...............not specified!
Dynamic loading support....no
Pkg-config location........$(libdir)/pkgconfig
Play and rec symlinks......no
Symlinks enabled...........no
OPTIONAL DEVICE DRIVERS
ao (Xiph)..................no
alsa (Linux)...............no
coreaudio (Mac OS X).......no
sndio (OpenBSD)............no
oss........................yes
pulseaudio.................no
sunaudio...................no
waveaudio (MS-Windows).....no
OPTIONAL FILE FORMATS
amrnb......................no
amrwb......................no
flac.......................yes
gsm........................no
lpc10......................no
mp2/mp3....................yes
id3tag....................no
lame......................yes
lame id3tag...............yes
dlopen lame...............no
mad.......................yes
dlopen mad................no
twolame...................no
oggvorbis..................yes
opus.......................no
sndfile....................no
wavpack....................no
OTHER OPTIONS
ladspa effects.............no
magic support..............no
png support................no
OpenMP support.............yes, -fopenmp
Configure finished. Do 'make -s && make install' to compile and install SoX.
[ec2-user@ip-xxx-xxx-xxx-xxx SOX]$ ls -l sox
-rwxr-xr-x 1 ec2-user ec2-user 5117960 Dec 14 14:03 sox
[ec2-user@ip-xxx-xxx-xxx-xxx SOX]$ ./sox --version
./sox: SoX v14.4.2
[ec2-user@ip-xxx-xxx-xxx-xxx SOX]$ ./sox
./sox: SoX v14.4.2
./sox FAIL sox: Not enough input filenames specified
Usage summary: [gopts] [[fopts] infile]... [fopts] outfile [effect [effopt]]...
SPECIAL FILENAMES (infile, outfile):
- Pipe/redirect input/output (stdin/stdout); may need -t
-d, --default-device Use the default audio device (where available)
-n, --null Use the `null' file handler; e.g. with synth effect
-p, --sox-pipe Alias for `-t sox -'
SPECIAL FILENAMES (infile only):
"|program [options] ..." Pipe input from external program (where supported)
http://server/file Use the given URL as input file (where supported)
GLOBAL OPTIONS (gopts) (can be specified at any point before the first effect):
--buffer BYTES Set the size of all processing buffers (default 8192)
--clobber Don't prompt to overwrite output file (default)
--combine concatenate Concatenate all input files (default for sox, rec)
--combine sequence Sequence all input files (default for play)
-D, --no-dither Don't dither automatically
--dft-min NUM Minimum size (log2) for DFT processing (default 10)
--effects-file FILENAME File containing effects and options
-G, --guard Use temporary files to guard against clipping
-h, --help Display version number and usage information
--help-effect NAME Show usage of effect NAME, or NAME=all for all
--help-format NAME Show info on format NAME, or NAME=all for all
--i, --info Behave as soxi(1)
--input-buffer BYTES Override the input buffer size (default: as --buffer)
--no-clobber Prompt to overwrite output file
-m, --combine mix Mix multiple input files (instead of concatenating)
--combine mix-power Mix to equal power (instead of concatenating)
-M, --combine merge Merge multiple input files (instead of concatenating)
--multi-threaded Enable parallel effects channels processing
--norm Guard (see --guard) & normalise
--play-rate-arg ARG Default `rate' argument for auto-resample with `play'
--plot gnuplot|octave Generate script to plot response of filter effect
-q, --no-show-progress Run in quiet mode; opposite of -S
--replay-gain track|album|off Default: off (sox, rec), track (play)
-R Use default random numbers (same on each run of SoX)
-S, --show-progress Display progress while processing audio data
--single-threaded Disable parallel effects channels processing
--temp DIRECTORY Specify the directory to use for temporary files
-T, --combine multiply Multiply samples of corresponding channels from all
input files (instead of concatenating)
--version Display version number of SoX and exit
-V[LEVEL] Increment or set verbosity level (default 2); levels:
1: failure messages
2: warnings
3: details of processing
4-6: increasing levels of debug messages
FORMAT OPTIONS (fopts):
Input file format options need only be supplied for files that are headerless.
Output files will have the same format as the input file where possible and not
overridden by any of various means including providing output format options.
-v|--volume FACTOR Input file volume adjustment factor (real number)
--ignore-length Ignore input file length given in header; read to EOF
-t|--type FILETYPE File type of audio
-e|--encoding ENCODING Set encoding (ENCODING may be one of signed-integer,
unsigned-integer, floating-point, mu-law, a-law,
ima-adpcm, ms-adpcm, gsm-full-rate)
-b|--bits BITS Encoded sample size in bits
-N|--reverse-nibbles Encoded nibble-order
-X|--reverse-bits Encoded bit-order
--endian little|big|swap Encoded byte-order; swap means opposite to default
-L/-B/-x Short options for the above
-c|--channels CHANNELS Number of channels of audio data; e.g. 2 = stereo
-r|--rate RATE Sample rate of audio
-C|--compression FACTOR Compression factor for output format
--add-comment TEXT Append output file comment
--comment TEXT Specify comment text for the output file
--comment-file FILENAME File containing comment text for the output file
--no-glob Don't `glob' wildcard match the following filename
AUDIO FILE FORMATS: 8svx aif aifc aiff aiffc al amb au avr cdda cdr cvs cvsd cvu dat dvms f32 f4 f64 f8 flac fssd gsrt hcom htk ima ircam la lu maud mp2 mp3 nist ogg prc raw s1 s16 s2 s24 s3 s32 s4 s8 sb sf sl sln smp snd sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 u32 u4 u8 ub ul uw vms voc vorbis vox wav wavpcm wve xa
PLAYLIST FORMATS: m3u pls
AUDIO DEVICE DRIVERS: oss ossdsp
EFFECTS: allpass band bandpass bandreject bass bend biquad chorus channels compand contrast dcshift deemph delay dither divide+ downsample earwax echo echos equalizer fade fir firfit+ flanger gain highpass hilbert input# loudness lowpass mcompand noiseprof noisered norm oops output# overdrive pad phaser pitch rate remix repeat reverb reverse riaa silence sinc speed splice stat stats stretch swap synth tempo treble tremolo trim upsample vad vol
* Deprecated effect + Experimental effect # LibSoX-only effect
EFFECT OPTIONS (effopts): effect dependent; see --help-effect
Tags: [Raspberry Pi], [電子工作]
●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)
FWinSdCardImager SDカード イメージ書き込みアプリ、ラズパイの Raspbian OS、Jetson Nanoの Ubuntuの書き込みに便利
ラズパイや Jetson Nano等のワンボードマイコン等への OSイメージの書き込みが簡単にできる
FWinPiFinder ラズベリーパイ IPアドレス発見アプリ。ARPコマンドでラズパイの IPアドレスを探索発見する
Raspberry Piや NVIDIA Jetson Nano等の IPアドレスを MACアドレスの OUI部分を使用して発見する
Raspberry Pi 3系のトラブルであるある第一位の電源トラブル、低電圧警報に関する情報のまとめ
ラズパイ3B系での低電圧警報に関する情報まとめ、コマンドラインやログファイルから低電圧を検知する方法
Raspberry Piで CPUの脆弱性 Spectreと Meltdownの脆弱性をチェックする方法
ラズパイで 2018年初頭に大騒ぎになったスペクターとメルトダウンの CPUの脆弱性をチェックする方法
Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入できる通販ショップ一覧まとめ
ラズパイゼロW ワイヤレスモデルを海外通販でサクッと簡単に個人輸入で入手。技適通過でも国内販売は常に品切れ
Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ
ラズパイ3で安定して使える microSDカードを購入する Teamと SanDiskは絶対に買わない
Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法
ラズパイに専用カメラモジュールを接続して Raspbianで写真の静止画撮影や動画を録画する方法
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も
Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳
ラズパイ公式フォーラムの「The Raspberry Pi 3 Model B Q&A thread」の日本語訳
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
ラズパイ3の GPIO端子の I2C機能を有効にして各種センサーを繋げる方法まとめ
大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう
Raspberry Piの開発環境の構築やタッチパネル付き液晶ディスプレイや各種センサーの使い方まとめ
Raspberry Pi関連はこちらへまとめました
下記以外にも多数のラズパイ関係の記事が有ります。
(I2C制御、GPIO制御、1-Wire制御、シリアル通信、日本語音声合成、日本語音声認識、中国語音声合成、MeCab 形態素解析エンジン、赤外線リモコン制御、秋月 I2C液晶モジュール、KeDei 3.5インチ液晶、HDMI 5インチ液晶、NFCカードリーダ、コマンドライン操作方法等)
Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板
Espressif ESP8266 ESP-12-E NodeMCU V1 ESP12 CP2102
BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)
レーザー彫刻機、カラー液晶の DIYオシロ、Arduinoや Raspberry Pi用の小型カラー液晶
[HOME]
|
[BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c)
2017 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator
http://www.neko.ne.jp/~freewing/amazon_aws/amazon_aws_build_sox_sound_exchange/