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
d712e15d
Commit
d712e15d
authored
Jul 20, 2021
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to emscripten v2.0.24
parent
09ebfee7
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
82 deletions
+29
-82
build-with-docker.sh
build-with-docker.sh
+1
-1
build-ffmpeg.sh
wasm/build-scripts/build-ffmpeg.sh
+3
-5
post.js
wasm/src/post.js
+0
-1
pre.js
wasm/src/pre.js
+8
-0
exit.test.js
wasm/tests/exit.test.js
+0
-21
multiple-round.test.js
wasm/tests/multiple-round.test.js
+0
-35
transcode-base.js
wasm/tests/transcode-base.js
+3
-6
transcode-mt.test.js
wasm/tests/transcode-mt.test.js
+1
-0
transcode-st.test.js
wasm/tests/transcode-st.test.js
+1
-0
transcode.js
wasm/tests/transcode.js
+2
-0
index.js
wasm/tests/utils/mt/index.js
+10
-13
No files found.
build-with-docker.sh
View file @
d712e15d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
set
-euo
pipefail
set
-euo
pipefail
EM_VERSION
=
2.0.
8
EM_VERSION
=
2.0.
24
docker pull emscripten/emsdk:
$EM_VERSION
docker pull emscripten/emsdk:
$EM_VERSION
docker run
\
docker run
\
...
...
wasm/build-scripts/build-ffmpeg.sh
View file @
d712e15d
...
@@ -5,7 +5,6 @@ source $(dirname $0)/var.sh
...
@@ -5,7 +5,6 @@ source $(dirname $0)/var.sh
if
[[
"
$FFMPEG_ST
"
!=
"yes"
]]
;
then
if
[[
"
$FFMPEG_ST
"
!=
"yes"
]]
;
then
mkdir
-p
wasm/packages/core/dist
mkdir
-p
wasm/packages/core/dist
EXPORTED_FUNCTIONS
=
"[_main, _proxy_main]"
EXTRA_FLAGS
=(
EXTRA_FLAGS
=(
-pthread
-pthread
-s
USE_PTHREADS
=
1
# enable pthreads support
-s
USE_PTHREADS
=
1
# enable pthreads support
...
@@ -14,7 +13,6 @@ if [[ "$FFMPEG_ST" != "yes" ]]; then
...
@@ -14,7 +13,6 @@ if [[ "$FFMPEG_ST" != "yes" ]]; then
)
)
else
else
mkdir
-p
wasm/packages/core-st/dist
mkdir
-p
wasm/packages/core-st/dist
EXPORTED_FUNCTIONS
=
"[_main]"
EXTRA_FLAGS
=(
EXTRA_FLAGS
=(
-o
wasm/packages/core-st/dist/ffmpeg-core.js
-o
wasm/packages/core-st/dist/ffmpeg-core.js
)
)
...
@@ -30,11 +28,11 @@ FLAGS=(
...
@@ -30,11 +28,11 @@ FLAGS=(
-s
EXIT_RUNTIME
=
1
# exit runtime after execution
-s
EXIT_RUNTIME
=
1
# exit runtime after execution
-s
MODULARIZE
=
1
# use modularized version to be more flexible
-s
MODULARIZE
=
1
# use modularized version to be more flexible
-s
EXPORT_NAME
=
"createFFmpegCore"
# assign export name for browser
-s
EXPORT_NAME
=
"createFFmpegCore"
# assign export name for browser
-s
EXPORTED_FUNCTIONS
=
"
$EXPORTED_FUNCTIONS
"
# export main and proxy_main funcs
-s
EXPORTED_FUNCTIONS
=
"
[_main]
"
# export main and proxy_main funcs
-s
EX
TRA_EX
PORTED_RUNTIME_METHODS
=
"[FS, cwrap, ccall, setValue, writeAsciiToMemory]"
# export preamble funcs
-s
EXPORTED_RUNTIME_METHODS
=
"[FS, cwrap, ccall, setValue, writeAsciiToMemory]"
# export preamble funcs
-s
INITIAL_MEMORY
=
2146435072
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB
-s
INITIAL_MEMORY
=
2146435072
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB
--post-js
wasm/src/post.js
--pre-js
wasm/src/pre.js
--pre-js
wasm/src/pre.js
--post-js
wasm/src/post.js
$OPTIM_FLAGS
$OPTIM_FLAGS
${
EXTRA_FLAGS
[@]
}
${
EXTRA_FLAGS
[@]
}
)
)
...
...
wasm/src/post.js
View file @
d712e15d
Module
[
'exit'
]
=
exit
;
wasm/src/pre.js
View file @
d712e15d
...
@@ -7,3 +7,11 @@ Module['quit'] = function(status) {
...
@@ -7,3 +7,11 @@ Module['quit'] = function(status) {
if
(
Module
[
"onExit"
])
Module
[
"onExit"
](
status
);
if
(
Module
[
"onExit"
])
Module
[
"onExit"
](
status
);
throw
new
ExitStatus
(
status
);
throw
new
ExitStatus
(
status
);
}
}
Module
[
'exit'
]
=
exit
;
/**
* Disable all console output, might need to enable it
* for debugging
*/
out
=
err
=
function
()
{}
wasm/tests/exit.test.js
deleted
100644 → 0
View file @
09ebfee7
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
FILE_SIZE
=
38372
;
let
aviData
=
null
;
beforeAll
(()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
});
test
(
'transcode avi to x264 mp4 with exit'
,
async
()
=>
{
const
processExit
=
process
.
exit
;
global
.
process
.
exit
=
jest
.
fn
();
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
const
{
fileSize
}
=
await
runFFmpeg
(
IN_FILE_NAME
,
aviData
,
args
,
OUT_FILE_NAME
,
[],
[],
1000
);
expect
(
fileSize
).
not
.
toBe
(
FILE_SIZE
);
global
.
process
.
exit
=
processExit
;
},
TIMEOUT
);
wasm/tests/multiple-round.test.js
deleted
100644 → 0
View file @
09ebfee7
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
createFFmpegCore
=
require
(
'../packages/core/dist/ffmpeg-core'
);
const
{
TIMEOUT
}
=
require
(
'./config'
);
const
{
runFFmpeg
,
ffmpeg
}
=
require
(
'./utils'
);
const
IN_FILE_NAME
=
'video-1s.avi'
;
const
OUT_FILE_NAME
=
'video.mp4'
;
const
MP4_SIZE
=
38372
;
let
aviData
=
null
;
let
resolve
=
null
;
let
Core
=
null
;
beforeAll
(
async
()
=>
{
aviData
=
Uint8Array
.
from
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'data'
,
IN_FILE_NAME
)));
Core
=
await
createFFmpegCore
({
printErr
:
(
m
)
=>
{
},
print
:
(
m
)
=>
{
if
(
m
.
startsWith
(
'FFMPEG_END'
))
{
resolve
();
}
}
});
},
TIMEOUT
);
test
(
'should transcode to mp4 twice'
,
async
()
=>
{
const
args
=
[
'-i'
,
IN_FILE_NAME
,
OUT_FILE_NAME
];
Core
.
FS
.
writeFile
(
IN_FILE_NAME
,
aviData
);
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
ffmpeg
(
Core
,
args
);
await
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
});
expect
(
Core
.
FS
.
readFile
(
OUT_FILE_NAME
).
length
).
toBe
(
MP4_SIZE
);
Core
.
FS
.
unlink
(
OUT_FILE_NAME
);
}
},
TIMEOUT
);
wasm/tests/transcode
.test
.js
→
wasm/tests/transcode
-base
.js
View file @
d712e15d
...
@@ -3,10 +3,8 @@ const { CASES, TIMEOUT } = require('./config');
...
@@ -3,10 +3,8 @@ const { CASES, TIMEOUT } = require('./config');
require
(
'events'
).
EventEmitter
.
defaultMaxListeners
=
64
;
require
(
'events'
).
EventEmitter
.
defaultMaxListeners
=
64
;
[
module
.
exports
=
(
mode
)
=>
{
{
mode
:
'mt'
,
...
require
(
'./utils'
)(
'mt'
)
},
const
{
getCore
,
ffmpeg
}
=
require
(
'./utils'
)(
mode
);
{
mode
:
'st'
,
...
require
(
'./utils'
)(
'st'
)
},
].
forEach
(({
mode
,
getCore
,
ffmpeg
})
=>
{
CASES
.
forEach
(({
CASES
.
forEach
(({
name
,
name
,
args
,
args
,
...
@@ -38,5 +36,4 @@ require('events').EventEmitter.defaultMaxListeners = 64;
...
@@ -38,5 +36,4 @@ require('events').EventEmitter.defaultMaxListeners = 64;
}
catch
(
e
)
{}
}
catch
(
e
)
{}
},
TIMEOUT
);
},
TIMEOUT
);
});
});
})
};
wasm/tests/transcode-mt.test.js
0 → 100644
View file @
d712e15d
require
(
'./transcode-base'
)(
'mt'
);
wasm/tests/transcode-st.test.js
0 → 100644
View file @
d712e15d
require
(
'./transcode-base'
)(
'st'
);
wasm/tests/transcode.js
View file @
d712e15d
...
@@ -5,6 +5,8 @@ if (process.argv.length > 2) {
...
@@ -5,6 +5,8 @@ if (process.argv.length > 2) {
mode
=
process
.
argv
[
2
];
mode
=
process
.
argv
[
2
];
}
}
require
(
'events'
).
EventEmitter
.
defaultMaxListeners
=
64
;
const
{
getCore
,
ffmpeg
}
=
require
(
'./utils'
)(
mode
);
const
{
getCore
,
ffmpeg
}
=
require
(
'./utils'
)(
mode
);
(
async
()
=>
{
(
async
()
=>
{
...
...
wasm/tests/utils/mt/index.js
View file @
d712e15d
const
parseArgs
=
require
(
'../parseArgs'
);
const
parseArgs
=
require
(
'../parseArgs'
);
let
resolve
=
null
;
let
resolve
=
null
;
const
ffmpeg
=
({
core
,
args
})
=>
{
const
ffmpeg
=
({
core
,
args
})
=>
new
Promise
((
_resolve
)
=>
{
try
{
core
.
ccall
(
core
.
ccall
(
'
proxy_main'
,
// use emscripten_proxy_main if emscripten upgraded
'emscripten_
proxy_main'
,
// use emscripten_proxy_main if emscripten upgraded
'number'
,
'number'
,
[
'number'
,
'number'
],
[
'number'
,
'number'
],
parseArgs
(
core
,
[
'ffmpeg'
,
'-hide_banner'
,
'-nostdin'
,
...
args
]),
parseArgs
(
core
,
[
'ffmpeg'
,
'-hide_banner'
,
'-nostdin'
,
...
args
]),
);
);
}
catch
(
e
)
{
resolve
=
_resolve
;
// TODO: only ignore certain exceptions
}
});
return
new
Promise
((
_resolve
)
=>
{
resolve
=
_resolve
;
});
};
const
getCore
=
()
=>
(
const
getCore
=
()
=>
(
require
(
'../../../packages/core/dist/ffmpeg-core'
)({
require
(
'../../../packages/core/dist/ffmpeg-core'
)({
...
...
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