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
5f8c868b
Commit
5f8c868b
authored
Sep 02, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add x264 and fix ffmpeg.js
parent
487f38a5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
17 deletions
+53
-17
.gitignore
.gitignore
+1
-0
.gitmodules
.gitmodules
+3
-0
build.sh
build.sh
+8
-5
x264
third_party/x264
+1
-0
build-ffmpeg.sh
wasm/build-scripts/build-ffmpeg.sh
+6
-4
build-x264.sh
wasm/build-scripts/build-x264.sh
+19
-0
configure.sh
wasm/build-scripts/configure.sh
+5
-2
ffmpeg.js
wasm/ffmpeg.js
+10
-6
No files found.
.gitignore
View file @
5f8c868b
...
...
@@ -39,3 +39,4 @@
/tools/python/__pycache__/
/wasm/cache
/wasm/dist
/build
.gitmodules
View file @
5f8c868b
[submodule "testdata"]
path = testdata
url = https://github.com/ffmpegwasm/testdata.git
[submodule "third_party/x264"]
path = third_party/x264
url = https://code.videolan.org/videolan/x264.git
build.sh
View file @
5f8c868b
...
...
@@ -2,13 +2,16 @@
set
-eo
pipefail
ROOT
=
$(
dirname
$0
)
ROOT
=
$PWD
BUILD_DIR
=
$ROOT
/build
# verify Emscripten version
emcc
-v
# build x264
$ROOT
/wasm/build-scripts/build-x264.sh
$ROOT
/third_party/x264
$BUILD_DIR
# configure FFmpeg with Emscripten
$ROOT
/wasm/build-scripts/configure.sh
# build dependencies
$ROOT
/wasm/build-scripts/configure.sh
$BUILD_DIR
#
#
build dependencies
$ROOT
/wasm/build-scripts/make.sh
# build ffmpeg.wasm
$ROOT
/wasm/build-scripts/build-ffmpeg.sh
#
#
build ffmpeg.wasm
$ROOT
/wasm/build-scripts/build-ffmpeg.sh
$BUILD_DIR
x264
@
db0d4177
Subproject commit db0d417728460c647ed4a847222a535b00d3dbcb
wasm/build-scripts/build-ffmpeg.sh
View file @
5f8c868b
...
...
@@ -2,13 +2,15 @@
set
-eo
pipefail
BUILD_DIR
=
$1
mkdir
-p
wasm/dist
ARGS
=(
-I
.
-I
./fftools
-Llibavcodec
-Llibavdevice
-Llibavfilter
-Llibavformat
-Llibavresample
-Llibavutil
-Llibpostproc
-Llibswscale
-Llibswresample
-I
.
-I
./fftools
-I
$BUILD_DIR
/include
-Llibavcodec
-Llibavdevice
-Llibavfilter
-Llibavformat
-Llibavresample
-Llibavutil
-Llibpostproc
-Llibswscale
-Llibswresample
-L
$BUILD_DIR
/lib
-Qunused-arguments
-o
wasm/dist/ffmpeg-core.js fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
-lavdevice
-lavfilter
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
-l
m
-lavdevice
-lavfilter
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
-l
postproc
-lm
-lx264
-pthread
-O3
# Optimize code with performance first
-s
USE_SDL
=
2
# use SDL2
-s
USE_PTHREADS
=
1
# enable pthreads support
...
...
@@ -16,6 +18,6 @@ ARGS=(
-s
INVOKE_RUN
=
0
# not to run the main() in the beginning
-s
EXPORTED_FUNCTIONS
=
"[_main, _proxy_main]"
# export main and proxy_main funcs
-s
EXTRA_EXPORTED_RUNTIME_METHODS
=
"[FS, cwrap, setValue, writeAsciiToMemory]"
# export preamble funcs
-s
INITIAL_MEMORY
=
33554432
# 33554432 bytes = 32
MB
-s
INITIAL_MEMORY
=
268435456
# 268435456 bytes = 256
MB
)
emcc
"
${
ARGS
[@]
}
"
wasm/build-scripts/build-x264.sh
0 → 100755
View file @
5f8c868b
#!/bin/bash -x
set
-eo
pipefail
ROOT
=
$1
BUILD_DIR
=
$2
cd
$ROOT
ARGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-gnu
# use i686 linux
--enable-static
# enable building static library
--disable-cli
# disable cli tools
--disable-asm
# disable asm optimization
--extra-cflags
=
"-s USE_PTHREADS=1"
# pass this flags for using pthreads
)
emconfigure ./configure
"
${
ARGS
[@]
}
"
emmake make install-lib-static
-j4
cd
-
wasm/build-scripts/configure.sh
View file @
5f8c868b
...
...
@@ -2,8 +2,9 @@
set
-eo
pipefail
CFLAGS
=
"-s USE_PTHREADS -O3"
LDFLAGS
=
"
$CFLAGS
-s INITIAL_MEMORY=33554432"
# 33554432 bytes = 32 MB
BUILD_DIR
=
$1
CFLAGS
=
"-s USE_PTHREADS -O3 -I
$BUILD_DIR
/include"
LDFLAGS
=
"
$CFLAGS
-L
$BUILD_DIR
/lib -s INITIAL_MEMORY=33554432"
# 33554432 bytes = 32 MB
ARGS
=(
--target-os
=
none
# use none to prevent any os specific configurations
--arch
=
x86_32
# use x86_32 to achieve minimal architectural optimization
...
...
@@ -13,6 +14,8 @@ ARGS=(
--disable-stripping
# disable stripping
--disable-programs
# disable programs build (incl. ffplay, ffprobe & ffmpeg)
--disable-doc
# disable doc
--enable-gpl
# required by x264
--enable-libx264
# enable x264
--extra-cflags
=
"
$CFLAGS
"
--extra-cxxflags
=
"
$CFLAGS
"
--extra-ldflags
=
"
$LDFLAGS
"
...
...
wasm/ffmpeg.js
View file @
5f8c868b
...
...
@@ -6,7 +6,7 @@ Module.onRuntimeInitialized = () => {
Module
.
FS
.
writeFile
(
'flame.avi'
,
data
);
const
ffmpeg
=
Module
.
cwrap
(
'proxy_main'
,
'number'
,
[
'number'
,
'number'
]);
const
args
=
[
'ffmpeg'
,
'-hide_banner'
,
'-i'
,
'flame.avi'
,
'flame.mp4'
];
const
args
=
[
'ffmpeg'
,
'-hide_banner'
,
'-
report'
,
'-
i'
,
'flame.avi'
,
'flame.mp4'
];
const
argsPtr
=
Module
.
_malloc
(
args
.
length
*
Uint32Array
.
BYTES_PER_ELEMENT
);
args
.
forEach
((
s
,
idx
)
=>
{
const
buf
=
Module
.
_malloc
(
s
.
length
+
1
);
...
...
@@ -17,13 +17,17 @@ Module.onRuntimeInitialized = () => {
/*
* The execution of ffmpeg is not synchronized,
* so we need to
set a timer to wait for it completes
.
* so we need to
parse the log file to check if completed
.
*/
const
timer
=
setInterval
(()
=>
{
if
(
Module
.
FS
.
readdir
(
'.'
).
find
(
f
=>
f
===
'flame.mp4'
)
!==
-
1
)
{
clearInterval
(
timer
);
const
output
=
Module
.
FS
.
readFile
(
'flame.mp4'
);
fs
.
writeFileSync
(
'flame.mp4'
,
output
);
const
logFileName
=
Module
.
FS
.
readdir
(
'.'
).
find
(
name
=>
name
.
endsWith
(
'.log'
));
if
(
typeof
logFileName
!==
'undefined'
)
{
const
log
=
String
.
fromCharCode
.
apply
(
null
,
Module
.
FS
.
readFile
(
logFileName
));
if
(
log
.
includes
(
"frames successfully decoded"
))
{
clearInterval
(
timer
);
const
output
=
Module
.
FS
.
readFile
(
'flame.mp4'
);
fs
.
writeFileSync
(
'flame.mp4'
,
output
);
}
}
},
500
);
};
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