Commit d30ad812 authored by Jerome Wu's avatar Jerome Wu

Add opus build scripts and tests

parent 29c72e41
......@@ -28,6 +28,8 @@ $SCRIPT_ROOT/build-ogg.sh
$SCRIPT_ROOT/build-vorbis.sh
# build theora
$SCRIPT_ROOT/build-theora.sh
# build opus
$SCRIPT_ROOT/build-opus.sh
# build freetype2
$SCRIPT_ROOT/build-freetype2.sh
# build aom (disabled as it is extremely slow)
......
......@@ -9,7 +9,7 @@ FLAGS=(
-I. -I./fftools -I$BUILD_DIR/include
-Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -L$BUILD_DIR/lib
-Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lx265 -lvpx -lwavpack -lmp3lame -lfdk-aac -lvorbis -lvorbisenc -lvorbisfile -logg -ltheora -ltheoraenc -ltheoradec -lz -lfreetype -pthread
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lx265 -lvpx -lwavpack -lmp3lame -lfdk-aac -lvorbis -lvorbisenc -lvorbisfile -logg -ltheora -ltheoraenc -ltheoradec -lz -lfreetype -lopus -pthread
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
-o wasm/dist/ffmpeg-core.js
-s USE_SDL=2 # use SDL2
......
#!/bin/bash
set -euo pipefail
source $(dirname $0)/var.sh
LIB_PATH=third_party/opus
CFLAGS="-s USE_PTHREADS=1 $OPTIM_FLAGS"
CONF_FLAGS=(
--prefix=$BUILD_DIR # install library in a build directory for FFmpeg to include
--host=i686-gnu # use i686 linux
--enable-shared=no # not to build shared library
--disable-asm # not to use asm
--disable-rtcd # not to detect cpu capabilities
--disable-doc # not to build docs
--disable-extra-programs # not to build demo and tests
--disable-stack-protector
)
echo "CONF_FLAGS=${CONF_FLAGS[@]}"
(cd $LIB_PATH && \
emconfigure ./autogen.sh && \
CFLAGS=$CFLAGS emconfigure ./configure "${CONF_FLAGS[@]}")
emmake make -C $LIB_PATH clean
emmake make -C $LIB_PATH install -j
......@@ -17,6 +17,7 @@ FLAGS=(
--enable-libtheora # enable libtheora
--enable-libvorbis # enable libvorbis
--enable-libfreetype # enable freetype
--enable-libopus # enable opus
# --enable-libaom # enable libaom
)
echo "FFMPEG_CONFIG_FLAGS=${FLAGS[@]}"
......
const fs = require('fs');
const path = require('path');
const { TIMEOUT } = require('./config');
const { runFFmpeg } = require('./utils');
const IN_FILE_NAME = 'audio-1s.wav';
const OUT_FILE_NAME = 'audio.opus';
const FILE_SIZE = 12793;
let wavData = null;
beforeAll(() => {
wavData = Uint8Array.from(fs.readFileSync(path.join(__dirname, 'data', IN_FILE_NAME)));
});
test('convert wav to mp3', async () => {
const args = ['-i', IN_FILE_NAME, '-c:a', 'libopus', OUT_FILE_NAME];
const { fileSize } = await runFFmpeg(IN_FILE_NAME, wavData, args, OUT_FILE_NAME);
expect(fileSize).toBe(FILE_SIZE);
}, TIMEOUT);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment