使用对 AWS lambda 的 lame 和 flac 支持构建静态 sox
build static sox with lame and flac support for AWS lambda
我正在尝试在 AWS lambda 函数中使用 sox 将 FLAC 文件转换为 MP3,但我似乎无法构建支持 FLAC 的 sox 版本。
我发现 this 我一直在使用的很好的解决方案,但它不支持 FLAC。
我在网上搜索了替代方案,但似乎没有任何效果。我还读到,在某个阶段,FLAC 支持丢失了,但应该已经修复了。
我仍在寻找答案,但如有任何帮助,我们将不胜感激。
您需要将 libvorbis 和 flac 库添加到您的静态构建中,并标记 sox 构建以包含它们。我已经根据您的示例问题对脚本进行了更改,以向您展示这是如何完成的。
sudo yum update
sudo yum install gcc44 gcc-c++ libgcc44 cmake –y
# now grab sox and its dependencies
mkdir -p deps
mkdir -p deps/unpacked
mkdir -p deps/built
mkdir -p deps/built/libmad
mkdir -p deps/built/sox
mkdir -p deps/built/lame
mkdir -p deps/built/libvorbis
mkdir -p deps/built/flac
wget -O deps/sox-14.4.2.tar.bz2 "http://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2F&ts=1416316415&use_mirror=heanet"
wget -O deps/libmad-0.15.1b.tar.gz "http://downloads.sourceforge.net/project/mad/libmad/0.15.1b/libmad-0.15.1b.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmad%2Ffiles%2Flibmad%2F0.15.1b%2F&ts=1416316482&use_mirror=heanet"
wget -O deps/lame-3.99.5.tar.gz "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1416316457&use_mirror=kent"
wget -O deps/libvorbis-1.3.5.tar.xz "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz"
wget -O deps/flac-1.3.2.tar.xz "https://superb-dca2.dl.sourceforge.net/project/flac/flac-src/flac-1.3.2.tar.xz"
# unpack the dependencie
pushd deps/unpacked
tar xvfp ../sox-14.4.2.tar.bz2
tar xvfp ../libmad-0.15.1b.tar.gz
tar xvfp ../lame-3.99.5.tar.gz
tar xvfp ../libvorbis-1.3.5.tar.xz
tar xvfp ../flac-1.3.2.tar.xz
popd
# build libmad, statically
pushd deps/unpacked/libmad-0.15.1b
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/libmad)
# Patch makefile to remove -fforce-mem
sed s/-fforce-mem//g < Makefile > Makefile.patched
cp Makefile.patched Makefile
make
make install
popd
# build lame, statically
pushd deps/unpacked/lame-3.99.5
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/lame)
make
make install
popd
# build libvorbis, statically
pushd deps/unpacked/libvorbis-1.3.5
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/libvorbis)
make
make install
popd
# build flac, statically
pushd deps/unpacked/flac-1.3.2
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/flac)
make
make install
popd
# build sox, statically
pushd deps/unpacked/sox-14.4.2
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/sox) \
LDFLAGS="-L$(realpath ../../built/libmad/lib) -L$(realpath ../../built/lame/lib) -L$(realpath ../../built/libvorbis/lib) -L$(realpath ../../built/flac/lib)" \
CPPFLAGS="-I$(realpath ../../built/libmad/include) -I$(realpath ../../built/lame/include) -I$(realpath ../../built/libvorbis/include) -I$(realpath ../../built/flac/include)" \
--with-mad --with-lame --with-libvorbis --with-flac --without-oggvorbis --without-oss --without-sndfile --without-gomp
make -s
make install
popd
cp deps/built/sox/bin/sox .
rm -rf deps/built
rm -rf deps/unpacked
我正在尝试在 AWS lambda 函数中使用 sox 将 FLAC 文件转换为 MP3,但我似乎无法构建支持 FLAC 的 sox 版本。
我发现 this 我一直在使用的很好的解决方案,但它不支持 FLAC。
我在网上搜索了替代方案,但似乎没有任何效果。我还读到,在某个阶段,FLAC 支持丢失了,但应该已经修复了。 我仍在寻找答案,但如有任何帮助,我们将不胜感激。
您需要将 libvorbis 和 flac 库添加到您的静态构建中,并标记 sox 构建以包含它们。我已经根据您的示例问题对脚本进行了更改,以向您展示这是如何完成的。
sudo yum update
sudo yum install gcc44 gcc-c++ libgcc44 cmake –y
# now grab sox and its dependencies
mkdir -p deps
mkdir -p deps/unpacked
mkdir -p deps/built
mkdir -p deps/built/libmad
mkdir -p deps/built/sox
mkdir -p deps/built/lame
mkdir -p deps/built/libvorbis
mkdir -p deps/built/flac
wget -O deps/sox-14.4.2.tar.bz2 "http://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsox%2Ffiles%2Fsox%2F14.4.2%2F&ts=1416316415&use_mirror=heanet"
wget -O deps/libmad-0.15.1b.tar.gz "http://downloads.sourceforge.net/project/mad/libmad/0.15.1b/libmad-0.15.1b.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmad%2Ffiles%2Flibmad%2F0.15.1b%2F&ts=1416316482&use_mirror=heanet"
wget -O deps/lame-3.99.5.tar.gz "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1416316457&use_mirror=kent"
wget -O deps/libvorbis-1.3.5.tar.xz "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz"
wget -O deps/flac-1.3.2.tar.xz "https://superb-dca2.dl.sourceforge.net/project/flac/flac-src/flac-1.3.2.tar.xz"
# unpack the dependencie
pushd deps/unpacked
tar xvfp ../sox-14.4.2.tar.bz2
tar xvfp ../libmad-0.15.1b.tar.gz
tar xvfp ../lame-3.99.5.tar.gz
tar xvfp ../libvorbis-1.3.5.tar.xz
tar xvfp ../flac-1.3.2.tar.xz
popd
# build libmad, statically
pushd deps/unpacked/libmad-0.15.1b
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/libmad)
# Patch makefile to remove -fforce-mem
sed s/-fforce-mem//g < Makefile > Makefile.patched
cp Makefile.patched Makefile
make
make install
popd
# build lame, statically
pushd deps/unpacked/lame-3.99.5
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/lame)
make
make install
popd
# build libvorbis, statically
pushd deps/unpacked/libvorbis-1.3.5
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/libvorbis)
make
make install
popd
# build flac, statically
pushd deps/unpacked/flac-1.3.2
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/flac)
make
make install
popd
# build sox, statically
pushd deps/unpacked/sox-14.4.2
./configure --disable-shared --enable-static --prefix=$(realpath ../../built/sox) \
LDFLAGS="-L$(realpath ../../built/libmad/lib) -L$(realpath ../../built/lame/lib) -L$(realpath ../../built/libvorbis/lib) -L$(realpath ../../built/flac/lib)" \
CPPFLAGS="-I$(realpath ../../built/libmad/include) -I$(realpath ../../built/lame/include) -I$(realpath ../../built/libvorbis/include) -I$(realpath ../../built/flac/include)" \
--with-mad --with-lame --with-libvorbis --with-flac --without-oggvorbis --without-oss --without-sndfile --without-gomp
make -s
make install
popd
cp deps/built/sox/bin/sox .
rm -rf deps/built
rm -rf deps/unpacked