Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
6f5211d1
Commit
6f5211d1
authored
Oct 29, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ogg and vorbis build scripts, tests and examples (WIP)
parent
d4dc6a50
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
136 additions
and
33 deletions
+136
-33
README.md
README.md
+7
-0
build.sh
build.sh
+4
-0
build-fdk-aac.sh
wasm/build-scripts/build-fdk-aac.sh
+4
-2
build-lame.sh
wasm/build-scripts/build-lame.sh
+2
-2
build-ogg.sh
wasm/build-scripts/build-ogg.sh
+18
-0
build-vorbis.sh
wasm/build-scripts/build-vorbis.sh
+20
-0
build-wavpack.sh
wasm/build-scripts/build-wavpack.sh
+2
-2
var.sh
wasm/build-scripts/var.sh
+1
-0
vorbis.html
wasm/examples/browser/next/vorbis.html
+42
-0
transcode-x265.js
wasm/tests/next/transcode-x265.js
+0
-27
vorbis.js
wasm/tests/next/vorbis.js
+18
-0
x265.js
wasm/tests/next/x265.js
+18
-0
No files found.
README.md
View file @
6f5211d1
...
@@ -6,6 +6,13 @@ This is the core part of FFmpeg.wasm where we transpile C/C++ code of FFmpeg to
...
@@ -6,6 +6,13 @@ This is the core part of FFmpeg.wasm where we transpile C/C++ code of FFmpeg to
If you have any issues for this repository, please put it here: https://github.com/ffmpegwasm/ffmpeg.wasm/issues
If you have any issues for this repository, please put it here: https://github.com/ffmpegwasm/ffmpeg.wasm/issues
## Setup
```
$ git clone https://github.com/ffmpegwasm/ffmpeg.wasm-core
$ git submodule update --init --recursive
```
## Build
## Build
1.
Use docker (easy way)
1.
Use docker (easy way)
...
...
build.sh
View file @
6f5211d1
...
@@ -20,6 +20,10 @@ $SCRIPT_ROOT/build-wavpack.sh
...
@@ -20,6 +20,10 @@ $SCRIPT_ROOT/build-wavpack.sh
$SCRIPT_ROOT
/build-lame.sh
$SCRIPT_ROOT
/build-lame.sh
# build fdk-aac
# build fdk-aac
$SCRIPT_ROOT
/build-fdk-aac.sh
$SCRIPT_ROOT
/build-fdk-aac.sh
# build ogg
# $SCRIPT_ROOT/build-ogg.sh
# build vorbis
# $SCRIPT_ROOT/build-vorbis.sh
# configure FFmpeg with Emscripten
# configure FFmpeg with Emscripten
$SCRIPT_ROOT
/configure-ffmpeg.sh
$SCRIPT_ROOT
/configure-ffmpeg.sh
# build ffmpeg.wasm core
# build ffmpeg.wasm core
...
...
wasm/build-scripts/build-fdk-aac.sh
View file @
6f5211d1
...
@@ -4,13 +4,15 @@ set -euo pipefail
...
@@ -4,13 +4,15 @@ set -euo pipefail
source
$(
dirname
$0
)
/var.sh
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/fdk-aac
LIB_PATH
=
third_party/fdk-aac
FLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
C
FLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
CONF_FLAGS
=(
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-linux
# use i686 linux
--host
=
i686-linux
# use i686 linux
--disable-shared
# disable shared library
--disable-shared
# disable shared library
)
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
emconfigure ./autogen.sh
&&
emconfigure ./configure
"
${
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
clean
emmake make
-C
$LIB_PATH
install
-j
emmake make
-C
$LIB_PATH
install
-j
wasm/build-scripts/build-lame.sh
View file @
6f5211d1
...
@@ -4,7 +4,7 @@ set -euo pipefail
...
@@ -4,7 +4,7 @@ set -euo pipefail
source
$(
dirname
$0
)
/var.sh
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/lame
LIB_PATH
=
third_party/lame
FLAGS
=
"-c
-s USE_PTHREADS=1
$OPTIM_FLAGS
"
CFLAGS
=
"
-s USE_PTHREADS=1
$OPTIM_FLAGS
"
CONF_FLAGS
=(
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-linux
# use i686 linux
--host
=
i686-linux
# use i686 linux
...
@@ -13,6 +13,6 @@ CONF_FLAGS=(
...
@@ -13,6 +13,6 @@ CONF_FLAGS=(
--disable-analyzer-hooks
# exclude analyzer hooks
--disable-analyzer-hooks
# exclude analyzer hooks
)
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
emconfigure ./configure
"
${
CONF_FLAGS
[@]
}
"
)
(
cd
$LIB_PATH
&&
CFLAGS
=
$CFLAGS
emconfigure ./configure
"
${
CONF_FLAGS
[@]
}
"
)
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
install
-j
emmake make
-C
$LIB_PATH
install
-j
wasm/build-scripts/build-ogg.sh
0 → 100755
View file @
6f5211d1
#!/bin/bash
set
-euo
pipefail
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/Ogg
CFLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-linux
# use i686 linux
--disable-shared
# disable shared library
)
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
wasm/build-scripts/build-vorbis.sh
0 → 100755
View file @
6f5211d1
#!/bin/bash
set
-euo
pipefail
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/vorbis
CFLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
-I
$BUILD_DIR
/include -Qunused-arguments"
LDFLAGS
=
"-L
$BUILD_DIR
/lib"
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-linux
# use i686 linux
--disable-shared
# disable shared library
--disable-oggtest
# disable tests
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
\
emconfigure ./autogen.sh
&&
\
CFLAGS
=
$CFLAGS
LDFLAGS
=
$LDFLAGS
emconfigure ./configure
"
${
CONF_FLAGS
[@]
}
"
)
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
install
-j
wasm/build-scripts/build-wavpack.sh
View file @
6f5211d1
...
@@ -4,7 +4,7 @@ set -euo pipefail
...
@@ -4,7 +4,7 @@ set -euo pipefail
source
$(
dirname
$0
)
/var.sh
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/WavPack
LIB_PATH
=
third_party/WavPack
FLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
C
FLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
CONF_FLAGS
=(
CONF_FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
x86-linux-gnu
# use x86 linux as host
--host
=
x86-linux-gnu
# use x86 linux as host
...
@@ -17,6 +17,6 @@ CONF_FLAGS=(
...
@@ -17,6 +17,6 @@ CONF_FLAGS=(
--disable-shared
# enable building static library
--disable-shared
# enable building static library
)
)
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
echo
"CONF_FLAGS=
${
CONF_FLAGS
[@]
}
"
(
cd
$LIB_PATH
&&
CFLAGS
=
$FLAGS
emconfigure ./autogen.sh
"
${
CONF_FLAGS
[@]
}
"
)
(
cd
$LIB_PATH
&&
CFLAGS
=
$
C
FLAGS
emconfigure ./autogen.sh
"
${
CONF_FLAGS
[@]
}
"
)
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
clean
emmake make
-C
$LIB_PATH
install
-j
emmake make
-C
$LIB_PATH
install
-j
wasm/build-scripts/var.sh
View file @
6f5211d1
...
@@ -48,6 +48,7 @@ FFMPEG_CONFIG_FLAGS_BASE=(
...
@@ -48,6 +48,7 @@ FFMPEG_CONFIG_FLAGS_BASE=(
--enable-libwavpack
# enable libwavpack
--enable-libwavpack
# enable libwavpack
--enable-libmp3lame
# enable libmp3lame
--enable-libmp3lame
# enable libmp3lame
--enable-libfdk-aac
# enable libfdk-aac
--enable-libfdk-aac
# enable libfdk-aac
# --enable-libvorbis # enable libvorbis
--disable-debug
# disable debug info, required by closure
--disable-debug
# disable debug info, required by closure
--disable-runtime-cpudetect
# disable runtime cpu detect
--disable-runtime-cpudetect
# disable runtime cpu detect
--disable-autodetect
# disable external libraries auto detect
--disable-autodetect
# disable external libraries auto detect
...
...
wasm/examples/browser/next/vorbis.html
0 → 100644
View file @
6f5211d1
<html>
<head>
<style>
html
,
body
{
margin
:
0
;
width
:
100%
;
height
:
100%
}
body
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
}
</style>
</head>
<body>
<h3>
Upload a wav file to transcode to aac and play!
</h3>
<audio
id=
"output-audio"
controls
></audio><br/>
<input
type=
"file"
id=
"uploader"
>
<p
id=
"message"
>
Upload a wav file
</p>
<script
type=
"text/javascript"
src=
"./js/utils.js"
></script>
<script
type=
"text/javascript"
>
const
message
=
document
.
getElementById
(
'message'
);
const
transcode
=
async
({
target
:
{
files
}
})
=>
{
const
IN_FILE_NAME
=
'audio.wav'
;
const
OUT_FILE_NAME
=
'audio.ogg'
;
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:a'
,
'libvorbis'
,
OUT_FILE_NAME
];
message
.
innerHTML
=
'Writing file to MEMFS'
;
const
data
=
new
Uint8Array
(
await
readFromBlobOrFile
(
files
[
0
]));
const
now
=
Date
.
now
();
console
.
time
(
`[
${
now
}
]
${
files
[
0
].
name
}
execution time`
);
message
.
innerHTML
=
'Start to transcode'
;
const
{
file
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
data
,
args
,
OUT_FILE_NAME
)
const
audio
=
document
.
getElementById
(
'output-audio'
);
audio
.
src
=
URL
.
createObjectURL
(
new
Blob
([
file
.
buffer
],
{
type
:
'audio/ogg'
}));
console
.
timeEnd
(
`[
${
now
}
]
${
files
[
0
].
name
}
execution time`
);
};
document
.
getElementById
(
'uploader'
).
addEventListener
(
'change'
,
transcode
);
</script>
<script
type=
"text/javascript"
src=
"../../dist/ffmpeg-core.js"
></script>
</body>
</html>
wasm/tests/next/transcode-x265.js
deleted
100644 → 0
View file @
d4dc6a50
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
aviFilePath
=
path
.
join
(
__dirname
,
'data'
,
'video-1s.avi'
);
const
MP4_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(
async
()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
aviFilePath
));
});
test
(
'transcode avi to x265 mp4'
,
async
()
=>
{
const
Core
=
await
runFFmpeg
(
'video.avi'
,
aviData
,
[
'-i'
,
'video.avi'
,
'-c:v'
,
'libx265'
,
'video.mp4'
]);
const
fileSize
=
Core
.
FS
.
readFile
(
'video.mp4'
).
length
;
Core
.
FS
.
unlink
(
'video.mp4'
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
},
TIMEOUT
);
test
(
'transcode avi to x265 mp4 twice'
,
async
()
=>
{
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
const
Core
=
await
runFFmpeg
(
'video.avi'
,
aviData
,
[
'-i'
,
'video.avi'
,
'-c:v'
,
'libx265'
,
'video.mp4'
]);
const
fileSize
=
Core
.
FS
.
readFile
(
'video.mp4'
).
length
;
Core
.
FS
.
unlink
(
'video.mp4'
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
}
},
TIMEOUT
);
wasm/tests/next/vorbis.js
0 → 100644
View file @
6f5211d1
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.ogg'
;
const
OGG_SIZE
=
4239
;
let
wavData
=
null
;
beforeAll
(()
=>
{
wavData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'convert wav to aac'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:a'
,
'libvorbis'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
wavData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
OGG_SIZE
);
},
TIMEOUT
);
wasm/tests/next/x265.js
0 → 100644
View file @
6f5211d1
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
}
=
require
(
'./utils'
);
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
MP4_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to x265 mp4'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libx265'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
MP4_SIZE
);
},
TIMEOUT
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment