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
2811f758
Commit
2811f758
authored
Nov 01, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add aom
parent
4e4b74a6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
147 additions
and
11 deletions
+147
-11
.gitmodules
.gitmodules
+3
-0
build.sh
build.sh
+2
-0
aom
third_party/aom
+1
-0
build-aom.sh
wasm/build-scripts/build-aom.sh
+36
-0
build-ffmpeg.mp4-scale.sh
wasm/build-scripts/build-ffmpeg.mp4-scale.sh
+28
-0
build-ffmpeg.sh
wasm/build-scripts/build-ffmpeg.sh
+1
-1
configure-ffmpeg.mp4-scale.sh
wasm/build-scripts/configure-ffmpeg.mp4-scale.sh
+2
-0
configure-ffmpeg.sh
wasm/build-scripts/configure-ffmpeg.sh
+11
-0
var.sh
wasm/build-scripts/var.sh
+0
-10
aom.html
wasm/examples/browser/aom.html
+42
-0
aom.test.js
wasm/tests/aom.test.js
+21
-0
No files found.
.gitmodules
View file @
2811f758
...
...
@@ -28,3 +28,6 @@
[submodule "third_party/theora"]
path = third_party/theora
url = https://github.com/ffmpegwasm/theora
[submodule "third_party/aom"]
path = third_party/aom
url = https://github.com/ffmpegwasm/aom
build.sh
View file @
2811f758
...
...
@@ -26,6 +26,8 @@ $SCRIPT_ROOT/build-ogg.sh
$SCRIPT_ROOT
/build-vorbis.sh
# build theora
$SCRIPT_ROOT
/build-theora.sh
# build aom
$SCRIPT_ROOT
/build-aom.sh
# configure FFmpeg with Emscripten
$SCRIPT_ROOT
/configure-ffmpeg.sh
# build ffmpeg.wasm core
...
...
aom
@
bb35ba91
Subproject commit bb35ba9148543f22ba7d8642e4fbd29ae301f5dc
wasm/build-scripts/build-aom.sh
0 → 100755
View file @
2811f758
#!/bin/bash
set
-euo
pipefail
source
$(
dirname
$0
)
/var.sh
LIB_PATH
=
third_party/aom
CMBUILD_DIR
=
cmbuild
CFLAGS
=
"-s USE_PTHREADS=1
$OPTIM_FLAGS
"
CM_FLAGS
=(
-DCMAKE_INSTALL_PREFIX
=
$BUILD_DIR
# assign lib and include install path
-DCMAKE_TOOLCHAIN_FILE
=
$TOOLCHAIN_FILE
# use emscripten toolchain file
-DBUILD_SHARED_LIBS
=
0
# disable shared library build
-DAOM_TARGET_CPU
=
generic
# use generic cpu
-DENABLE_DOCS
=
0
# disable docs
-DENABLE_TESTS
=
0
# disable tests
-DENABLE_EXAMPLES
=
0
# disable examples
-DENABLE_TOOLS
=
0
# disable tools
-DCONFIG_RUNTIME_CPU_DETECT
=
0
# disable cpu detect
-DCONFIG_WEBM_IO
=
0
# disable libwebm support
)
echo
"CM_FLAGS=
${
CM_FLAGS
[@]
}
"
cd
$LIB_PATH
rm
-rf
$CMBUILD_DIR
mkdir
-p
$CMBUILD_DIR
cd
$CMBUILD_DIR
emmake cmake ..
\
-DAOM_EXTRA_C_FLAGS
=
"
$CFLAGS
"
\
-DAOM_EXTRA_CXX_FLAGS
=
"
$CFLAGS
"
\
${
CM_FLAGS
[@]
}
emmake make clean
emmake make
install
-j
cd
$ROOT_DIR
wasm/build-scripts/build-ffmpeg.mp4-scale.sh
0 → 100755
View file @
2811f758
#!/bin/bash
set
-eo
pipefail
source
$(
dirname
$0
)
/var.sh
mkdir
-p
wasm/dist
emmake make
-j
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
-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
-s
USE_PTHREADS
=
1
# enable pthreads support
-s
PROXY_TO_PTHREAD
=
1
# detach main() from browser/UI main thread
-s
INVOKE_RUN
=
0
# not to run the main() in the beginning
-s
EXIT_RUNTIME
=
1
# exit runtime after execution
-s
MODULARIZE
=
1
# use modularized version to be more flexible
-s
EXPORT_NAME
=
"createFFmpegCore"
# assign export name for browser
-s
EXPORTED_FUNCTIONS
=
"[_main, _proxy_main]"
# export main and proxy_main funcs
-s
EXTRA_EXPORTED_RUNTIME_METHODS
=
"[FS, cwrap, ccall, setValue, writeAsciiToMemory]"
# export preamble funcs
-s
INITIAL_MEMORY
=
1073741824
# 1073741824 bytes = 1 GB
$OPTIM_FLAGS
)
echo
"FFMPEG_EM_FLAGS=
${
FLAGS
[@]
}
"
emcc
"
${
FLAGS
[@]
}
"
wasm/build-scripts/build-ffmpeg.sh
View file @
2811f758
...
...
@@ -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
-pthread
-lavdevice
-lavfilter
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
-lpostproc
-lm
-lx264
-lx265
-lvpx
-lwavpack
-lmp3lame
-lfdk-aac
-lvorbis
-lvorbisenc
-lvorbisfile
-logg
-ltheora
-ltheoraenc
-ltheoradec
-
laom
-
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
...
...
wasm/build-scripts/configure-ffmpeg.mp4-scale.sh
View file @
2811f758
...
...
@@ -6,6 +6,8 @@ source $(dirname $0)/var.sh
FLAGS
=(
"
${
FFMPEG_CONFIG_FLAGS_BASE
[@]
}
"
--disable-all
--enable-gpl
# required by x264
--enable-libx264
# enable x264
--enable-avcodec
--enable-avformat
--enable-avfilter
...
...
wasm/build-scripts/configure-ffmpeg.sh
View file @
2811f758
...
...
@@ -5,6 +5,17 @@ source $(dirname $0)/var.sh
FLAGS
=(
"
${
FFMPEG_CONFIG_FLAGS_BASE
[@]
}
"
--enable-gpl
# required by x264
--enable-nonfree
# required by fdk-aac
--enable-libx264
# enable x264
--enable-libx265
# enable x265
--enable-libvpx
# enable libvpx / webm
--enable-libwavpack
# enable libwavpack
--enable-libmp3lame
# enable libmp3lame
--enable-libfdk-aac
# enable libfdk-aac
--enable-libtheora
# enable libtheora
--enable-libvorbis
# enable libvorbis
--enable-libaom
# enable libaom
)
echo
"FFMPEG_CONFIG_FLAGS=
${
FLAGS
[@]
}
"
emconfigure ./configure
"
${
FLAGS
[@]
}
"
wasm/build-scripts/var.sh
View file @
2811f758
...
...
@@ -44,16 +44,6 @@ FFMPEG_CONFIG_FLAGS_BASE=(
--disable-stripping
# disable stripping
--disable-programs
# disable programs build (incl. ffplay, ffprobe & ffmpeg)
--disable-doc
# disable doc
--enable-gpl
# required by x264
--enable-nonfree
# required by fdk-aac
--enable-libx264
# enable x264
--enable-libx265
# enable x265
--enable-libvpx
# enable libvpx / webm
--enable-libwavpack
# enable libwavpack
--enable-libmp3lame
# enable libmp3lame
--enable-libfdk-aac
# enable libfdk-aac
--enable-libtheora
# enable libtheora
--enable-libvorbis
# enable libvorbis
--disable-debug
# disable debug info, required by closure
--disable-runtime-cpudetect
# disable runtime cpu detect
--disable-autodetect
# disable external libraries auto detect
...
...
wasm/examples/browser/aom.html
0 → 100644
View file @
2811f758
<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 video to transcode to av1 and play!
</h3>
<video
id=
"output-video"
controls
></video><br/>
<input
type=
"file"
id=
"uploader"
>
<p
id=
"message"
>
Upload a video
</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
=
'video.avi'
;
const
OUT_FILE_NAME
=
'video.mkv'
;
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libaom-av1'
,
'-crf'
,
'48'
,
'-b:v'
,
'0'
,
'-strict'
,
'experimental'
,
'-tiles'
,
'2x2'
,
'-row-mt'
,
'1'
,
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
video
=
document
.
getElementById
(
'output-video'
);
video
.
src
=
URL
.
createObjectURL
(
new
Blob
([
file
.
buffer
],
{
type
:
'video/mp4'
}));
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/aom.test.js
0 → 100644
View file @
2811f758
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.mkv'
;
const
FILE_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
/*
* Cannot complete this test as transcoding is extremely slow.
*/
test
.
skip
(
'transcode avi to av1'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
'-c:v'
,
'libaom-av1'
,
'-crf'
,
'48'
,
'-b:v'
,
'0'
,
'-strict'
,
'experimental'
,
'-tiles'
,
'2x2'
,
'-row-mt'
,
'1'
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
);
expect
(
fileSize
).
toBe
(
FILE_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